-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.gradle
More file actions
98 lines (80 loc) · 2.44 KB
/
build.gradle
File metadata and controls
98 lines (80 loc) · 2.44 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
plugins {
id 'java'
id 'com.gradleup.shadow' version '9.0.0-beta12'
}
group = 'com.pyjavabridge'
def resolveVersionFromGit = {
def versionPattern = ~/^(\d+[A-Z])\s*-\s*.*$/
def result = providers.exec {
commandLine 'git', 'log', '-1', '--pretty=%s'
ignoreExitValue = true
}
def lastSubject = result.standardOutput.asText.get().trim()
if (lastSubject ==~ versionPattern) {
def matcher = (lastSubject =~ versionPattern)
return matcher[0][1]
}
return 'dev'
}
version = resolveVersionFromGit()
def paperVersion = '1.21.4-R0.1-SNAPSHOT'
dependencies {
compileOnly "io.papermc.paper:paper-api:${paperVersion}"
compileOnly 'com.comphenix.protocol:ProtocolLib:5.3.0'
implementation 'org.msgpack:msgpack-core:0.9.8'
}
repositories {
mavenCentral()
maven { url = 'https://repo.papermc.io/repository/maven-public/' }
maven { url = 'https://repo.dmulloy2.net/repository/public/' }
}
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}
tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
options.release = 21
options.compilerArgs += ['-Xlint:deprecation']
}
tasks.named('processResources') {
filesMatching('plugin.yml') {
expand(version: project.version)
}
}
tasks.named('jar') {
archiveFileName = "${project.name}-${project.version}.jar"
}
shadowJar {
archiveClassifier.set('')
archiveFileName = "${project.name}-${project.version}.jar"
relocate 'org.msgpack', 'com.pyjavabridge.libs.msgpack'
}
tasks.register('copyPluginJar', Copy) {
dependsOn tasks.named('shadowJar')
from tasks.named('shadowJar').flatMap { it.archiveFile }
def pluginsDir = layout.projectDirectory.dir("server/plugins")
into pluginsDir
doFirst {
pluginsDir.asFile.mkdirs()
delete(fileTree(pluginsDir) {
include "pyjavabridge-*.jar"
})
}
}
tasks.register('copyReleaseJar', Copy) {
dependsOn tasks.named('shadowJar')
from tasks.named('shadowJar').flatMap { it.archiveFile }
into "${rootDir}/releases"
doFirst {
file("${rootDir}/releases").mkdirs()
}
}
tasks.register('copyBridgePython', Copy) {
from "${rootDir}/src/main/resources/python/bridge"
into "${rootDir}/server/plugins/PyJavaBridge/scripts/bridge"
}
tasks.named('build') {
finalizedBy tasks.named('copyPluginJar'), tasks.named('copyReleaseJar'), tasks.named('copyBridgePython')
}