-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Rework gradle-build setup * Fix versioning * Configure publishing * Fix github action * Fix github action 2 * Reorganize project naming * Update gradle
- Loading branch information
Showing
16 changed files
with
366 additions
and
251 deletions.
There are no files selected for viewing
This file contains 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,24 @@ | ||
# Normalize as LF in the repository, OS native locally | ||
* text=auto | ||
|
||
*.bat text eol=crlf | ||
gradlew text eol=lf | ||
*.sh text eol=lf | ||
*.conf text eol=lf | ||
|
||
*.java text | ||
*.java diff=java | ||
|
||
# Binary files that should not be modified | ||
*.dat binary | ||
*.db binary | ||
*.icns binary | ||
*.ico binary | ||
*.jar binary | ||
*.jks binary | ||
*.jpg binary | ||
*.key binary | ||
*.png binary | ||
*.ttf binary | ||
*.wav binary | ||
JavaApplicationStub binary |
This file contains 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
This file contains 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
This file contains 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
This file contains 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,17 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
fun plugin(dependency: Provider<PluginDependency>) = dependency.map { | ||
"${it.pluginId}:${it.pluginId}.gradle.plugin:${it.version}" | ||
} | ||
|
||
implementation ( plugin( libs.plugins.spotless ) ) | ||
implementation ( plugin( libs.plugins.shadow ) ) | ||
} |
This file contains 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,9 @@ | ||
|
||
// use version-catalog from root project | ||
dependencyResolutionManagement { | ||
versionCatalogs { | ||
register("libs") { | ||
from(files("../gradle/libs.versions.toml")) | ||
} | ||
} | ||
} |
This file contains 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,78 @@ | ||
plugins { | ||
java | ||
`java-library` | ||
`maven-publish` | ||
id ( "com.diffplug.spotless" ) | ||
} | ||
|
||
group = "de.bluecolored" | ||
version = gitVersion() | ||
|
||
repositories { | ||
maven ("https://repo.bluecolored.de/releases") { | ||
content { includeGroupByRegex ("de\\.bluecolored\\..*") } | ||
} | ||
maven ("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") { | ||
content { includeGroup ("org.spigotmc") } | ||
} | ||
|
||
mavenCentral() | ||
maven ("https://libraries.minecraft.net") | ||
maven ( "https://maven.minecraftforge.net" ) | ||
maven ("https://repo.papermc.io/repository/maven-public/") | ||
} | ||
|
||
tasks.withType(JavaCompile::class).configureEach { | ||
options.encoding = "utf-8" | ||
} | ||
|
||
tasks.withType(AbstractArchiveTask::class).configureEach { | ||
isReproducibleFileOrder = true | ||
isPreserveFileTimestamps = false | ||
} | ||
|
||
java { | ||
toolchain.languageVersion = JavaLanguageVersion.of(21) | ||
withSourcesJar() | ||
withJavadocJar() | ||
} | ||
|
||
tasks.javadoc { | ||
(options as StandardJavadocDocletOptions).apply { | ||
links( | ||
"https://docs.oracle.com/en/java/javase/16/docs/api/", | ||
"https://javadoc.io/doc/com.flowpowered/flow-math/1.0.3/", | ||
"https://javadoc.io/doc/com.google.code.gson/gson/2.8.9/", | ||
) | ||
addStringOption("Xdoclint:none", "-quiet") | ||
addBooleanOption("html5", true) | ||
} | ||
} | ||
|
||
tasks.test { | ||
useJUnitPlatform() | ||
} | ||
|
||
spotless { | ||
java { | ||
target ("src/*/java/**/*.java") | ||
|
||
licenseHeaderFile(rootProject.file("LICENSE_HEADER")) | ||
indentWithSpaces() | ||
trimTrailingWhitespace() | ||
} | ||
} | ||
|
||
publishing { | ||
repositories { | ||
maven { | ||
name = "bluecolored" | ||
url = uri( "https://repo.bluecolored.de/releases" ) | ||
|
||
credentials { | ||
username = project.findProperty("bluecoloredUsername") as String? ?: System.getenv("BLUECOLORED_USERNAME") | ||
password = project.findProperty("bluecoloredPassword") as String? ?: System.getenv("BLUECOLORED_PASSWORD") | ||
} | ||
} | ||
} | ||
} |
This file contains 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,44 @@ | ||
import org.gradle.api.Project | ||
import java.io.IOException | ||
import java.util.concurrent.TimeUnit | ||
import java.util.concurrent.TimeoutException | ||
|
||
fun Project.gitHash(): String { | ||
return runCommand("git rev-parse --verify HEAD", "-") | ||
} | ||
|
||
fun Project.gitClean(): Boolean { | ||
return runCommand("git status --porcelain", "NOT_CLEAN").isEmpty() | ||
} | ||
|
||
fun Project.gitVersion(): String { | ||
val lastTag = if (runCommand("git tag", "").isEmpty()) "" else runCommand("git describe --tags --abbrev=0", "") | ||
val lastVersion = if (lastTag.isEmpty()) "0.0" else lastTag.substring(1) // remove the leading 'v' | ||
val commits = runCommand("git rev-list --count $lastTag..HEAD", "0") | ||
val gitVersion = lastVersion + | ||
(if (commits == "0") "" else "-$commits") + | ||
(if (gitClean()) "" else "-dirty") | ||
|
||
logger.lifecycle("${project.name} version: $gitVersion") | ||
|
||
return gitVersion | ||
} | ||
|
||
private fun Project.runCommand(cmd: String, fallback: String? = null): String { | ||
ProcessBuilder(cmd.split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex())) | ||
.directory(projectDir) | ||
.redirectOutput(ProcessBuilder.Redirect.PIPE) | ||
.redirectError(ProcessBuilder.Redirect.PIPE) | ||
.start() | ||
.apply { | ||
if (!waitFor(10, TimeUnit.SECONDS)) | ||
throw TimeoutException("Failed to execute command: '$cmd'") | ||
} | ||
.run { | ||
val error = errorStream.bufferedReader().readText().trim() | ||
if (error.isEmpty()) return inputStream.bufferedReader().readText().trim() | ||
logger.warn("Failed to execute command '$cmd': $error") | ||
if (fallback != null) return fallback | ||
throw IOException(error) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains 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,14 @@ | ||
[versions] | ||
junit = "5.8.2" | ||
|
||
[libraries] | ||
flow-math = { module = "com.flowpowered:flow-math", version = "1.0.3" } | ||
gson = { module = "com.google.code.gson:gson", version = "2.8.9" } | ||
jetbrains-annotations = { module = "org.jetbrains:annotations", version = "23.0.0" } | ||
junit-core = { module = "org.junit.jupiter:junit-jupiter", version.ref = "junit" } | ||
junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } | ||
lombok = { module = "org.projectlombok:lombok", version = "1.18.32" } | ||
|
||
[plugins] | ||
shadow = { id = "io.github.goooler.shadow", version = "8.+" } | ||
spotless = { id = "com.diffplug.spotless", version = "6.+" } |
Binary file not shown.
This file contains 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,5 +1,5 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
Oops, something went wrong.