-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbuild.gradle
More file actions
220 lines (183 loc) · 6.34 KB
/
build.gradle
File metadata and controls
220 lines (183 loc) · 6.34 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
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
plugins {
id 'java'
id 'maven-publish'
id 'jacoco'
id "io.freefair.lombok" version "5.3.0"
id "com.github.hierynomus.license" version "0.15.0"
// Nemerosa Versioning Plugin for the build info
id "net.nemerosa.versioning" version "2.14.0"
}
jacoco {
// Use JaCoCo 0.8.6 for (experimental) support for Java 15 class files.
toolVersion = "0.8.6"
}
group = 'com.dumbdogdiner'
version = '2.3.0'
// License Plugin Options
license {
header = project.file('LICENSE_HEADER')
ext.year = Calendar.getInstance().get(Calendar.YEAR)
mapping("java", "SLASHSTAR_STYLE")
exclude("**/*.json")
}
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" << "-XDignore.symbol.file"
options.encoding = "UTF-8"
}
// Run the license formatter before compiling the source code.
tasks.compileJava.dependsOn licenseFormatMain, licenseFormatTest
configurations {
jaxDoclet
// give test dependencies access to compileOnly dependencies to emulate providedCompile
testImplementation.extendsFrom compileOnly
}
repositories {
mavenCentral()
jcenter()
google()
maven { url 'https://oss.sonatype.org/content/repositories/snapshots' }
maven { url 'https://papermc.io/repo/repository/maven-public/' }
}
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
compileOnly 'com.destroystokyo.paper:paper-api:1.16.5-R0.1-SNAPSHOT'
compileOnly 'net.md-5:bungeecord-api:1.16-R0.5-SNAPSHOT'
implementation 'org.jetbrains:annotations:20.1.0'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'io.github.classgraph:classgraph:4.8.100'
implementation 'com.github.seancfoley:ipaddress:5.3.3'
implementation 'com.squareup.okhttp3:okhttp:4.9.0'
implementation 'commons-validator:commons-validator:1.7'
implementation 'com.google.guava:guava:30.1-jre'
// Tests - JUnit 5
testImplementation("org.junit.jupiter:junit-jupiter-api:5.7.0")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.7.0")
// Tests - Mocking Suite (eg. mocking Bukkit for tests)
testImplementation("org.mockito:mockito-core:3.7.7")
// Tests - Mocked Bukkit Project (Has some additional features)
testImplementation 'com.github.seeseemelk:MockBukkit-v1.16:0.5.0'
testImplementation 'it.unimi.dsi:fastutil:8.4.4'
}
task downloadTextures(type: Download) {
sourceUrl = 'https://dumbdogdiner.github.io/mc-heads-resource/textures.json'
target = new File('src/main/resources/generated/textures.json')
}
task cleanGenerated(type: Delete){
delete('src/main/resources/generated')
}
test {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed"
// Show System.out for code ran by tests
showStandardStreams = true
}
//ignoreFailures = true
finalizedBy jacocoTestReport // report is always generated after tests run
}
jacocoTestReport {
dependsOn test // tests are required to run before generating the report
reports {
xml.enabled true
html.enabled true
}
}
task sources(type: Jar, dependsOn: classes) {
archiveClassifier.set("sources")
from sourceSets.main.allSource
}
tasks.delombok.shouldRunAfter(sources)
tasks.publish.dependsOn build
tasks.build.shouldRunAfter(clean)
tasks.javadoc.shouldRunAfter(clean)
tasks.build.finalizedBy(sources)
tasks.clean.dependsOn(cleanGenerated)
tasks.processResources.dependsOn(downloadTextures)
// Javadoc Fixes
// Some environments (such as the builder image) do not use UTF-8 as the default encoding!
delombok {
finalizedBy(javadoc)
print(true)
encoding = "UTF-8"
//verbose(true)
}
// Build Info
// Set the timestamp format
def dataBuildTimestamp = "yyyy-MM-dd'T'HH:mm:ss.SSSZ"
// Import the filter
import org.apache.tools.ant.filters.ReplaceTokens
// Define the map containing the tokens we want to replace
def tokensMap = [
BUILDINFO_VERSION: project.version,
BUILDINFO_DATEFORMAT: dataBuildTimestamp,
BUILDINFO_TIMESTAMP: new java.text.SimpleDateFormat(dataBuildTimestamp).format(new Date()),
BUILDINFO_COMMIT: versioning.info.commit,
BUILDINFO_BRANCH: versioning.info.branch,
BUILDINFO_ISDIRTY: versioning.info.dirty.toString()
]
// Create task to replace the tokens with their actual values
// NOTE: At the moment this replaces tokens *globally* (format eg. @BUILDINFO_COMMIT@ in source code)
task processSourceTokens(type: Sync) {
from sourceSets.main.java
into 'build/processed/src/main/java'
filter(ReplaceTokens, tokens: tokensMap)
// Pretty print the build info
println("\n----- StickyAPI Build Info -----\n")
tokensMap.each { println "${String.format("%1\$-" + 10 + "s", it.key.replace("BUILDINFO_", "").toLowerCase())}\t${it.value}" }
}
// Use the filter task as the input for compileJava
compileJava.source = processSourceTokens.outputs
tasks.publish.dependsOn build, sources
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
tasks.withType(Test) {
systemProperty "file.encoding", "UTF-8"
}
javadoc {
options.addBooleanOption('XDignore.symbol.file', true)
options.addBooleanOption('-frames', true)
options.addBooleanOption('private', true)
test.ignoreFailures true;
options.encoding = 'UTF-8'
dependsOn delombok
}
task browseJavadoc {
dependsOn javadoc
doLast {
java.awt.Desktop.desktop.browse new URI(("file:///" << System.getProperty("user.dir").replace('\\','/') << "/build/docs/javadoc/index.html").toString())
}
}
task rebuild {
dependsOn clean
finalizedBy build
}
publishing {
repositories {
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/DumbDogDiner/StickyAPI")
credentials {
username = project.findProperty("gpr.user") ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("gpr.key") ?: System.getenv("GITHUB_TOKEN")
}
}
}
publications {
gpr(MavenPublication) {
from(components.java)
artifact sources // Publish the output of the sources task
}
}
}
class Download extends DefaultTask {
@Input
String sourceUrl
@OutputFile
File target
@TaskAction
void download() {
ant.get(src: sourceUrl, dest: target)
}
}