generated from CrimsonWarpedcraft/plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuild.gradle
134 lines (114 loc) · 3.73 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
import java.text.SimpleDateFormat
plugins {
id 'io.github.goooler.shadow' version "8.1.8"
id 'java'
id 'antlr'
id 'maven-publish'
}
group = "com.jacoobes"
String ver = 'RC-1.2'
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()
}
String Uri = ""
if (version.endsWith("-SNAPSHOT")) {
Uri = "snapshots"
} else Uri = "releases"
publishing {
publications {
create("mavenJava", MavenPublication) {
artifact(shadowJar.archiveFile) {
classifier = ""
}
groupId = group.toString()
artifactId = project.name
version = version.toString()
}
}
repositories(repositories -> {
repositories.maven(repo -> {
repo.setUrl(uri(findProperty("uri") != null ? findProperty("uri").toString()+Uri : System.getenv("URI")+Uri))
repo.credentials(passwordCredentials -> {
passwordCredentials.setUsername(findProperty("mavenUser") != null ? findProperty("mavenUser").toString() : System.getenv("MAVEN_USER"))
passwordCredentials.setPassword(findProperty("mavenPassword") != null ? findProperty("mavenPassword").toString() : System.getenv("MAVEN_PASSWORD"))
})
})
})
}
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 + "-" + version + '.jar')
}
}
}