-
Notifications
You must be signed in to change notification settings - Fork 66
/
build.gradle
209 lines (173 loc) · 4.37 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
plugins {
id 'java'
id 'maven-publish'
id "checkstyle"
id "com.gradleup.shadow" version "8.3.0"
id "com.diffplug.spotless" version "6.20.0"
id "de.undercouch.download" version "5.6.0"
id "me.modmuss50.remotesign" version "0.4.0"
}
version = '1.0.1'
def ENV = System.getenv()
version = version + (ENV.GITHUB_ACTIONS ? "" : "+local")
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
}
def nativeLibVersion = "0.1.3"
def nativeLibDistributions = [
"windows-ARM64", "windows-Win32", "windows-x64", "macos-x86_64_arm64"
]
dependencies {
implementation ('org.sharegov:mjson:1.4.1') {
transitive false
}
nativeLibDistributions.each {
implementation "net.fabricmc.fabric-installer-native-lib:${it}:${nativeLibVersion}"
}
testImplementation 'junit:junit:4.13.2'
}
base {
archivesName = "fabric-installer"
}
java {
sourceCompatibility = JavaVersion.VERSION_1_8
}
tasks.withType(JavaCompile).configureEach {
it.options.encoding = "UTF-8"
if (JavaVersion.current().isJava9Compatible()) {
it.options.release = 8
}
}
checkstyle {
configFile = project.file("checkstyle.xml")
toolVersion = "8.45"
}
shadowJar {
manifest {
attributes 'Implementation-Title': 'FabricInstaller',
'Implementation-Version': project.version,
'Main-Class': 'net.fabricmc.installer.Main'
}
minimize()
archiveClassifier.set(null)
exclude('icon.ico')
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
tasks.register('serverJar', ShadowJar) {
manifest {
attributes 'Implementation-Title': 'FabricInstaller',
'Implementation-Version': project.version,
'Main-Class': 'net.fabricmc.installer.ServerLauncher'
}
minimize()
exclude('icon.ico')
exclude('*.png')
exclude('natives/*')
archiveClassifier = "server"
from sourceSets.main.output
configurations = [project.configurations.compileClasspath]
}
assemble.dependsOn serverJar
def bootstrapVersion = "0.5.2"
def bootstrapArch = "i686"
tasks.register('downloadBootstrap', Download) {
src "https://maven.fabricmc.net/net/fabricmc/fabric-installer-native-bootstrap/windows-${bootstrapArch}/${bootstrapVersion}/windows-${bootstrapArch}-${bootstrapVersion}.exe"
dest layout.buildDirectory
overwrite false
}
tasks.register('nativeExe', FileOutput) {
dependsOn shadowJar
dependsOn downloadBootstrap
output = file("${projectDir}/build/libs/${base.archivesName.get()}-${project.version}.exe")
outputs.upToDateWhen { false }
doFirst {
output.delete()
}
doLast {
output.createNewFile()
output.setBytes downloadBootstrap.outputFiles.first().readBytes()
if (ENV.SIGNING_SERVER) {
output.append signShadowJar.archiveFile.get().getAsFile().readBytes()
} else {
output.append shadowJar.archiveFile.get().getAsFile().readBytes()
}
}
}
build.dependsOn nativeExe
jar {
enabled = false
manifest {
attributes('Enable-Native-Access': 'ALL-UNNAMED')
}
}
if (ENV.SIGNING_SERVER) {
remoteSign {
requestUrl = ENV.SIGNING_SERVER
pgpAuthKey = ENV.SIGNING_PGP_KEY
jarAuthKey = ENV.SIGNING_JAR_KEY
sign (shadowJar)
afterEvaluate {
sign publishing.publications.maven
}
}
nativeExe.dependsOn signShadowJar
}
spotless {
java {
licenseHeaderFile(rootProject.file("HEADER"))
}
}
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId base.archivesName.get()
version project.version
if (ENV.SIGNING_SERVER) {
artifact (signShadowJar) {
classifier null
}
} else {
artifact (shadowJar) {
classifier null
}
}
artifact nativeExe.output
// No point in signing as it is designed to get modified
artifact (serverJar) {
classifier "server"
}
}
}
repositories {
maven {
if (ENV.MAVEN_URL) {
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.
tasks.register('checkVersion') {
doFirst {
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/fabric-installer/maven-metadata.xml").text
def metadata = new groovy.xml.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
class FileOutput extends DefaultTask {
@OutputFile
File output
}