diff --git a/README.md b/README.md index 8aad8d795..880bf8054 100644 --- a/README.md +++ b/README.md @@ -28,13 +28,13 @@ maven("https://repo.panda-lang.org/releases") ### Dependency ```kts - implementation("dev.rollczi:{artifact}:3.1.2") + implementation("dev.rollczi:{artifact}:3.2.0") ``` ```xml dev.rollczi {artifact} - 3.1.2 + 3.2.0 ``` `{artifact}` replace with [platform artifact](https://github.com/Rollczi/LiteCommands#platform-artifacts) diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 272716ad2..39bd02261 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -9,6 +9,7 @@ repositories { dependencies { implementation("me.champeau.jmh:jmh-gradle-plugin:0.7.2") implementation("net.kyori:indra-git:3.1.3") + implementation("com.google.guava:guava:30.1.1-jre") } sourceSets { diff --git a/buildSrc/src/main/kotlin/litecommands-compile-variables.gradle.kts b/buildSrc/src/main/kotlin/litecommands-compile-variables.gradle.kts index ed31f1100..33bf79975 100644 --- a/buildSrc/src/main/kotlin/litecommands-compile-variables.gradle.kts +++ b/buildSrc/src/main/kotlin/litecommands-compile-variables.gradle.kts @@ -1,13 +1,23 @@ +import com.google.common.io.Files + plugins { id("java-library") id("net.kyori.indra.git") } -val litecommandsVariables = "src/dev/rollczi/litecommands/LiteCommandsVariables.java" -val sourceFile = file(litecommandsVariables) -var content: String = sourceFile.readText() +val input = file("src") +var output = File(project.layout.buildDirectory.get().asFile, "sources/java/") + +val variablesInputFile = File(input, "dev/rollczi/litecommands/LiteCommandsVariables.java") +val variablesOutputFile = File(output, "dev/rollczi/litecommands/LiteCommandsVariables.java") +var variablesContent: String = variablesInputFile.readText() + +tasks.withType(JavaCompile::class.java).configureEach { + dependsOn("generateLiteCommandsVariables") + setSource(output) +} -tasks.compileJava { +tasks.create("generateLiteCommandsVariables") { if (!indraGit.isPresent) { throw IllegalStateException("indra-git is not present") } @@ -21,18 +31,54 @@ tasks.compileJava { ?: System.getenv("GIT_COMMIT") ?: throw IllegalStateException("commit is null") - val newContent = content + val newContent = variablesContent .replace("{litecommands-version}", version) .replace("{litecommands-branch}", branchName) .replace("{litecommands-commit}", commitHash) - doFirst { - sourceFile.writeText(newContent) + + if (output.exists()) { + // Remove the output directory if it exists to prevent any possible conflicts + deleteDirectory(output); } -} -tasks.classes { - doLast { - sourceFile.writeText(content) + output.mkdirs(); + output = output.getCanonicalFile() + + // copy all files + + input.walkTopDown().forEach { + if (it.isFile) { + val relativePath = it.relativeTo(input) + val outputFile = File(output, relativePath.path.toString()) + + Files.createParentDirs(outputFile) + + if (outputFile.path.equals(variablesOutputFile.path)) { + outputFile.createNewFile() + outputFile.writeText(newContent) + return@forEach + } + + + it.copyTo(outputFile) + } } } + +fun deleteDirectory(directory: File): Boolean { + if (directory.exists()) { + val files = directory.listFiles() + if (files != null) { + for (file in files) { + if (file.isDirectory) { + deleteDirectory(file) + } else { + file.delete() + } + } + } + } + + return directory.delete() +} \ No newline at end of file diff --git a/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts b/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts index 937907a6c..95ad90dfe 100644 --- a/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts +++ b/buildSrc/src/main/kotlin/litecommands-publish.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "dev.rollczi" -version = "3.2.0-SNAPSHOT" +version = "3.2.0" java { withSourcesJar() diff --git a/examples/bukkit-adventure-platform/build.gradle.kts b/examples/bukkit-adventure-platform/build.gradle.kts index 98df9925b..176a97d22 100644 --- a/examples/bukkit-adventure-platform/build.gradle.kts +++ b/examples/bukkit-adventure-platform/build.gradle.kts @@ -18,8 +18,8 @@ repositories { dependencies { compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") - // implementation("dev.rollczi:litecommands-bukkit:3.1.2") // <-- uncomment in your project - // implementation("dev.rollczi:litecommands-adventure-platform:3.1.2") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-bukkit:3.2.0") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-adventure-platform:3.2.0") // <-- uncomment in your project implementation("net.kyori:adventure-platform-bukkit:4.3.0") implementation("net.kyori:adventure-text-minimessage:4.14.0") diff --git a/examples/bukkit-chatgpt/build.gradle.kts b/examples/bukkit-chatgpt/build.gradle.kts index f4106abb5..b3e6f2823 100644 --- a/examples/bukkit-chatgpt/build.gradle.kts +++ b/examples/bukkit-chatgpt/build.gradle.kts @@ -18,8 +18,8 @@ repositories { dependencies { compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") - // implementation("dev.rollczi:litecommands-bukkit:3.1.2") // <-- uncomment in your project - // implementation("dev.rollczi:litecommands-chatgpt:3.1.2") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-bukkit:3.2.0") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-chatgpt:3.2.0") // <-- uncomment in your project implementation(project(":litecommands-bukkit")) // don't use this line in your build.gradle implementation(project(":litecommands-chatgpt")) // don't use this line in your build.gradle } diff --git a/examples/bukkit/build.gradle.kts b/examples/bukkit/build.gradle.kts index 54eacf78a..1212f847e 100644 --- a/examples/bukkit/build.gradle.kts +++ b/examples/bukkit/build.gradle.kts @@ -18,7 +18,7 @@ repositories { dependencies { compileOnly("org.spigotmc:spigot-api:1.20.2-R0.1-SNAPSHOT") - // implementation("dev.rollczi:litecommands-bukkit:3.1.2") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-bukkit:3.2.0") // <-- uncomment in your project implementation(project(":litecommands-bukkit")) // don't use this line in your build.gradle } diff --git a/examples/velocity/build.gradle.kts b/examples/velocity/build.gradle.kts index 53b9fdc72..f20681fd4 100644 --- a/examples/velocity/build.gradle.kts +++ b/examples/velocity/build.gradle.kts @@ -19,7 +19,7 @@ dependencies { compileOnly("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT") annotationProcessor("com.velocitypowered:velocity-api:3.2.0-SNAPSHOT") - // implementation("dev.rollczi:litecommands-velocity:3.1.2") // <-- uncomment in your project + // implementation("dev.rollczi:litecommands-velocity:3.2.0") // <-- uncomment in your project implementation(project(":litecommands-velocity")) // don't use this line in your build.gradle } diff --git a/litecommands-core/src/dev/rollczi/litecommands/LiteCommandsVariables.java b/litecommands-core/src/dev/rollczi/litecommands/LiteCommandsVariables.java index b74f132bf..5efaa06eb 100644 --- a/litecommands-core/src/dev/rollczi/litecommands/LiteCommandsVariables.java +++ b/litecommands-core/src/dev/rollczi/litecommands/LiteCommandsVariables.java @@ -7,9 +7,9 @@ */ public final class LiteCommandsVariables { - public static final String VERSION = "3.2.0-SNAPSHOT"; - public static final String BRANCH = "master"; - public static final String COMMIT = "3e05bcf3550cfac6b33a0b6a824226e46c50a109"; + public static final String VERSION = "{litecommands-version}"; + public static final String BRANCH = "{litecommands-branch}"; + public static final String COMMIT = "{litecommands-commit}"; private LiteCommandsVariables() { }