forked from FabricMC/fabric-installer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
194 lines (161 loc) · 4.18 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
plugins {
id 'java'
id 'maven-publish'
id "checkstyle"
id "com.github.johnrengelman.shadow" version "7.0.0"
id "org.cadixdev.licenser" version "0.6.1"
id "de.undercouch.download" version "4.1.2"
id "me.modmuss50.remotesign" version "0.1.0"
}
sourceCompatibility = 1.8
version = '1.0.0-babric.2'
archivesBaseName = "fabric-installer"
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'
}
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')
}
task serverJar(type: com.github.jengelman.gradle.plugins.shadow.tasks.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.1"
def bootstrapArch = "i686"
task downloadBootstrap(type: Download) {
src "https://maven.fabricmc.net/net/fabricmc/fabric-installer-native-bootstrap/windows-${bootstrapArch}/${bootstrapVersion}/windows-${bootstrapArch}-${bootstrapVersion}.exe"
dest project.buildDir
}
task nativeExe(dependsOn: [shadowJar, downloadBootstrap], type: FileOutput) {
output = file("${projectDir}/build/libs/${archivesBaseName}-${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
}
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
}
license {
header rootProject.file("HEADER")
include "**/*.java"
}
publishing {
publications {
maven(MavenPublication) {
groupId project.group
artifactId project.archivesBaseName
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.
task checkVersion {
doFirst {
def xml = new URL("https://maven.fabricmc.net/net/fabricmc/fabric-installer/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
class FileOutput extends DefaultTask {
@OutputFile
File output
}