forked from iSach/UltraCosmetics
-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathbuild.gradle
171 lines (152 loc) · 5.84 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
import org.apache.tools.ant.filters.ReplaceTokens
allprojects {
apply plugin: 'java-library'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'maven-publish'
eclipse.classpath.downloadJavadoc = true
eclipse.classpath.downloadSources = true
idea.module.downloadJavadoc = true
idea.module.downloadSources = true
group = 'be.isach.UltraCosmetics'
version = '3.10.1-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(21)
}
}
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 ReplaceTokens, tokens: [
'VERSION' : project.version,
'GIT-HASH': getGitHash()
]
}
afterEvaluate {
jar {
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, 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/' }
// SpigotMC
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://repo.jeff-media.com/public/' }
// Towny
maven { url = 'https://repo.glaremasters.me/repository/towny/' }
// PlayerAuctions
maven { url = 'https://repo.olziedev.com/' }
// Vault, PEconomy, MobChipLite, FoliaLib
maven { url = 'https://jitpack.io' }
// Paper API
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
// Mojang Authlib
maven { url = 'https://libraries.minecraft.net' }
}
def version = 17
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'
}