Skip to content

Commit 704c6e3

Browse files
committed
add version catalogs inside gradle and replace with gradle-kts
1 parent 83bc60e commit 704c6e3

8 files changed

Lines changed: 212 additions & 176 deletions

File tree

api/build.gradle

Lines changed: 0 additions & 89 deletions
This file was deleted.

api/build.gradle.kts

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
@file:Suppress("GroovyAssignabilityCheck")
2+
3+
import net.minecraftforge.licenser.LicenseExtension
4+
import net.minecraftforge.licenser.LicenseProperties
5+
import org.gradle.kotlin.dsl.closureOf
6+
7+
plugins {
8+
`java-library`
9+
`maven-publish`
10+
}
11+
12+
tasks.withType<JavaCompile> {
13+
options.release.set(21)
14+
options.encoding = "UTF-8"
15+
}
16+
17+
dependencies {
18+
compileOnly(libs.minecraft.velocity.api)
19+
api(libs.elytrium.commons.config)
20+
api(libs.elytrium.commons.utils)
21+
api(libs.elytrium.commons.velocity)
22+
api(libs.elytrium.commons.kyori)
23+
api(libs.minecraft.adventure.nbt)
24+
25+
compileOnly(libs.tool.spotbugs.annotations)
26+
}
27+
28+
extensions.configure<LicenseExtension> {
29+
matching(
30+
"**/mcprotocollib/**",
31+
closureOf<LicenseProperties> {
32+
setHeader(rootProject.file("HEADER_MCPROTOCOLLIB.txt"))
33+
}
34+
)
35+
setHeader(file("HEADER.txt"))
36+
}
37+
38+
tasks.named<Javadoc>("javadoc") {
39+
options.encoding = "UTF-8"
40+
(options as StandardJavadocDocletOptions).apply {
41+
source = "21"
42+
links("https://docs.oracle.com/en/java/javase/11/docs/api/")
43+
addStringOption("Xdoclint:none", "-quiet")
44+
if (JavaVersion.current() >= JavaVersion.VERSION_1_9 && JavaVersion.current() < JavaVersion.VERSION_12) {
45+
addBooleanOption("-no-module-directories", true)
46+
}
47+
}
48+
}
49+
50+
val sourcesJar by tasks.registering(Jar::class) {
51+
archiveClassifier.set("sources")
52+
from(sourceSets.main.get().allSource)
53+
}
54+
55+
val javadocJar by tasks.registering(Jar::class) {
56+
archiveClassifier.set("javadoc")
57+
from(tasks.javadoc)
58+
}
59+
60+
publishing {
61+
repositories {
62+
maven {
63+
credentials {
64+
username = System.getenv("ELYTRIUM_MAVEN_USERNAME")
65+
password = System.getenv("ELYTRIUM_MAVEN_PASSWORD")
66+
}
67+
name = "elytrium-repo"
68+
url = uri("https://maven.elytrium.net/repo/")
69+
}
70+
}
71+
72+
publications.create<MavenPublication>("publication") {
73+
from(components["java"])
74+
75+
artifact(javadocJar)
76+
artifact(sourcesJar)
77+
}
78+
}
79+
80+
artifacts {
81+
archives(javadocJar)
82+
archives(sourcesJar)
83+
}
84+
85+
@Suppress("UNCHECKED_CAST")
86+
val getCurrentShortRevision = rootProject.extra["getCurrentShortRevision"] as () -> String
87+
88+
89+
val versionStringProvider = provider {
90+
if (version.toString().contains("-")) {
91+
"${version} (git-${getCurrentShortRevision()})"
92+
} else {
93+
version.toString()
94+
}
95+
}
96+
97+
val copyTask by tasks.register<Copy>("generateTemplates") {
98+
val versionString = versionStringProvider.get()
99+
inputs.property("version", versionString)
100+
from(file("src/main/templates"))
101+
into(layout.buildDirectory.dir("generated/sources/templates"))
102+
expand("version" to versionString)
103+
}
104+
105+
sourceSets.main.configure {
106+
java.srcDir(copyTask.outputs)
107+
}

build.gradle

Lines changed: 0 additions & 62 deletions
This file was deleted.

build.gradle.kts

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
import com.github.spotbugs.snom.SpotBugsExtension
2+
import com.github.spotbugs.snom.SpotBugsTask
3+
4+
plugins {
5+
java
6+
checkstyle
7+
alias(libs.plugins.gradle.spotbugs) apply false
8+
alias(libs.plugins.gradle.licenser) apply false
9+
}
10+
11+
allprojects {
12+
apply(plugin = "checkstyle")
13+
apply(plugin = "com.github.spotbugs")
14+
apply(plugin = "net.minecraftforge.licenser")
15+
16+
group = "net.elytrium.limboapi"
17+
version = "1.1.27-SNAPSHOT"
18+
19+
tasks.withType<JavaCompile> {
20+
sourceCompatibility = JavaVersion.VERSION_21.toString()
21+
targetCompatibility = JavaVersion.VERSION_21.toString()
22+
}
23+
24+
repositories {
25+
mavenCentral()
26+
maven {
27+
name = "elytrium-repo"
28+
url = uri("https://maven.elytrium.net/repo/")
29+
}
30+
maven {
31+
name = "papermc-repo"
32+
url = uri("https://repo.papermc.io/repository/maven-public/")
33+
}
34+
}
35+
36+
checkstyle {
37+
toolVersion = "10.12.1"
38+
configFile = file("$rootDir/config/checkstyle/checkstyle.xml")
39+
configProperties = mapOf("configDirectory" to "$rootDir/config/checkstyle")
40+
maxErrors = 0
41+
maxWarnings = 0
42+
}
43+
44+
extensions.configure<SpotBugsExtension> {
45+
excludeFilter.set(file("${rootDir}/config/spotbugs/suppressions.xml"))
46+
}
47+
48+
tasks.withType<SpotBugsTask> {
49+
if (project == rootProject) return@withType
50+
reports.register("html") {
51+
required.set(true)
52+
outputLocation.set(layout.buildDirectory.file("reports/spotbugs/main/spotbugs.html"))
53+
setStylesheet("fancy-hist.xsl")
54+
}
55+
}
56+
}
57+
58+
fun getCurrentShortRevision(): String {
59+
val isWindows = System.getProperty("os.name")
60+
.lowercase()
61+
.contains("win")
62+
63+
val process = if (isWindows) {
64+
ProcessBuilder("cmd", "/c", "git rev-parse --short HEAD")
65+
} else {
66+
ProcessBuilder("bash", "-c", "git rev-parse --short HEAD")
67+
}
68+
return process
69+
.start()
70+
.inputStream
71+
.bufferedReader()
72+
.readText()
73+
.trim()
74+
}
75+
76+
// Make the function available to subprojects via extra properties
77+
extra["getCurrentShortRevision"] = ::getCurrentShortRevision

gradle/libs.versions.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[versions]
22
elytrium-commons = "1.2.3" # https://github.com/Elytrium/elytrium-java-commons
33
elytrium-fastprepare = "1.0.13" #https://github.com/Elytrium/FastPrepareAPI
4-
gradle-licenser = "0.6.1" # https://github.com/CadixDev/licenser
5-
gradle-shadow = "8.3.6" # https://github.com/GradleUp/shadow
6-
gradle-spotbugs = "6.0.12" # https://github.com/spotbugs/spotbugs-gradle-plugin
4+
gradle-licenser = "1.2.0" # https://github.com/CadixDev/licenser
5+
gradle-shadow = "9.4.0" # https://github.com/GradleUp/shadow
6+
gradle-spotbugs = "6.4.8" # https://github.com/spotbugs/spotbugs-gradle-plugin
77
minecraft-adventure = "4.15.0" # https://github.com/KyoriPowered/adventure
88
minecraft-bstats = "3.0.0" # https://github.com/Bastian/bStats
9-
minecraft-velocity = "3.4.0-SNAPSHOT" # https://github.com/PaperMC/Velocity
9+
minecraft-velocity = "3.5.0-SNAPSHOT" # https://github.com/PaperMC/Velocity
1010
tool-commons-io = "2.6" # https://github.com/apache/commons-io
1111
tool-fastutil = "8.5.11" # https://github.com/vigna/fastutil/
1212
tool-google-guava = "28.0-jre" # https://github.com/google/guava
@@ -32,6 +32,6 @@ tool-netty-handler = { module = "io.netty:netty-handler", version.ref = "tool-ne
3232
tool-spotbugs-annotations = { module = "com.github.spotbugs:spotbugs-annotations", version.ref = "tool-spotbugs-annotations" }
3333

3434
[plugins]
35-
gradle-licenser = { id = "org.cadixdev.licenser", version.ref = "gradle-licenser" }
35+
gradle-licenser = { id = "net.minecraftforge.licenser", version.ref = "gradle-licenser" }
3636
gradle-shadow = { id = "com.gradleup.shadow", version.ref = "gradle-shadow" }
3737
gradle-spotbugs = { id = "com.github.spotbugs", version.ref = "gradle-spotbugs" }

0 commit comments

Comments
 (0)