-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.gradle.kts
242 lines (203 loc) · 7.24 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import groovy.util.ConfigObject
import groovy.util.ConfigSlurper
import org.gradle.jvm.tasks.Jar
import java.io.File
import java.util.Properties
import java.time.LocalDateTime
buildscript {
repositories {
maven("https://files.minecraftforge.net/maven")
mavenCentral()
gradlePluginPortal()
}
}
plugins {
scala
//We apply these to get pretty build script
java
idea
maven
signing
id("com.github.johnrengelman.shadow").version("2.0.4")
id("net.minecraftforge.gradle").version("3.0.179")
}
val scaladoc: ScalaDoc by tasks
val compileJava: JavaCompile by tasks
val compileScala: ScalaCompile by tasks
val jar: Jar by tasks
val shadowJar: ShadowJar by tasks
val config = parseConfig(file("build.properties"))
java {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
compileJava.options.encoding = "UTF-8"
compileScala.scalaCompileOptions.additionalParameters = listOf("-Xexperimental")
scaladoc.scalaDocOptions.additionalParameters = listOf("-Xexperimental")
version = "${config["mc_version"]}-${config["version"]}"
group = "net.katsstuff.teamnightclipse"
base.archivesBaseName = "danmakucore"
sourceSets["main"].apply {
java {
setSrcDirs(listOf<File>())
}
withConvention(ScalaSourceSet::class) {
scala {
srcDir("src/main/java")
}
}
}
minecraft {
mappings("snapshot", "20171003-1.12")
accessTransformer(file("src/main/resources/danmakucore_at.cfg"))
runs {
create("client") {
workingDirectory(if (file("../run1.12").exists()) "../run1.12" else "run")
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
}
create("server") {
property("forge.logging.markers", "SCAN,REGISTRIES,REGISTRYDUMP")
property("forge.logging.console.level", "debug")
}
}
}
repositories {
maven {
name = "TeamNightclipse Bintray"
setUrl("https://dl.bintray.com/team-nightclipse/maven/")
}
maven {
name = "ilexiconn"
setUrl("https://maven.mcmoddev.com")
}
jcenter()
mavenLocal()
}
dependencies {
minecraft("net.minecraftforge:forge:${config["mc_version"]}-${config["forge_version"]}")
compileOnly("net.katsstuff.teamnightclipse:mirror:1.12.2-0.6.0-SNAPSHOT")
runtimeOnly("net.katsstuff.teamnightclipse:mirror:1.12.2-0.6.0-SNAPSHOT:dev")
compile("org.scala-lang:scala-library:2.11.4") //Gets ourself a better compiler
}
shadowJar.apply {
classifier = "shaded"
configurations = listOf()
relocate("shapeless", "net.katsstuff.teamnightclipse.mirror.shade.shapeless")
}
jar.apply {
exclude("**/*.psd")
manifest {
attributes(
mapOf(
"FMLAT" to "danmakucore_at.cfg",
"Specification-Title" to "DanmakuCore",
"Specification-Vendor" to "TeamNightclipse",
"Specification-Version" to "1", // We are version 1 of ourselves
"Implementation-Title" to project.name,
"Implementation-Version" to version,
"Implementation-Vendor" to "TeamNightclipse",
"Implementation-Timestamp" to LocalDateTime.now().toString()
)
)
}
}
tasks.withType<ProcessResources> {
inputs.property("version", project.version)
inputs.property("mcversion", config["mc_version"])
from(sourceSets["main"].resources.srcDirs) {
include("mcmod.info")
expand(mapOf("version" to project.version, "mcversion" to config["mc_version"]))
}
from(sourceSets["main"].resources.srcDirs) {
exclude("mcmod.info")
}
}
fun parseConfig(config: File): ConfigObject {
val prop = Properties()
prop.load(config.reader())
return ConfigSlurper().parse(prop)
}
idea.module.inheritOutputDirs = true
reobf {
create("shadowJar") {
mappings = tasks.getByName<net.minecraftforge.gradle.mcp.task.GenerateSRG>("createMcpToSrg").output
}
}
tasks["build"].dependsOn(shadowJar)
val deobfJar by tasks.creating(Jar::class) {
classifier = "dev"
from(sourceSets["main"].output)
}
val sourcesJar by tasks.creating(Jar::class) {
classifier = "sources"
from(sourceSets["main"].allSource)
}
val javadocJar by tasks.creating(Jar::class) {
classifier = "javadoc"
dependsOn(scaladoc)
from(scaladoc.destinationDir)
}
artifacts {
add("archives", shadowJar)
add("archives", sourcesJar)
add("archives", javadocJar)
add("archives", deobfJar)
}
signing {
useGpgCmd()
sign(configurations.archives)
}
tasks {
"uploadArchives"(Upload::class) {
repositories {
withConvention(MavenRepositoryHandlerConvention::class) {
mavenDeployer {
beforeDeployment {
signing.signPom(this)
}
withGroovyBuilder {
val releasesUri = """https://api.bintray.com/maven/team-nightclipse/maven/DanmakuCore/;publish=1"""
"repository"("url" to uri(releasesUri)) {
"authentication"("userName" to properties["bintray.user"], "password" to properties["bintray.apikey"])
}
/*
"snapshotRepository"("url" to uri("TODO")) {
"authentication"("userName" to properties["bintray.user"], "password" to properties["bintray.apikey"])
}
*/
}
pom.project {
withGroovyBuilder {
"description"("A library for Minecraft for creating Danmaku")
"licenses" {
"license" {
"name"("GNU General Lesser Public License (LGPL) version 3.0")
"url"("http://www.gnu.org/licenses/lgpl.txt")
"distribution"("repo")
}
}
"scm" {
"url"("https://github.com/TeamNightclipse/DanmakuCore")
"connection"("scm:git:github.com/TeamNightclipse/DanmakuCore")
"developerConnection"("scm:git:github.com/TeamNightclipse/DanmakuCore")
}
"issueManagement" {
"system"("github")
"url"("https://github.com/TeamNightclipse/DanmakuCore/issues")
}
"developers" {
"developer" {
"id"("Nikolai Frid")
"email"("[email protected]")
"url"("http://katsstuff.net/")
}
}
}
}
}
}
}
}
}