-
Notifications
You must be signed in to change notification settings - Fork 13
/
build.gradle
108 lines (90 loc) · 2.9 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
plugins {
id("java")
id("checkstyle")
id("com.github.spotbugs").version("5.0.14")
id("org.cadixdev.licenser").version("0.6.1")
id("com.github.johnrengelman.shadow").version("7.1.2")
}
setGroup("net.elytrium")
setVersion("1.1.7")
compileJava {
getOptions().setEncoding("UTF-8")
}
java {
setSourceCompatibility(JavaVersion.VERSION_17)
setTargetCompatibility(JavaVersion.VERSION_17)
}
repositories {
mavenCentral()
maven {
setName("elytrium-repo")
setUrl("https://maven.elytrium.net/repo/")
}
maven {
setName("papermc-repo")
setUrl("https://papermc.io/repo/repository/maven-public/")
}
maven() {
setName("sonatype-snapshots-repo")
setUrl("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}
dependencies {
compileOnly("net.elytrium.limboapi:api:$limboapiVersion")
compileOnly("com.velocitypowered:velocity-api:$velocityVersion")
annotationProcessor("com.velocitypowered:velocity-api:$velocityVersion")
compileOnly("com.velocitypowered:velocity-proxy:$velocityVersion")
compileOnly("io.netty:netty-handler:$nettyVersion")
implementation("net.elytrium:serializer:$serializerVersion")
}
shadowJar {
getArchiveClassifier().set("")
relocate("net.elytrium.commons.velocity", "net.elytrium.limboapi.thirdparty.commons.velocity")
relocate("net.elytrium.commons.kyori", "net.elytrium.limboapi.thirdparty.commons.kyori")
}
license {
setHeader(file("HEADER.txt"))
}
checkstyle {
setToolVersion("10.1")
setConfigFile(file("${this.getRootDir()}/config/checkstyle/checkstyle.xml"))
setConfigProperties("configDirectory": "${this.getRootDir()}/config/checkstyle")
// The build should immediately fail if we have errors.
setMaxErrors(0)
setMaxWarnings(0)
}
spotbugsMain {
setExcludeFilter(file("${this.getRootDir()}/config/spotbugs/suppressions.xml"))
reports {
html {
getRequired().set(true)
getOutputLocation().set(file("${this.getBuildDir()}/reports/spotbugs/main/spotbugs.html"))
setStylesheet("fancy-hist.xsl")
}
}
}
sourceSets.main.getJava().srcDir(
getTasks().register("generateTemplates", Copy) {
task -> {
String version = getVersion().contains("-") ? "${getVersion()} (git-${getCurrentShortRevision()})" : getVersion()
task.getInputs().properties("version": version)
task.from(file("src/main/templates")).into(getLayout().getBuildDirectory().dir("generated/sources/templates"))
task.expand("version": version)
}
}.map {
it.getOutputs()
}
)
assemble.dependsOn(shadowJar)
String getCurrentShortRevision() {
OutputStream outputStream = new ByteArrayOutputStream()
exec {
if (System.getProperty("os.name").toLowerCase().contains("win")) {
commandLine("cmd", "/c", "git rev-parse --short HEAD")
} else {
commandLine("bash", "-c", "git rev-parse --short HEAD")
}
setStandardOutput(outputStream)
}
return outputStream.toString().trim()
}