This repository has been archived by the owner on Aug 2, 2023. It is now read-only.
forked from FabricMC/fabric-language-kotlin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle.kts
202 lines (180 loc) · 6.26 KB
/
build.gradle.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
import com.matthewprenger.cursegradle.CurseArtifact
import com.matthewprenger.cursegradle.CurseProject
import com.matthewprenger.cursegradle.CurseUploadTask
import com.matthewprenger.cursegradle.Options
import net.fabricmc.loom.task.RemapJarTask
import net.fabricmc.loom.task.RemapSourcesJarTask
plugins {
kotlin("jvm") version Jetbrains.Kotlin.version
`maven-publish`
id("moe.nikky.persistentCounter") version "0.0.8-SNAPSHOT"
id("net.minecrell.licenser") version "0.4.1"
id("com.matthewprenger.cursegradle") version CurseGradle.version
id("fabric-loom") version Fabric.Loom.version
}
base {
archivesBaseName = Constants.modid
}
val buildNumber = counter.variable(id = "buildNumber", key = Constants.modVersion + branch)
group = Constants.group
description = Constants.description
version = System.getenv("BUILD_NUMBER")?.let { "${Constants.modVersion}+build.$buildNumber" }
?: "${Constants.modVersion}+local"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
tasks.getByName<ProcessResources>("processResources") {
filesMatching("fabric.mod.json") {
expand(
mutableMapOf(
"version" to version
)
)
}
}
license {
header = file("HEADER")
include("**/*.java")
include("**/*.kt")
}
repositories {
maven(url = "http://maven.fabricmc.net") {
name = "Fabric"
}
maven(url = "https://libraries.minecraft.net/") {
name = "Mojang"
}
maven(url = "https://kotlin.bintray.com/kotlinx/") {
name = "KotlinX"
}
mavenCentral()
jcenter()
}
fun DependencyHandlerScope.includeAndExpose(dep: String) {
modApi(dep)
include(dep)
}
dependencies {
minecraft(group = "com.mojang", name = "minecraft", version = Minecraft.version)
mappings(group = "net.fabricmc", name = "yarn", version = Fabric.YarnMappings.version, classifier = "v2")
modImplementation(group = "net.fabricmc", name = "fabric-loader", version = Fabric.Loader.version)
includeAndExpose(Jetbrains.Kotlin.stdLib)
includeAndExpose(Jetbrains.Kotlin.stdLibJkd8)
includeAndExpose(Jetbrains.Kotlin.stdLibJkd7)
includeAndExpose(Jetbrains.Kotlin.reflect)
includeAndExpose(Jetbrains.annotations)
includeAndExpose(Jetbrains.KotlinX.coroutinesCore)
includeAndExpose(Jetbrains.KotlinX.coroutinesJdk8)
}
val remapJar = tasks.getByName<RemapJarTask>("remapJar")
val remapSourcesJar = tasks.getByName<RemapSourcesJarTask>("remapSourcesJar")
val sourcesJar = tasks.create<Jar>("sourcesJar") {
archiveClassifier.set("sources")
from(sourceSets["main"].allSource)
}
publishing {
publications {
create("main", MavenPublication::class.java) {
groupId = project.group.toString()
artifactId = project.name.toLowerCase()
version = project.version.toString()
artifact(remapJar) {
builtBy(remapJar)
}
artifact(sourcesJar) {
builtBy(remapSourcesJar)
}
}
}
repositories {
maven(url = "http://mavenupload.modmuss50.me/") {
val mavenPass: String? = project.properties["mavenPass"] as String?
mavenPass?.let {
credentials {
username = "buildslave"
password = mavenPass
}
}
}
}
}
val curse_api_key: String? by project
if (curse_api_key != null && project.hasProperty("release")) {
val CURSEFORGE_RELEASE_TYPE: String by project
val CURSEFORGE_ID: String by project
curseforge {
options(closureOf<Options> {
forgeGradleIntegration = false
})
apiKey = curse_api_key
project(closureOf<CurseProject> {
id = CURSEFORGE_ID
releaseType = CURSEFORGE_RELEASE_TYPE
addGameVersion("1.14")
addGameVersion("1.14.1")
addGameVersion("1.14.2")
addGameVersion("1.14.3")
addGameVersion("1.14.4")
addGameVersion("1.15-Snapshot")
addGameVersion("1.15")
addGameVersion("Fabric")
val changelog_file: String? by project
if (changelog_file != null) {
println("changelog = $changelog_file")
changelogType = "markdown"
changelog = file(changelog_file as String)
}
mainArtifact(
file("${project.buildDir}/libs/${base.archivesBaseName}-${version}.jar"),
closureOf<CurseArtifact> {
displayName = "Fabric Language Kotlin $version"
})
})
}
project.afterEvaluate {
tasks.getByName<CurseUploadTask>("curseforge${CURSEFORGE_ID}") {
dependsOn(remapJar)
}
}
}
tasks.create<Copy>("processMDTemplates") {
group = "documentation"
from(rootDir.resolve("templates"))
include("**/*.template.md")
filesMatching("**/*.template.md") {
name = sourceName.substringBeforeLast(".template.md") + ".md"
expand(
"KOTLIN_VERSION" to Jetbrains.Kotlin.version,
"LOADER_VERSION" to Fabric.Loader.version,
"BUNDLED_STDLIB" to Jetbrains.Kotlin.stdLibJkd8,
"BUNDLED_REFLECT" to Jetbrains.Kotlin.reflect,
"BUNDLED_ANNOTATIONS" to Jetbrains.annotations,
"BUNDLED_COROUTINES_CORE" to Jetbrains.KotlinX.coroutinesCore,
"BUNDLED_COROUTINES_JDK8" to Jetbrains.KotlinX.coroutinesJdk8
)
}
destinationDir = rootDir
}
task<DefaultTask>("depsize") {
group = "help"
description = "prints dependency sizes"
doLast {
val formatStr = "%,10.2f"
val size = configurations.default.resolve()
.map { it.length() / (1024.0 * 1024.0) }.sum()
val out = buildString {
append("Total dependencies size:".padEnd(45))
append("${String.format(formatStr, size)} Mb\n\n")
configurations
.default
.resolve()
.sortedWith(compareBy { -it.length() })
.forEach {
append(it.name.padEnd(45))
append("${String.format(formatStr, (it.length() / 1024.0))} kb\n")
}
}
println(out)
}
}