This repository has been archived by the owner on Jun 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
build.gradle
255 lines (220 loc) · 6.43 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
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
plugins {
id 'application'
id 'eclipse'
id 'idea'
id 'maven-publish'
id 'checkstyle'
id 'com.github.johnrengelman.shadow' version '6.1.0'
}
tasks.withType(JavaCompile).configureEach {
def targetVersion = 8
if (JavaVersion.current().isJava9Compatible()) {
it.options.release.set(targetVersion)
} else {
sourceCompatibility = JavaVersion.toVersion(targetVersion)
targetCompatibility = JavaVersion.toVersion(targetVersion)
}
}
def ENV = System.getenv()
version = new String(file(".version").bytes).substring(1)
if (!(ENV.MAVEN_PASSWORD)) {
version = version + "-SNAPSHOT"
}
print(version)
group = 'net.patchworkmc'
archivesBaseName = 'patchwork-patcher'
checkstyle {
configFile = rootProject.file("checkstyle.xml")
toolVersion = '8.25'
}
sourceSets {
cli {
java {
compileClasspath += main.output
compileClasspath += sourceSets.main.compileClasspath
runtimeClasspath += main.output
runtimeClasspath += sourceSets.main.runtimeClasspath
}
}
ui {
java {
compileClasspath += main.output
compileClasspath += sourceSets.main.compileClasspath
runtimeClasspath += main.output
runtimeClasspath += sourceSets.main.runtimeClasspath
}
}
}
repositories {
mavenCentral()
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net'
}
maven {
url 'https://maven.patchworkmc.net'
}
}
dependencies {
// ASM
implementation 'org.ow2.asm:asm:9.0'
implementation 'org.ow2.asm:asm-analysis:9.0'
implementation 'org.ow2.asm:asm-commons:9.0'
implementation 'org.ow2.asm:asm-tree:9.0'
implementation 'org.ow2.asm:asm-util:9.0'
// Patchwork
implementation 'net.patchworkmc:patchwork-manifest:1.0.1'
// Logging
implementation 'org.apache.logging.log4j:log4j-api:2.13.2'
implementation 'org.apache.logging.log4j:log4j-core:2.13.2'
runtimeOnly 'net.minecrell:terminalconsoleappender:1.2.0'
runtimeOnly 'org.jline:jline-terminal-jansi:3.12.1'
// Other dependencies
implementation 'net.fabricmc:tiny-remapper:0.3.1.72'
// Needed for merging the client and server jar
implementation ('net.fabricmc:stitch:0.4.6+build.74') {
exclude module: 'enigma'
}
implementation 'com.electronwill.night-config:toml:3.6.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation "commons-io:commons-io:2.7"
implementation "org.jetbrains:annotations:16.0.2"
// Java has it's own XML parsers, but they were made before generics and are a perfect example
// of awful corporate old java style.
implementation "org.dom4j:dom4j:2.1.3"
}
task sourcesJar(type: Jar, dependsOn: classes) {
archiveClassifier.set 'sources'
from sourceSets.main.allSource
}
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
shadowJar {
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
minimize {
exclude(dependency("org.dom4j:dom4j:2.1.3"))
exclude(dependency("org.apache.logging.log4j:log4j-core:2.13.2"))
exclude(dependency("net.minecrell:terminalconsoleappender:1.2.0"))
exclude(dependency("org.jline:jline-terminal-jansi:3.12.1"))
exclude(dependency("com.electronwill.night-config:toml:3.6.0"))
}
}
task shadowCliJar(type: ShadowJar, dependsOn: shadowJar) {
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
archiveClassifier.set("cli")
from sourceSets.cli.output
from zipTree(shadowJar.archiveFile.get())
configurations = [ configurations.cliRuntime ]
minimize {
exclude(dependency("org.dom4j:dom4j:2.1.3"))
exclude(dependency("org.apache.logging.log4j:log4j-core:2.13.2"))
exclude(dependency("net.minecrell:terminalconsoleappender:1.2.0"))
exclude(dependency("org.jline:jline-terminal-jansi:3.12.1"))
exclude(dependency("com.electronwill.night-config:toml:3.6.0"))
}
manifest {
attributes(
'Implementation-Title': 'Patchwork Patcher (CLI)',
'Implementation-Version': archiveVersion.get(),
'Main-Class': "net.patchworkmc.patcher.cli.PatchworkCLI"
)
}
}
task shadowUiJar(type: ShadowJar, dependsOn: shadowJar) {
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer)
archiveClassifier.set("ui")
from sourceSets.ui.output
from zipTree(shadowJar.archiveFile.get())
configurations = [ configurations.uiRuntime ]
minimize {
exclude(dependency("org.dom4j:dom4j:2.1.3"))
exclude(dependency("org.apache.logging.log4j:log4j-core:2.13.2"))
exclude(dependency("net.minecrell:terminalconsoleappender:1.2.0"))
exclude(dependency("org.jline:jline-terminal-jansi:3.12.1"))
exclude(dependency("com.electronwill.night-config:toml:3.6.0"))
}
manifest {
attributes(
'Implementation-Title': 'Patchwork Patcher (UI)',
'Implementation-Version': archiveVersion.get(),
'Main-Class': "net.patchworkmc.patcher.ui.PatchworkUI"
)
}
}
task removeStepJar(type: Delete, dependsOn: shadowJar) {
delete shadowJar.archiveFile.get()
}
shadowJar.finalizedBy shadowCliJar
shadowCliJar.finalizedBy shadowUiJar
shadowUiJar.finalizedBy removeStepJar
publishing {
publications {
maven(MavenPublication) {
groupId 'net.patchworkmc'
artifactId "patchwork-patcher"
version version
artifact (jar)
artifact (sourcesJar)
}
}
}
application {
mainClassName "net.patchworkmc.patcher.ui.PatchworkUI"
if (file('.classpath').exists()) {
println("Eclipse detected. Disabling ANSI.")
applicationDefaultJvmArgs = ['-Dpatchwork.log.disableAnsi=true']
}
}
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
def runDir = file("run")
if(!runDir.exists() && !runDir.mkdirs()) {
throw new IOException("Failed to create run directory ${runDir.getAbsolutePath()}")
}
run {
workingDir runDir
}
jar {
manifest {
attributes(
'Implementation-Title': 'Patchwork Patcher',
'Implementation-Version': archiveVersion.get()
)
}
}
publishing {
publications {
mavenJava(MavenPublication) {
// add all the jars that should be included when publishing to maven
afterEvaluate {
artifact jar
artifact sourcesJar
}
}
}
repositories {
if (ENV.MAVEN_PASSWORD) {
maven {
url 'https://maven.patchworkmc.net/releases'
credentials {
username "patchworkmc"
password ENV.MAVEN_PASSWORD
}
}
}
}
}
task bumpVersion() {
doLast {
def versionSplit = ((String) version).split("\\.")
new File(".version").write("v" + versionSplit[0] + "." + (versionSplit[1].toInteger() + 1))
}
}
publish.finalizedBy bumpVersion
task copyIdeaFiles(type: Copy) {
if (file(".idea/").exists()) {
from "idea-docs/"
into ".idea/"
}
}
copyIdeaFiles