generated from CrimsonWarpedcraft/plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.gradle
108 lines (87 loc) · 2.71 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
import java.text.SimpleDateFormat
plugins {
id 'io.github.goooler.shadow' version "8.1.8"
id 'java'
id 'antlr'
}
group = "com.jacoobes.scratchpaper"
static def getTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmm")
sdf.setTimeZone(TimeZone.getTimeZone("UTC"))
return sdf.format(new Date()).toString()
}
// Set version to version property if supplied
String shortVersion = null
if (hasProperty('ver')) {
if (ver.charAt(0) == "v") {
shortVersion = ver.substring(1).toUpperCase()
} else {
shortVersion = ver.toUpperCase()
}
}
// If the tag includes "-RC-" or no tag is supplied, append "-SNAPSHOT"
int rcIdx
if (shortVersion == null || shortVersion == "") {
version = getTime() + "-SNAPSHOT"
} else if ((rcIdx = shortVersion.indexOf("-RC-")) != -1) {
version = shortVersion.substring(0, rcIdx) + "-SNAPSHOT"
} else {
version = shortVersion
}
java {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}
repositories {
maven {
name 'papermc'
url 'https://repo.papermc.io/repository/maven-public/'
}
mavenCentral()
}
dependencies {
compileOnly 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.8.3'
implementation 'io.papermc:paperlib:1.0.8'
antlr "org.antlr:antlr4:4.13.1" // use ANTLR version 4
testImplementation 'io.papermc.paper:paper-api:1.21-R0.1-SNAPSHOT'
testImplementation 'org.junit.jupiter:junit-jupiter:5.10.2'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher:1.10.2'
}
test {
useJUnitPlatform()
}
processResources {
filesMatching("**/plugin.yml") {
expand ( NAME: rootProject.name, VERSION: version, PACKAGE: project.group.toString() )
}
}
def generatedSrcDir = "src/main/java/com/jacoobes/scratchpaper"
generateGrammarSource {
arguments += ["-visitor", "-no-listener", "-package", "com.jacoobes.scratchpaper"]
outputDirectory = file(generatedSrcDir)
}
shadowJar {
archiveClassifier.set('')
relocate 'io.papermc.lib', 'shadow.io.papermc.paperlib'
minimize()
}
// Disable jar and replace with shadowJar
jar.enabled = false
assemble.dependsOn(shadowJar)
tasks.register('printProjectName') {
doLast {
println rootProject.name
}
}
tasks.register('release') {
dependsOn build
doLast {
if (!version.endsWith("-SNAPSHOT")) {
// Rename final JAR to trim off version information
shadowJar.archiveFile.get().getAsFile()
.renameTo(layout.buildDirectory.get().toString() + File.separator + 'libs' + File.separator
+ rootProject.name + '.jar')
}
}
}