forked from ProtocolSupport/ProtocolSupport
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.gradle
236 lines (187 loc) · 7.29 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
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '7.1.0'
id 'io.github.shevchik.ManualGradleDependencySupplier' version '3.1'
id 'maven-publish'
}
gradle.startParameter.showStacktrace = org.gradle.api.logging.configuration.ShowStacktrace.ALWAYS
defaultTasks 'build'
group 'protocolsupport'
version '1.18.2-1-dev'
import java.nio.file.Path
import java.nio.file.Paths
import java.nio.file.Files
import java.nio.file.StandardCopyOption;
import io.github.shevchik.manualgradledependencysupplier.ManualGradleDependencySupplier
import io.github.shevchik.manualgradledependencysupplier.DependencySupplier
import io.github.shevchik.manualgradledependencysupplier.BuildDependencySupplier
import io.github.shevchik.manualgradledependencysupplier.UnpackZipFileDependencySupplier
import io.github.shevchik.manualgradledependencysupplier.FilterZipFileDependencySupplier
Path projectDirectoryPath = projectDir.toPath().toAbsolutePath()
Path projectBuildDirectoryPath = getBuildDir().toPath()
Path generatedResourcesDirectoryPath = projectBuildDirectoryPath.resolve('gen')
Path generatedResourcesResourcesDirectoryPath = generatedResourcesDirectoryPath.resolve('resources')
task setupFolders(type: DefaultTask) {doLast{
Files.createDirectories(generatedResourcesDirectoryPath)
Files.createDirectories(generatedResourcesResourcesDirectoryPath)
}}
sourceCompatibility = JavaVersion.VERSION_17
sourceSets {
main {
java {
srcDirs = ['src']
}
resources {
srcDirs = ['resources']
}
}
test {
java {
srcDirs = ['tests']
}
}
}
repositories {
mavenCentral()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
maven {
url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/'
}
maven {
url 'https://papermc.io/repo/repository/maven-public/'
}
maven {
url 'https://libraries.minecraft.net/'
}
maven {
url 'https://jitpack.io'
}
}
configurations {
spigotLibraries
compileOnly {
extendsFrom spigotLibraries
}
testImplementation {
extendsFrom spigotLibraries
}
}
dependencies {
Path spigotBuildDirectoryPath = projectBuildDirectoryPath.resolve('spigot')
DependencySupplier spigotDependencySupplier = new UnpackZipFileDependencySupplier(
new BuildDependencySupplier(
new URL('https://hub.spigotmc.org/jenkins/job/BuildTools/146/artifact/target/BuildTools.jar'),
spigotBuildDirectoryPath,
'BuildTools.jar',
['java', '-jar', 'BuildTools.jar', '--rev', '1.18.2'],
['spigot-1.18.2.jar']
).setBuildEnv([
'MAVEN_OPTS': '-Dmaven.repo.local=' + spigotBuildDirectoryPath.resolve('m2').toString() + ' -Xmx1024M'
]),
'META-INF/versions/spigot-1.18.2-R0.1-SNAPSHOT.jar',
spigotBuildDirectoryPath,
'spigot-1.18.2-real.jar'
)
compileOnly group: 'com.github.ProtocolSupport', name: 'ProtocolSupportBuildProcessor', version: '907b3e20db'
compileOnly group: 'io.papermc.paper', name: 'paper-api', version: '1.18.2-R0.1-SNAPSHOT'
compileOnly ManualGradleDependencySupplier.supplyDependecies([
new FilterZipFileDependencySupplier(
spigotDependencySupplier,
['/net/minecraft', '/com/mojang', '/org/bukkit/craftbukkit', '/org/spigotmc'], true,
spigotBuildDirectoryPath,
'spigot-1.18.2-real-filtered-compile.jar'
)
])
compileOnly group: 'io.netty', name: 'netty-all', version: '4.1.70.Final'
compileOnly group: 'com.mojang', name: 'authlib', version: '3.2.38'
compileOnly group: 'com.mojang', name: 'brigadier', version: '1.0.18'
implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.11'
implementation group: 'com.google.code.findbugs', name: 'jsr305', version: '3.0.2'
annotationProcessor group: 'com.github.ProtocolSupport', name: 'ProtocolSupportBuildProcessor', version: '907b3e20db'
testImplementation group: 'org.spigotmc', name: 'spigot-api', version: '1.18.2-R0.1-SNAPSHOT'
testImplementation ManualGradleDependencySupplier.supplyDependecies([
spigotDependencySupplier
])
testImplementation group: 'it.unimi.dsi', name: 'fastutil', version: '8.5.6'
testImplementation group: 'io.netty', name: 'netty-all', version: '4.1.70.Final'
testImplementation group: 'com.mojang', name: 'authlib', version: '3.3.39'
testImplementation group: 'com.mojang', name: 'brigadier', version: '1.0.18'
testImplementation group: 'com.mojang', name: 'datafixerupper', version: '4.1.27'
testImplementation group: 'com.mojang', name: 'javabridge', version: '1.2.24'
testImplementation group: 'com.mojang', name: 'logging', version: '1.0.0'
testImplementation group: 'org.apache.logging.log4j', name: 'log4j', version: '2.17.0', ext: 'pom'
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.17.0'
testImplementation group: 'org.apache.logging.log4j', name: 'log4j-iostreams', version: '2.17.0'
testImplementation group: 'net.sf.jopt-simple', name: 'jopt-simple', version: '5.0.4'
testImplementation group: 'jline', name: 'jline', version: '2.12.1'
testImplementation group: 'com.github.oshi', name: 'oshi-core', version: '5.8.5'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.2.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.2.0'
}
compileJava {
options.encoding = 'UTF-8'
options.incremental = false
options.compilerArgs << ('-Aprotocolsupportbuildprocessor.generatedresourcesdirectory=' + generatedResourcesResourcesDirectoryPath.resolve('preload').toString())
}
test {
Path workingDirectoryPath = projectDirectoryPath.resolve('testsRun');
doFirst {
Files.createDirectories(workingDirectoryPath)
}
useJUnitPlatform()
workingDir = workingDirectoryPath;
maxHeapSize = '3G'
testLogging.showStandardStreams = true
testLogging.exceptionFormat = 'full'
}
processResources {
doFirst {
Properties properties = new Properties()
properties.setProperty('buildtime', new Date().format('yyyy.MM.dd \'at\' HH:mm:ss z'))
properties.setProperty('buildhost', System.getProperty('protocolsupport.buildhost', 'unknown'))
properties.setProperty('buildnumber', System.getProperty('protocolsupport.buildnumber', 'unknown'))
properties.setProperty('buildgit', System.getProperty('protocolsupport.buildgit', 'unknown'))
Files.newBufferedWriter(generatedResourcesResourcesDirectoryPath.resolve('buildinfo')).withCloseable({ properties.store(it, 'Build info') })
}
from generatedResourcesDirectoryPath
filesMatching('plugin.yml') {
expand 'version': project.version
}
}
shadowJar {
duplicatesStrategy = DuplicatesStrategy.INCLUDE
archiveClassifier = ''
from sourceSets.main.java.srcDirs
from 'LICENSE'
exclude 'META-INF/**'
exclude 'module-info.class'
String relocatePrefix = 'protocolsupport.libs.'
relocate 'org.apache', relocatePrefix + 'org.apache'
relocate 'javax.annotation', relocatePrefix + 'javax.annotation'
}
task copyFinalJarToTarget(type: DefaultTask) {doLast{
Path targetJarDirectory = projectDirectoryPath.resolve('target')
Files.createDirectories(targetJarDirectory)
Files.copy(
shadowJar.archiveFile.get().getAsFile().toPath().toAbsolutePath(),
targetJarDirectory.resolve(shadowJar.archiveBaseName.get() + '.jar'),
StandardCopyOption.REPLACE_EXISTING
)
}}
compileJava.dependsOn(setupFolders)
jar.enabled = false
jar.finalizedBy(shadowJar)
shadowJar.finalizedBy(copyFinalJarToTarget)
tasks.withType(GenerateModuleMetadata) {
enabled = false
}
publishing {
publications {
release(MavenPublication) {
from components.java
artifacts = [shadowJar]
}
}
}