-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathbuild.gradle
More file actions
170 lines (136 loc) · 4.88 KB
/
build.gradle
File metadata and controls
170 lines (136 loc) · 4.88 KB
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
plugins {
id 'java'
id 'com.gradleup.shadow' version '9.4.1'
id 'maven-publish'
}
group 'WildTools'
version = "2026.1"
project.ext {
targetFolder = file("target/")
buildVersion = System.getenv("BUILD_NUMBER") == null || Boolean.parseBoolean(System.getenv("STABLE_BUILD")) ?
version : version + "-b" + System.getenv("BUILD_NUMBER")
}
allprojects {
apply plugin: 'java'
apply plugin: 'com.gradleup.shadow'
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(8))
}
}
repositories {
maven { url 'https://repo.bg-software.com/repository/nms/' }
maven { url 'https://repo.bg-software.com/repository/api/' }
maven { url 'https://repo.bg-software.com/repository/common/' }
maven { url 'https://repo.bg-software.com/repository/dependencies/' }
}
dependencies {
compileOnly "com.bgsoftware.common.reflection:ReflectionUtils:b8"
}
tasks.register('checkDebug') {
Set<File> filesWithDebug = fileTree('src/main/java').filter { file ->
file.text.contains('Bukkit.broadcastMessage')
}.getFiles()
if (!filesWithDebug.isEmpty())
throw new GradleException("Found debug messages: " + filesWithDebug)
}
shadowJar {
relocate 'com.bgsoftware.common', 'com.bgsoftware.wildtools.libs.com.bgsoftware.common'
}
build {
dependsOn checkDebug
dependsOn shadowJar
}
}
repositories {
mavenCentral()
}
dependencies {
implementation project(":API")
implementation 'com.bgsoftware.common.reflection:ReflectionUtils:b8'
implementation 'com.bgsoftware.common.updater:Updater:b1'
implementation 'com.bgsoftware.common.config:CommentedConfiguration:b1'
implementation 'com.bgsoftware.common.shopsbridge:ShopsBridge:b20:all@jar'
implementation 'com.bgsoftware.common.dependencies:DependenciesManager:b2'
implementation 'com.bgsoftware.common.nmsloader:NMSLoader:b20'
implementation 'org.bstats:bstats-bukkit:3.0.0'
// Spigot jars
compileOnly "org.spigotmc:v1_7_R3:latest"
compileOnly 'org.spigotmc:v1_16_R3-Tuinity:latest'
}
processResources {
outputs.upToDateWhen { false }
eachFile { details ->
if (details.name.contentEquals('plugin.yml')) {
filter { String line ->
line.replace('${project.version}', rootProject.buildVersion)
}
}
}
}
subprojects.each { evaluationDependsOn(it.path) }
shadowJar {
relocate 'org.bstats', 'com.bgsoftware.wildtools.libs.org.bstats'
archiveClassifier.set('')
from sourceSets.main.output
from(project.configurations.runtimeClasspath.filter { it.name.endsWith('.jar') }.collect { zipTree(it) }) {
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA'
}
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
subprojects.each { sub ->
if (sub.path.startsWith(':NMS:v1')) {
try {
def reobfTask = sub.tasks.named('reobfJar')
dependsOn(reobfTask)
from(reobfTask.map { it.outputJar }) {
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA'
rename { sub.name }
into("nms")
}
return;
} catch (Exception ignored) {
}
}
if (sub.path.startsWith(':NMS:v')) {
def shadowJarTask = sub.tasks.named("shadowJar")
dependsOn(shadowJarTask)
from(shadowJarTask.map { it.archiveFile }) {
exclude 'META-INF/MANIFEST.MF', 'META-INF/*.SF', 'META-INF/*.DSA', 'META-INF/*.RSA'
rename { sub.name }
into("nms")
}
} else {
from sub.sourceSets.main.output
}
}
dependencies {
// This includes the API and all sub-modules in the final JAR
include project(':API')
// Use a loop to include all NMS and Hook subprojects automatically
subprojects.findAll { it.path.startsWith(':NMS:') || it.path.startsWith(':Hooks:') }.each { sub ->
include project(sub.path)
}
}
}
tasks.register('cleanTarget', Delete) {
delete rootProject.targetFolder
}
tasks.register('collectArtifacts', Copy) {
group = 'build'
dependsOn('cleanTarget')
dependsOn(tasks.named('shadowJar'))
dependsOn(project(':API').tasks.named('shadowJar'))
from(tasks.named('shadowJar').map { it.archiveFile }) {
rename { rootProject.name + "-" + rootProject.buildVersion + ".jar" }
}
from(project(':API').tasks.named('shadowJar').map { it.archiveFile }) {
rename { rootProject.name + "-API.jar" }
}
into(rootProject.targetFolder)
}
tasks.named('build') {
dependsOn(tasks.named('shadowJar'))
}
tasks.named('shadowJar') {
finalizedBy('collectArtifacts')
}