-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
161 lines (128 loc) · 4.54 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
plugins {
id "java"
id "maven-publish"
id "java-gradle-plugin"
id "idea"
id "eclipse"
}
//Heads up: This buildscript is a bit weird, because some of the "sample" projects compile it against Gradle 4,
//but others compile it against Gradle 7. The sample projects retrieve the plugin as an included build, not as
//a separate artifact (mainly to avoid a roundtrip through mavenLocal), which causes all sorts of fun problems
//in practice. I probably shouldn't do that.
// CI nonsense //
String buildContext = "Local"
if(System.getenv("GITHUB_SHA") != null) {
String hash = System.getenv("GITHUB_SHA"); if(hash.length() > 8) hash = hash.substring(0, 8)
buildContext = "Github Actions CI, commit " + hash
if(System.getenv("VOLDE_RELEASE_MODE") == null) {
version += "-SNAPSHOT"
}
}
// Pre-toolchains: the canonical way to set source compatibility? //
// Post-toolchains: used as a default when no toolchain is configured //
sourceCompatibility = "1.8"
targetCompatibility = "1.8"
// Dependencies //
repositories {
maven {
name = "Fabric"
url = "https://maven.fabricmc.net/"
if(it.respondsTo("mavenContent")) { //doesn't exist in Gradle 4
it.mavenContent {
includeGroup("net.fabricmc")
includeGroup("org.jetbrains")
includeGroup("org.cadixdev")
}
}
}
mavenCentral()
}
dependencies {
implementation gradleApi() //the currently-running version of Gradle
//java staples
compileOnly "org.jetbrains:annotations:24.0.1"
implementation "com.google.code.gson:gson:2.8.5"
//bytecode
implementation "org.ow2.asm:asm:9.1"
implementation "org.ow2.asm:asm-commons:9.1"
implementation "org.ow2.asm:asm-tree:9.1"
//mappings
implementation "net.fabricmc:tiny-mappings-parser:0.3.0+build.17"
implementation ("net.fabricmc:tiny-remapper:0.8.6") { transitive = false } //disabling transitives removes another copy of asm (this time 9.3)
//decompilers
implementation "org.jetbrains:intellij-fernflower:1.2.1.16"
//for working with forge 1.6's binpatches.pack.lzma
implementation "org.tukaani:xz:1.9" //lzma decompression
implementation "org.apache.commons:commons-compress:1.25.0" //pack200 decompression
//implementation ("net.fabricmc:lorenz-tiny:1.0.0+build.1") { transitive = false } //TODO: only used by MigrateMappingsTask
//implementation "org.cadixdev:mercury:0.1.0.fabric-SNAPSHOT" //TODO: only used by RemapSourcesJar
}
// Properties of the artifact //
jar {
manifest {
//Reading from project.version is deprecated in Gradle 7 lol
String ver = project.respondsTo("archivesVersion") ? project.archivesVersion : project.version
attributes "Implementation-Version": "${ver} (build ctx: ${buildContext})"
}
}
gradlePlugin {
plugins {
"${name}" {
id = "${group}.${name}"
implementationClass = "net.fabricmc.loom.LoomGradlePlugin"
}
}
}
// Publishing //
task sourcesJar(type: Jar, dependsOn: classes) {
if(it.hasProperty("archiveClassifier")) it.archiveClassifier = "sources" //Gradle 7, 8
else it.classifier = "sources" //Gradle 4
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
if(it.hasProperty("archiveClassifier")) it.archiveClassifier = "javadoc" //Gradle 7, 8
else it.classifier = "javadoc" //Gradle 4
from javadoc.destinationDir
}
publishing {
publications {
plugin(MavenPublication) { publication ->
groupId project.group
artifactId project.archivesBaseName
version project.version
from components["java"]
artifact sourcesJar
artifact javadocJar
}
}
repositories {
if (project.hasProperty("publish-username")) {
maven {
url "https://repo-api.sleeping.town/"
credentials {
username project.hasProperty("publish-username") ? project.getProperty("publish-username") : null
password project.hasProperty("publish-password") ? project.getProperty("publish-password") : null
}
}
}
maven {
url file("build/maven").toURI().toString()
}
}
}
// Javadoc settings //
javadoc {
options {
List<String> links = []
links.add("https://docs.gradle.org/${gradle.gradleVersion}/javadoc/")
links.add("https://javadoc.io/doc/com.google.code.gson/gson/2.8.5/")
links.add("https://javadoc.io/doc/com.google.guava/guava/28.0-jre/")
//yoinked off stackoverflow https://stackoverflow.com/questions/10766238/javadoc-parameter-without-package-name
if (JavaVersion.current().isJava11Compatible()) {
links.add("https://docs.oracle.com/en/java/javase/${JavaVersion.current().majorVersion}/docs/api/")
} else {
links.add("https://docs.oracle.com/javase/${JavaVersion.current().majorVersion}/docs/api/")
}
it.links(links as String[])
}
}