This repository has been archived by the owner on Jun 14, 2022. It is now read-only.
forked from FabricMC/fabric-loader
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbuild.gradle
221 lines (189 loc) · 5.61 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
plugins {
id "java"
id "maven-publish"
id "idea"
id "eclipse"
id("fabric-loom") version "0.5-SNAPSHOT"
id "maven"
id "signing"
id("org.cadixdev.licenser") version "0.5.0"
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
archivesBaseName = "fabric-loader-1.8.9"
version = version + "+build." + buildTime()
static def buildTime() {
def df = new java.text.SimpleDateFormat("yyyyMMddHHmm")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
// Fetch build number from Jenkins
def ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")
repositories {
mavenCentral()
jcenter()
maven {
name = "Fabric"
url = "http://maven.modmuss50.me/"
}
maven {
name = "mojang"
url = "https://libraries.minecraft.net/"
}
maven {
name = "legacy-fabric"
url = "https://maven.legacyfabric.net"
}
}
dependencies {
minecraft "com.mojang:minecraft:1.8.9"
mappings "net.fabricmc:yarn:1.8.9+build.202104081552"
// Minecraft"s JAR uses these annotations
compile "com.google.code.findbugs:jsr305:3.0.2"
// 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.8.2+build.24") {
exclude module: "launchwrapper"
}
implementation "net.fabricmc:tiny-mappings-parser:0.2.2.14"
implementation "net.fabricmc:tiny-remapper:0.3.0.70"
implementation "net.fabricmc:access-widener:1.0.0"
implementation "com.google.jimfs:jimfs:1.2-fabric"
implementation "net.fabricmc:fabric-loader-sat4j:2.3.5.4"
// 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.launch.server.FabricServerLauncher"
)
}
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
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"
}
javadoc {
options {
source = "8"
encoding = "UTF-8"
charSet = "UTF-8"
memberLevel = JavadocMemberLevel.PACKAGE
links(
"https://guava.dev/releases/21.0/api/docs/",
"https://asm.ow2.io/javadoc/",
"https://docs.oracle.com/javase/8/docs/api/",
"https://jenkins.liteloader.com/job/Mixin/javadoc/",
"https://logging.apache.org/log4j/2.x/log4j-api/apidocs/"
)
addStringOption("Xdoclint:none", "-quiet")
}
classpath = sourceSets.main.compileClasspath
}
task javadocJar(type: Jar) {
dependsOn javadoc
from javadoc.destinationDir
classifier = "javadoc"
}
build.dependsOn javadocJar
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(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 {
// mavenLocal()
if (System.getenv("MAVEN_PUBLISH_TOKEN") != null)
{
maven {
url = "https://maven.legacyfabric.net/"
credentials {
username = "BobTheBuildSlave"
password = System.getenv("MAVEN_PUBLISH_TOKEN")
}
authentication {
basic(BasicAuthentication)
}
}
}
}
}
// A task to ensure that the version being released has not already been released.
task checkVersion {
doFirst {
def xml = new URL("https://maven.legacyfabric.net/net/fabricmc/fabric-loader-1.8.9/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