forked from FabricMC/fabric-loader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
232 lines (198 loc) · 5.97 KB
/
build.gradle
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
plugins {
id 'java'
id 'idea'
id 'eclipse'
id 'maven-publish'
id 'checkstyle'
id("org.cadixdev.licenser") version "0.5.0"
id("fabric-loom") version "0.7-SNAPSHOT"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
archivesBaseName = "fabric-loader"
// Fetch build number from Jenkins
def ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")
repositories {
mavenCentral()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
maven {
name = 'mojang'
url = 'https://libraries.minecraft.net/'
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/legacyJava']
}
}
dependencies {
minecraft "com.mojang:minecraft:1.16.4"
mappings "net.fabricmc:yarn:1.16.4+build.9:v2"
// fabric-loader dependencies
implementation "org.ow2.asm:asm:${project.asm_version}"
implementation "org.ow2.asm:asm-analysis:${project.asm_version}"
implementation "org.ow2.asm:asm-commons:${project.asm_version}"
implementation "org.ow2.asm:asm-tree:${project.asm_version}"
implementation "org.ow2.asm:asm-util:${project.asm_version}"
// Required for mixin annotation processor
annotationProcessor "org.ow2.asm:asm:${project.asm_version}"
annotationProcessor "org.ow2.asm:asm-analysis:${project.asm_version}"
annotationProcessor "org.ow2.asm:asm-commons:${project.asm_version}"
annotationProcessor "org.ow2.asm:asm-tree:${project.asm_version}"
annotationProcessor "org.ow2.asm:asm-util:${project.asm_version}"
implementation('net.fabricmc:sponge-mixin:0.9.4+mixin.0.8.2') {
exclude module: 'launchwrapper'
exclude module: 'guava'
}
implementation 'net.fabricmc:tiny-mappings-parser:0.2.2.14'
implementation 'net.fabricmc:tiny-remapper:0.4.2'
implementation 'net.fabricmc:access-widener:1.0.0'
implementation 'org.ow2.sat4j:org.ow2.sat4j.core:2.3.6'
implementation 'org.ow2.sat4j:org.ow2.sat4j.pb:2.3.6'
// launchwrapper + dependencies
implementation ('net.minecraft:launchwrapper:1.12') {
transitive = false
}
implementation 'net.sf.jopt-simple:jopt-simple:5.0.3'
testCompileOnly 'org.jetbrains:annotations:19.0.0'
// Unit testing for mod metadata
testImplementation('org.junit.jupiter:junit-jupiter:5.6.2')
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this task, sources will not be generated.
withSourcesJar()
}
jar {
manifest {
attributes (
'Main-Class': 'net.fabricmc.loader.impl.launch.server.FabricServerLauncher'
)
}
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// useful for creating test mod jar
task testJar(type: Jar) {
archiveClassifier = "test"
from sourceSets.test.output
}
task copyJson(type: Copy, dependsOn: ["remapJar"]) {
from('src/main/resources/fabric-installer.json') {
rename { "${archivesBaseName}-${version}.json" }
}
into 'build/libs'
}
task copyJsonLw(type: Copy, dependsOn: ["remapJar"]) {
from('src/main/resources/fabric-installer.launchwrapper.json') {
rename { "${archivesBaseName}-${version}.launchwrapper.json" }
}
into 'build/libs'
}
tasks.build.dependsOn "copyJson"
tasks.build.dependsOn "copyJsonLw"
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
// The Minecraft launcher currently installs Java 8 for users, so your mod probably wants to target Java 8 too
// JDK 9 introduced a new way of specifying this that will make sure no newer classes or methods are used.
// We'll use that if it's available, but otherwise we'll use the older option.
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = 8
}
}
javadoc {
options {
if (file("README.html").exists()) {
overview = "README.html"
}
source = "8"
encoding = 'UTF-8'
charSet = 'UTF-8'
memberLevel = JavadocMemberLevel.PACKAGE
links(
'https://asm.ow2.io/javadoc/',
'https://docs.oracle.com/javase/8/docs/api/',
'https://logging.apache.org/log4j/2.x/log4j-api/apidocs/'
)
// Disable the crazy super-strict doclint tool in Java 8
addStringOption('Xdoclint:none', '-quiet')
}
source sourceSets.main.allJava.srcDirs
classpath = sourceSets.main.compileClasspath + sourceSets.main.output // compile impl stuff for dep as well
include("**/api/**")
// workaround as one of the api stuff use that package
failOnError false
}
task javadocJar(type: Jar) {
dependsOn javadoc
from javadoc.destinationDir
classifier = 'javadoc'
}
build.dependsOn javadocJar
checkstyle {
configFile = file("checkstyle.xml")
toolVersion = '8.31'
}
license {
header file("HEADER")
include '**/*.java'
// Exclude gson since it is google's code, we just modify and bundle it
exclude '**/lib/gson/*.java'
}
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
artifact(file("${project.buildDir}/libs/$archivesBaseName-${version}.jar")) {
builtBy remapJar
}
artifact(sourcesJar) {
builtBy remapSourcesJar
}
artifact javadocJar
artifact(file('src/main/resources/fabric-installer.json')) {
builtBy remapJar
}
artifact(file('src/main/resources/fabric-installer.launchwrapper.json')) {
builtBy remapJar
classifier = "launchwrapper"
}
}
}
// select the repositories you want to publish to
repositories {
if (ENV.MAVEN_URL) {
maven {
url ENV.MAVEN_URL
credentials {
username ENV.MAVEN_USERNAME
password ENV.MAVEN_PASSWORD
}
}
}
}
}
// A task to ensure that the version being released has not already been released.
task checkVersion {
doFirst {
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/fabric-loader/maven-metadata.xml").text
def metadata = new XmlSlurper().parseText(xml)
def versions = metadata.versioning.versions.version*.text();
if (versions.contains(version)) {
throw new RuntimeException("${version} has already been released!")
}
}
}
publish.mustRunAfter checkVersion