generated from CrimsonWarpedcraft/plugin-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.gradle
176 lines (148 loc) · 4.24 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
import java.text.SimpleDateFormat
plugins {
id 'checkstyle'
id "com.github.spotbugs" version "5.0.9"
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'java'
id 'maven-publish'
}
group = "com.crimsonwarpedcraft.cwcommons"
static def getTime() {
SimpleDateFormat sdf = new SimpleDateFormat("yyMMdd-HHmm")
sdf.setTimeZone(TimeZone.getTimeZone("UTC"))
return sdf.format(new Date()).toString()
}
// Load version from string
String shortVersion = null
if (hasProperty('ver')) {
if (ver.charAt(0) == "v") {
shortVersion = ver.substring(1)
} else {
shortVersion = ver
}
}
if (shortVersion == null || shortVersion == "") {
shortVersion = getTime()
}
// Add snapshot identifier to version
version = shortVersion + "-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
repositories {
maven {
name 'sps'
url 'https://mvn.snowypeaksystems.com/repository/maven-public/'
}
mavenCentral()
maven {
name 'papermc'
url 'https://repo.papermc.io/repository/maven-public/'
content {
includeGroup 'io.papermc'
includeGroup 'io.papermc.paper'
includeGroup 'net.md-5'
}
}
}
dependencies {
compileOnly 'dev.jorel:commandapi-annotations:8.4.1'
compileOnly 'dev.jorel:commandapi-shade:8.4.1'
compileOnly 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
compileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.1'
implementation 'com.google.code.gson:gson:2.9.1'
implementation 'io.papermc:paperlib:1.0.7'
spotbugsPlugins 'com.h3xstream.findsecbugs:findsecbugs-plugin:1.12.0'
testCompileOnly 'com.github.spotbugs:spotbugs-annotations:4.7.1'
testImplementation 'io.papermc.paper:paper-api:1.18.1-R0.1-SNAPSHOT'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.2'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.2'
}
test {
useJUnitPlatform()
}
processResources {
filesMatching("**/plugin.yml") {
expand ( NAME: rootProject.name, VERSION: version, PACKAGE: project.group.toString() )
}
}
checkstyle {
toolVersion '10.3.1'
maxWarnings = 0
}
tasks.withType(Checkstyle) {
reports {
xml.required = false
html.required = true
}
}
spotbugsMain {
reports {
xml.required = false
html.required = true
}
}
spotbugsTest {
reports {
xml.required = false
html.required = true
}
}
shadowJar {
archiveClassifier.set('')
dependencies {
include dependency('dev.jorel:commandapi-shade:8.4.1')
}
relocate 'dev.jorel.commandapi', 'com.crimsonwarpedcraft.cwcommons.shadow.dev.jorel'
relocate 'io.papermc.lib', 'com.crimsonwarpedcraft.cwcommons.shadow.io.papermc.lib'
minimize()
}
publishing {
repositories {
maven {
name = "sps"
url = uri("https://mvn.snowypeaksystems.com/repository/maven-snapshots/")
credentials {
username = System.getenv("SPS_MVN_USER")
password = System.getenv("SPS_MVN_PASS")
}
}
}
publications {
spsmvn(MavenPublication) {
artifact shadowJar.archiveFile
}
}
}
// Disable jar and replace with shadowJar
jar.enabled = false
assemble.dependsOn(shadowJar)
// We need to build before we publish
publish.dependsOn(build)
task configureRelease {
doLast {
// Trim the "-SNAPSHOT" extension from version
version = shortVersion
// Change the publishing repository to release server
publishing.repositories.getByName(
"sps",
{
url = uri("https://mvn.snowypeaksystems.com/repository/maven-releases/")
}
)
}
}
// Make sure configuration runs in the correct order
build.mustRunAfter(configureRelease)
task release {
dependsOn build
dependsOn publish
dependsOn configureRelease
doLast {
// Rename final JAR to trim off version information
shadowJar.archiveFile.get().getAsFile()
.renameTo(buildDir.toString() + File.separator + 'libs' + File.separator
+ rootProject.name + '.jar')
}
}