-
Notifications
You must be signed in to change notification settings - Fork 96
Improve gradle #234
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
Merged
Merged
Improve gradle #234
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
de718fe
add version catalogs
makeevrserg 73b3e0e
add version catalogs inside gradle and replace with gradle-kts
makeevrserg 4811f87
fix spotbugs task
makeevrserg 165fd3c
fix spotbugs task
makeevrserg 554d7e6
move enableFeaturePreview down
makeevrserg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,107 @@ | ||
| @file:Suppress("GroovyAssignabilityCheck") | ||
|
|
||
| import net.minecraftforge.licenser.LicenseExtension | ||
| import net.minecraftforge.licenser.LicenseProperties | ||
| import org.gradle.kotlin.dsl.closureOf | ||
|
|
||
| plugins { | ||
| `java-library` | ||
| `maven-publish` | ||
| } | ||
|
|
||
| tasks.withType<JavaCompile> { | ||
| options.release.set(21) | ||
| options.encoding = "UTF-8" | ||
| } | ||
|
|
||
| dependencies { | ||
| compileOnly(libs.minecraft.velocity.api) | ||
| api(libs.elytrium.commons.config) | ||
| api(libs.elytrium.commons.utils) | ||
| api(libs.elytrium.commons.velocity) | ||
| api(libs.elytrium.commons.kyori) | ||
| api(libs.minecraft.adventure.nbt) | ||
|
|
||
| compileOnly(libs.tool.spotbugs.annotations) | ||
| } | ||
|
|
||
| extensions.configure<LicenseExtension> { | ||
| matching( | ||
| "**/mcprotocollib/**", | ||
| closureOf<LicenseProperties> { | ||
| setHeader(rootProject.file("HEADER_MCPROTOCOLLIB.txt")) | ||
| } | ||
| ) | ||
| setHeader(file("HEADER.txt")) | ||
| } | ||
|
|
||
| tasks.named<Javadoc>("javadoc") { | ||
| options.encoding = "UTF-8" | ||
| (options as? StandardJavadocDocletOptions)?.apply { | ||
| source = "21" | ||
| links("https://docs.oracle.com/en/java/javase/11/docs/api/") | ||
| addStringOption("Xdoclint:none", "-quiet") | ||
| if (JavaVersion.current() >= JavaVersion.VERSION_1_9 && JavaVersion.current() < JavaVersion.VERSION_12) { | ||
| addBooleanOption("-no-module-directories", true) | ||
| } | ||
| } | ||
| } | ||
|
|
||
| val sourcesJar by tasks.registering(Jar::class) { | ||
| archiveClassifier.set("sources") | ||
| from(sourceSets.main.get().allSource) | ||
| } | ||
|
|
||
| val javadocJar by tasks.registering(Jar::class) { | ||
| archiveClassifier.set("javadoc") | ||
| from(tasks.javadoc) | ||
| } | ||
|
|
||
| publishing { | ||
| repositories { | ||
| maven { | ||
| credentials { | ||
| username = System.getenv("ELYTRIUM_MAVEN_USERNAME") | ||
| password = System.getenv("ELYTRIUM_MAVEN_PASSWORD") | ||
| } | ||
| name = "elytrium-repo" | ||
| url = uri("https://maven.elytrium.net/repo/") | ||
| } | ||
| } | ||
|
|
||
| publications.create<MavenPublication>("publication") { | ||
| from(components["java"]) | ||
|
|
||
| artifact(javadocJar) | ||
| artifact(sourcesJar) | ||
| } | ||
| } | ||
|
|
||
| artifacts { | ||
| archives(javadocJar) | ||
| archives(sourcesJar) | ||
| } | ||
|
|
||
| @Suppress("UNCHECKED_CAST") | ||
| val getCurrentShortRevision = rootProject.extra["getCurrentShortRevision"] as () -> String | ||
|
|
||
|
|
||
| val versionStringProvider = provider { | ||
| if (version.toString().contains("-")) { | ||
| "${version} (git-${getCurrentShortRevision()})" | ||
| } else { | ||
| version.toString() | ||
| } | ||
| } | ||
|
|
||
| val copyTask by tasks.register<Copy>("generateTemplates") { | ||
| val versionString = versionStringProvider.get() | ||
| inputs.property("version", versionString) | ||
| from(file("src/main/templates")) | ||
| into(layout.buildDirectory.dir("generated/sources/templates")) | ||
| expand("version" to versionString) | ||
| } | ||
|
|
||
| sourceSets.main.configure { | ||
| java.srcDir(copyTask.outputs) | ||
| } | ||
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| import com.github.spotbugs.snom.SpotBugsExtension | ||
| import com.github.spotbugs.snom.SpotBugsTask | ||
|
|
||
| plugins { | ||
| java | ||
| checkstyle | ||
| alias(libs.plugins.gradle.spotbugs) apply false | ||
| alias(libs.plugins.gradle.licenser) apply false | ||
| } | ||
|
|
||
| allprojects { | ||
| apply(plugin = "checkstyle") | ||
| apply(plugin = "com.github.spotbugs") | ||
| apply(plugin = "net.minecraftforge.licenser") | ||
|
|
||
| group = "net.elytrium.limboapi" | ||
| version = "1.1.27-SNAPSHOT" | ||
|
|
||
| tasks.withType<JavaCompile> { | ||
| sourceCompatibility = JavaVersion.VERSION_21.toString() | ||
| targetCompatibility = JavaVersion.VERSION_21.toString() | ||
| } | ||
|
|
||
| checkstyle { | ||
| toolVersion = "10.12.1" | ||
| configFile = file("$rootDir/config/checkstyle/checkstyle.xml") | ||
| configProperties = mapOf("configDirectory" to "$rootDir/config/checkstyle") | ||
| maxErrors = 0 | ||
| maxWarnings = 0 | ||
| } | ||
|
|
||
| extensions.configure<SpotBugsExtension> { | ||
| excludeFilter.set(file("${rootDir}/config/spotbugs/suppressions.xml")) | ||
| } | ||
|
|
||
| tasks.withType<SpotBugsTask>() { | ||
| reports.create("html") { | ||
| required.set(true) | ||
| outputLocation.set(layout.buildDirectory.file("reports/spotbugs/main/spotbugs.html")) | ||
| setStylesheet("fancy-hist.xsl") | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fun getCurrentShortRevision(): String { | ||
| val isWindows = System.getProperty("os.name") | ||
| .lowercase() | ||
| .contains("win") | ||
|
|
||
| val process = if (isWindows) { | ||
| ProcessBuilder("cmd", "/c", "git rev-parse --short HEAD") | ||
| } else { | ||
| ProcessBuilder("bash", "-c", "git rev-parse --short HEAD") | ||
| } | ||
| return process | ||
| .start() | ||
| .inputStream | ||
| .bufferedReader() | ||
| .readText() | ||
| .trim() | ||
| } | ||
|
|
||
| // Make the function available to subprojects via extra properties | ||
| extra["getCurrentShortRevision"] = ::getCurrentShortRevision |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,3 @@ | ||
| org.gradle.jvmargs=-Xmx4096m | ||
| fastPrepareVersion=1.0.13 | ||
| velocityVersion=3.5.0-SNAPSHOT | ||
| nettyVersion=4.1.86.Final | ||
| fastutilVersion=8.5.11 | ||
| bstatsVersion=3.0.0 | ||
| spotbugsVersion=4.7.3 | ||
| elytriumCommonsVersion=1.2.3 | ||
| adventureVersion=4.15.0 | ||
| manifestUrl=https://launchermeta.mojang.com/mc/game/version_manifest.json | ||
| cacheValidMillis=6000000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| [versions] | ||
| elytrium-commons = "1.2.3" # https://github.com/Elytrium/elytrium-java-commons | ||
| elytrium-fastprepare = "1.0.13" #https://github.com/Elytrium/FastPrepareAPI | ||
| gradle-licenser = "1.2.0" # https://github.com/CadixDev/licenser | ||
| gradle-shadow = "9.4.0" # https://github.com/GradleUp/shadow | ||
| gradle-spotbugs = "6.4.8" # https://github.com/spotbugs/spotbugs-gradle-plugin | ||
| minecraft-adventure = "4.15.0" # https://github.com/KyoriPowered/adventure | ||
| minecraft-bstats = "3.0.0" # https://github.com/Bastian/bStats | ||
| minecraft-velocity = "3.5.0-SNAPSHOT" # https://github.com/PaperMC/Velocity | ||
| tool-commons-io = "2.6" # https://github.com/apache/commons-io | ||
| tool-fastutil = "8.5.11" # https://github.com/vigna/fastutil/ | ||
| tool-google-guava = "28.0-jre" # https://github.com/google/guava | ||
| tool-netty = "4.1.86.Final" # https://github.com/netty/netty | ||
| tool-spotbugs-annotations = "4.7.3" # https://github.com/spotbugs/spotbugs | ||
|
|
||
| [libraries] | ||
| elytrium-commons-config = { module = "net.elytrium.commons:config", version.ref = "elytrium-commons" } | ||
| elytrium-commons-kyori = { module = "net.elytrium.commons:kyori", version.ref = "elytrium-commons" } | ||
| elytrium-commons-utils = { module = "net.elytrium.commons:utils", version.ref = "elytrium-commons" } | ||
| elytrium-commons-velocity = { module = "net.elytrium.commons:velocity", version.ref = "elytrium-commons" } | ||
| elytrium-fastprepare = { module = "net.elytrium:fastprepare", version.ref = "elytrium-fastprepare" } | ||
| minecraft-adventure-nbt = { module = "net.kyori:adventure-nbt", version.ref = "minecraft-adventure" } | ||
| minecraft-bstats-velocity = { module = "org.bstats:bstats-velocity", version.ref = "minecraft-bstats" } | ||
| minecraft-velocity-api = { module = "com.velocitypowered:velocity-api", version.ref = "minecraft-velocity" } | ||
| minecraft-velocity-native = { module = "com.velocitypowered:velocity-native", version.ref = "minecraft-velocity" } | ||
| minecraft-velocity-proxy = { module = "com.velocitypowered:velocity-proxy", version.ref = "minecraft-velocity" } | ||
| tool-commons-io = { module = "commons-io:commons-io", version.ref = "tool-commons-io" } | ||
| tool-fastutil = { module = "it.unimi.dsi:fastutil-core", version.ref = "tool-fastutil" } | ||
| tool-google-guava = { module = "com.google.guava:guava", version.ref = "tool-google-guava" } | ||
| tool-netty-codec = { module = "io.netty:netty-codec", version.ref = "tool-netty" } | ||
| tool-netty-handler = { module = "io.netty:netty-handler", version.ref = "tool-netty" } | ||
| tool-spotbugs-annotations = { module = "com.github.spotbugs:spotbugs-annotations", version.ref = "tool-spotbugs-annotations" } | ||
|
|
||
| [plugins] | ||
| gradle-licenser = { id = "net.minecraftforge.licenser", version.ref = "gradle-licenser" } | ||
| gradle-shadow = { id = "com.gradleup.shadow", version.ref = "gradle-shadow" } | ||
| gradle-spotbugs = { id = "com.github.spotbugs", version.ref = "gradle-spotbugs" } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.