forked from UltraCosmetics/UltraCosmetics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
208 lines (178 loc) · 5.99 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
allprojects {
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
eclipse.classpath.downloadJavadoc = true
eclipse.classpath.downloadSources = true
idea.module.downloadJavadoc = true
idea.module.downloadSources = true
group = 'be.isach'
version = '3.3'
def classifier = 'RELEASE'
tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
java {
toolchain {
// minimum Java version to compile all subprojects
languageVersion = JavaLanguageVersion.of(17)
}
}
configurations {
shaded
compile.extendsFrom shaded
}
def getGitHash = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', 'HEAD'
standardOutput = stdout
}
return stdout.toString().trim()
}
processResources {
inputs.property("version", project.version)
filter org.apache.tools.ant.filters.ReplaceTokens, tokens: [
'VERSION' : project.version,
'CLASSIFIER': classifier,
'GIT-HASH' : getGitHash()
]
}
afterEvaluate {
jar {
archiveClassifier = classifier
dependsOn configurations.shaded
from configurations.shaded.collect {
it.isDirectory() ?
it :
zipTree(it)
}
}
}
}
defaultTasks 'obfuscate'
subprojects.each {
if (!it.hasProperty("remapMcVersion")) return
tasks.register("obf" + it.name, VersionedObfTask, it)
}
dependencies {
subprojects.each { p ->
if (p.name == "core") {
shaded(project(path: ':core', configuration: 'shadow'))
return;
}
shaded(p) {
transitive false
}
}
}
subprojects { subproj ->
repositories {
mavenLocal()
mavenCentral()
// AnvilGUI
// MobChip
// Treasury
maven {
url "https://repo.codemc.io/repository/maven-snapshots/"
}
// Lib's Disguises
maven {
url 'https://repo.md-5.net/content/groups/public/'
}
// WorldEdit
maven {
url 'https://repo.aikar.co/nexus/content/groups/aikar'
}
// BungeeCord
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots'
}
// PlaceholderAPI
maven {
url 'https://repo.extendedclip.com/content/repositories/placeholderapi/'
}
// PlayerPoints
maven {
url 'https://repo.rosewooddev.io/repository/public/'
}
// Spigot
maven {
url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
// WorldGuard
maven {
url "https://maven.enginehub.org/repo/"
}
// DiscordSRV
maven {
url "https://nexus.scarsz.me/content/groups/public/"
}
// ChestSort
maven {
url "https://hub.jeff-media.com/nexus/repository/jeff-media-public/"
}
// Towny
maven {
url = 'https://repo.glaremasters.me/repository/towny/'
}
// Vault
// PEconomy
maven {
url 'https://jitpack.io'
}
// Mojang Authlib
maven {
url 'https://libraries.minecraft.net'
}
}
def version = 8
if (subproj.hasProperty("javaVersion")) {
version = subproj.property("javaVersion")
}
subproj.tasks.withType(JavaCompile).configureEach {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(version)
}
}
}
abstract class VersionedObfTask extends DefaultTask {
private Project subproj;
@Inject
public VersionedObfTask(Project subproj) {
this.subproj = subproj
dependsOn 'jar'
description 'Generates an obfuscated version of the jar for use with Spigot.'
group = 'jar preparation'
ext.toolingDir = System.getProperty("user.dir")
ext.homeDir = project.gradle.gradleUserHomeDir.parent
}
@TaskAction
def go() {
def nms = subproj.name
def mcVer = subproj.getProperty("remapMcVersion")
def filename = project.tasks.jar.archiveFileName.get()
project.exec {
workingDir project.buildDir
commandLine 'java', '-cp', ext.toolingDir + '/tooling/specialsource/SpecialSource.jar' + File.pathSeparator + ext.homeDir + "/.m2/repository/org/spigotmc/spigot/$mcVer-R0.1-SNAPSHOT/spigot-$mcVer-R0.1-SNAPSHOT-remapped-mojang.jar",
'net.md_5.specialsource.SpecialSource', '--live', '--only', "be/isach/ultracosmetics/$nms", '-q',
'-i', 'libs/' + filename,
'-o', 'libs/obfuscated-donotuse-' + filename,
'-m', ext.homeDir + "/.m2/repository/org/spigotmc/minecraft-server/$mcVer-R0.1-SNAPSHOT/minecraft-server-$mcVer-R0.1-SNAPSHOT-maps-mojang.txt",
'--reverse'
}
project.exec {
workingDir project.buildDir
commandLine 'java', '-cp', ext.toolingDir + '/tooling/specialsource/SpecialSource.jar' + File.pathSeparator + ext.homeDir + "/.m2/repository/org/spigotmc/spigot/$mcVer-R0.1-SNAPSHOT/spigot-$mcVer-R0.1-SNAPSHOT-remapped-obf.jar",
'net.md_5.specialsource.SpecialSource', '--live', '--only', "be/isach/ultracosmetics/$nms", '-q',
'-i', 'libs/obfuscated-donotuse-' + filename,
'-o', 'libs/' + filename,
'-m', ext.homeDir + "/.m2/repository/org/spigotmc/minecraft-server/$mcVer-R0.1-SNAPSHOT/minecraft-server-$mcVer-R0.1-SNAPSHOT-maps-spigot.csrg"
}
}
}
tasks.register("obfuscate") {
dependsOn tasks.withType(VersionedObfTask)
group = 'jar preparation'
}