-
Notifications
You must be signed in to change notification settings - Fork 548
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert to Gradle Kotlin DSL #4175
base: master
Are you sure you want to change the base?
Changes from all commits
8baf55c
954ebd8
cd1b846
769e3a3
ccbc341
6e57c35
6f66070
705320b
3f5c4b1
7fe7a9c
a1fd6ca
498de0f
5fa3807
2e13858
f47af06
0066f4e
63a12fc
703e4a7
78413a7
15562b8
5729684
729d2c3
dbbd032
419d340
b4e7969
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,166 @@ | ||
import org.gradle.jvm.tasks.Jar | ||
|
||
plugins { | ||
`java-library` | ||
`maven-publish` | ||
jacoco | ||
id("com.github.johnrengelman.shadow") version "8.1.1" | ||
id("org.sonarqube") version "5.0.0.4638" | ||
id("xyz.jpenilla.run-paper") version "2.2.3" | ||
} | ||
|
||
// Needed for SonarScanner to work properly. 5.x requires java 17 | ||
|
||
val targetJavaVersion: Int = property("java.version").toString().toInt() | ||
val encoding: String = property("project.encoding").toString() | ||
val minecraftVersion: String = property("minecraft.version").toString() | ||
|
||
repositories { | ||
mavenCentral() | ||
maven("https://hub.spigotmc.org/nexus/content/repositories/snapshots") | ||
maven("https://repo.papermc.io/repository/maven-public/") | ||
maven("https://jitpack.io") | ||
maven("https://maven.enginehub.org/repo/") | ||
maven("https://repo.extendedclip.com/content/repositories/placeholderapi") | ||
maven("https://nexus.neetgames.com/repository/maven-public") | ||
maven("https://repo.walshy.dev/public") | ||
maven("https://repo.codemc.io/repository/maven-public/") | ||
maven("https://libraries.minecraft.net") | ||
} | ||
|
||
dependencies { | ||
// Api is similar to "implementation" but that these deps are also exposed transitively | ||
api("com.github.baked-libs.dough:dough-api:baf2d79f62") | ||
api("io.papermc:paperlib:1.0.8") | ||
api("commons-lang:commons-lang:2.6") | ||
|
||
compileOnly("org.spigotmc:spigot-api:$minecraftVersion-R0.1-SNAPSHOT") | ||
compileOnly("com.mojang:authlib:6.0.52") | ||
compileOnly("com.google.code.findbugs:jsr305:3.0.2") | ||
|
||
// Plugin dependencies | ||
compileOnly("com.sk89q.worldedit:worldedit-core:7.2.19") | ||
compileOnly("com.sk89q.worldedit:worldedit-bukkit:7.2.19") | ||
compileOnly("com.gmail.nossr50.mcMMO:mcMMO:2.1.230") | ||
compileOnly("me.clip:placeholderapi:2.11.5") | ||
compileOnly("me.minebuilders:clearlag-core:3.1.6") | ||
compileOnly("com.github.LoneDev6:itemsadder-api:3.6.1") | ||
compileOnly("net.imprex:orebfuscator-api:5.4.0") | ||
|
||
|
||
testRuntimeOnly("org.junit.platform:junit-platform-launcher") | ||
testImplementation("org.junit.jupiter:junit-jupiter:5.10.2") | ||
testImplementation("org.mockito:mockito-core:5.10.0") | ||
testImplementation("org.slf4j:slf4j-simple:2.0.9") | ||
testImplementation("com.github.seeseemelk:MockBukkit-v1.20:3.65.0") | ||
|
||
// Override MockBukkit's Paper to a pinned slightly older version | ||
// This is because MockBukkit currently fails after this PR: https://github.com/PaperMC/Paper/pull/9629 | ||
testImplementation("io.papermc.paper:paper-api:1.20.4-R0.1-20240205.114523-90") | ||
} | ||
|
||
group = "com.github.slimefun" | ||
version = property("project.version").toString() | ||
description = "Slimefun" | ||
|
||
|
||
java { | ||
toolchain.languageVersion.set(JavaLanguageVersion.of(targetJavaVersion)) | ||
withSourcesJar() | ||
} | ||
|
||
tasks { | ||
withType<JavaCompile>().configureEach { | ||
options.release = targetJavaVersion | ||
options.encoding = encoding | ||
|
||
// package info files are only important for Javadocs | ||
// We can safely exclude them from the final jar --> | ||
exclude("**/package-info.java") | ||
} | ||
withType<Javadoc>().configureEach { | ||
options.encoding = encoding | ||
} | ||
javadoc { | ||
setDestinationDir(file("javadocs")) | ||
options { | ||
title = "Slimefun4 - Javadocs" | ||
windowTitle = "Slimefun4 - Javadocs" | ||
// doclet = "org.gradle.external.javadoc.StandardJavadocDocletOptions" | ||
// FIXME offline links, groups, and additional options. | ||
} | ||
} | ||
assemble { | ||
dependsOn(shadowJar) | ||
} | ||
jar { | ||
archiveClassifier.set("original") | ||
archiveVersion.set("v${project.version}") | ||
} | ||
shadowJar { | ||
archiveClassifier.set("") | ||
archiveVersion.set("v${project.version}") | ||
|
||
// Relocations | ||
val destination = "io.github.thebusybiscuit.slimefun4.libraries" | ||
relocate("io.github.bakedlibs.dough", "$destination.dough") | ||
relocate("io.papermc.lib", "$destination.paperlib") | ||
relocate("org.apache.commons.lang", "$destination.commons.lang") | ||
// Merge the META-INF files | ||
mergeServiceFiles() | ||
} | ||
processResources { | ||
|
||
md5sha256 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
include("plugin.yml") | ||
include("config.yml") | ||
include("item-models.yml") | ||
include("wiki.json") | ||
include("languages/translators.json") | ||
include("tags/*.json") | ||
include("biome-maps/*.json") | ||
include("languages/**/*.yml") | ||
Comment on lines
+114
to
+121
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this really needed? AFAIK all resources are automatically included There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure, I'd have thought so too but I wonder why it was explicitly declared in the pom so I honored that explicit declaration. Can remove if there are no other reasons for it being explicitly declared. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can confirm all stuff is automatically included without that code |
||
filesMatching("plugin.yml") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be replaced with the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, haven't gotten to that part yet so I left it as we used to with maven resource filtering. |
||
expand("version" to project.version) | ||
} | ||
} | ||
test { | ||
useJUnitPlatform() | ||
} | ||
runServer { | ||
// Configure the Minecraft version for our task. | ||
// This is the only required configuration besides applying the plugin. | ||
// Your plugin's jar (or shadowJar if present) will be used automatically. | ||
minecraftVersion(minecraftVersion) | ||
|
||
downloadPlugins { | ||
// WorldEdit 7.2.19 | ||
url("https://mediafilez.forgecdn.net/files/5077/477/worldedit-bukkit-7.2.19.jar") | ||
} | ||
} | ||
named<Jar>("sourcesJar") { | ||
archiveVersion.set("v${project.version}") | ||
} | ||
} | ||
|
||
publishing { | ||
publications.create<MavenPublication>("maven") { | ||
from(components["java"]) | ||
pom { | ||
scm { | ||
inceptionYear = "2013" | ||
packaging = "jar" | ||
issueManagement { | ||
system = "GitHub Issues" | ||
url = "https://github.com/Slimefun/Slimefun4/issues" | ||
} | ||
licenses { | ||
license { | ||
name = "GNU General Public License v3.0" | ||
url = "https://github.com/Slimefun/Slimefun4/blob/master/LICENSE" | ||
distribution = "repo" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest we do this locally once (and push) instead of doing it every time in every task we want to invoke gradle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not entirely sure how the actions work so will need to figure out what you mean by that exactly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See also https://stackoverflow.com/questions/40978921/how-to-add-chmod-permissions-to-file-in-git