diff --git a/build.gradle.kts b/build.gradle.kts index 072c0b2..f578a00 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,23 +4,24 @@ plugins { id("java") } -val majorVersion = 0; -val minorVersion = 1; -val patchVersion = determinePatchVersion(project); +val majorVersion = 0 +val minorVersion = 1 +val patchVersion = determinePatchVersion(project) +val commitHash = determineCommitHash(project) allprojects { group = "dev.xhyrom" - version = "1.0-SNAPSHOT" + version = "$majorVersion.$minorVersion.$patchVersion" + + ext { + set("version", "$majorVersion.$minorVersion.$patchVersion+$commitHash") + } } subprojects { apply(plugin = "java") apply(plugin = "java-library") - ext { - set("version", "$majorVersion.$minorVersion.$patchVersion") - } - repositories { mavenCentral() } @@ -29,12 +30,27 @@ subprojects { fun determinePatchVersion(project: Project): Int { val tagInfo = ByteArrayOutputStream() + return try { + exec { + commandLine("git", "describe", "--tags") + standardOutput = tagInfo + } + + val result = tagInfo.toString() + + if (result.contains("-")) result.split("-")[1].toInt() else 0 + } catch (e: Exception) { + 0 + } +} + +fun determineCommitHash(project: Project): String { + val commitHashInfo = ByteArrayOutputStream() + exec { - commandLine("git", "describe", "--tags") - standardOutput = tagInfo + commandLine("git", "rev-parse", "--short", "HEAD") + standardOutput = commitHashInfo } - val result = tagInfo.toString() - - return if (result.contains("-")) result.split("-")[1].toInt() else 0 + return commitHashInfo.toString() } \ No newline at end of file diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts new file mode 100644 index 0000000..b1a04b7 --- /dev/null +++ b/buildSrc/build.gradle.kts @@ -0,0 +1,13 @@ +plugins { + `kotlin-dsl` + `groovy-gradle-plugin` +} + +repositories { + gradlePluginPortal() + mavenCentral() +} + +dependencies { + implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.2") +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/lighteco.base-logic.gradle.kts b/buildSrc/src/main/kotlin/lighteco.base-logic.gradle.kts new file mode 100644 index 0000000..2d169f1 --- /dev/null +++ b/buildSrc/src/main/kotlin/lighteco.base-logic.gradle.kts @@ -0,0 +1,26 @@ +plugins { + `java-library` + `maven-publish` +} + +java { + toolchain.languageVersion.set(JavaLanguageVersion.of(17)) + withSourcesJar() +} + +tasks { + processResources { + filesMatching(listOf("plugin.yml")) { + expand( + "name" to project.name, + "version" to project.version, + "description" to project.description, + "author" to "xHyroM" + ) + } + } + + compileJava { + options.encoding = Charsets.UTF_8.name() + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/lighteco.platform-logic.gradle.kts b/buildSrc/src/main/kotlin/lighteco.platform-logic.gradle.kts new file mode 100644 index 0000000..43dccc3 --- /dev/null +++ b/buildSrc/src/main/kotlin/lighteco.platform-logic.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("lighteco.shadow-logic") +} + +val Project.platform: String + get() = project.name.split("-")[1] + +tasks { + shadowJar { + archiveFileName.set("lighteco-${project.platform}-${project.version}.jar") + destinationDirectory.set(rootProject.layout.buildDirectory.dir("libs")) + } +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/lighteco.shadow-logic.gradle.kts b/buildSrc/src/main/kotlin/lighteco.shadow-logic.gradle.kts new file mode 100644 index 0000000..d3e0cef --- /dev/null +++ b/buildSrc/src/main/kotlin/lighteco.shadow-logic.gradle.kts @@ -0,0 +1,13 @@ +plugins { + id("lighteco.base-logic") + id("com.github.johnrengelman.shadow") +} + +tasks { + named("jar") { + archiveClassifier.set("unshaded") + } + named("build") { + dependsOn(tasks.shadowJar) + } +} \ No newline at end of file diff --git a/bukkit/build.gradle.kts b/bukkit/build.gradle.kts index edb0cbf..bf9743a 100644 --- a/bukkit/build.gradle.kts +++ b/bukkit/build.gradle.kts @@ -1,18 +1,11 @@ plugins { - id("java") + id("lighteco.platform-logic") } -group = "dev.xhyrom" - repositories { - mavenCentral() + maven("https://repo.papermc.io/repository/maven-public/") } dependencies { - testImplementation(platform("org.junit:junit-bom:5.9.1")) - testImplementation("org.junit.jupiter:junit-jupiter") -} - -tasks.test { - useJUnitPlatform() + compileOnly("io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT") } \ No newline at end of file diff --git a/bukkit/src/main/java/dev/xhyrom/Main.java b/bukkit/src/main/java/dev/xhyrom/Main.java deleted file mode 100644 index aec9966..0000000 --- a/bukkit/src/main/java/dev/xhyrom/Main.java +++ /dev/null @@ -1,7 +0,0 @@ -package dev.xhyrom; - -public class Main { - public static void main(String[] args) { - System.out.println("Hello world!"); - } -} \ No newline at end of file diff --git a/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java new file mode 100644 index 0000000..b4f364f --- /dev/null +++ b/bukkit/src/main/java/dev/xhyrom/lighteco/bukkit/BukkitLightEcoPlugin.java @@ -0,0 +1,4 @@ +package dev.xhyrom.lighteco.bukkit; + +public class BukkitLightEcoPlugin extends JavaPlugin { +} diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 016f901..0e30611 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -1,19 +1,3 @@ plugins { - id("java") -} - -group = "dev.xhyrom" -version = "1.0-SNAPSHOT" - -repositories { - mavenCentral() -} - -dependencies { - testImplementation(platform("org.junit:junit-bom:5.9.1")) - testImplementation("org.junit.jupiter:junit-jupiter") -} - -tasks.test { - useJUnitPlatform() + id("lighteco.shadow-logic") } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index e1c1dbe..8567d08 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -7,4 +7,4 @@ sequenceOf( ).forEach { include("lighteco-$it") project(":lighteco-$it").projectDir = file(it) -} \ No newline at end of file +} diff --git a/velocity/build.gradle.kts b/velocity/build.gradle.kts index 016f901..97e2d4e 100644 --- a/velocity/build.gradle.kts +++ b/velocity/build.gradle.kts @@ -1,19 +1,3 @@ plugins { - id("java") -} - -group = "dev.xhyrom" -version = "1.0-SNAPSHOT" - -repositories { - mavenCentral() -} - -dependencies { - testImplementation(platform("org.junit:junit-bom:5.9.1")) - testImplementation("org.junit.jupiter:junit-jupiter") -} - -tasks.test { - useJUnitPlatform() + id("lighteco.platform-logic") } \ No newline at end of file