From b1541a66c090be5ab81e33b9ea4ae82e80950b34 Mon Sep 17 00:00:00 2001 From: zml Date: Sat, 9 Sep 2023 12:26:45 -0700 Subject: [PATCH] chore: switch to blossom for templates, resolve gradle deprecations --- gradle/libs.versions.toml | 7 +++- subprojects/gradle-plugin/build.gradle.kts | 38 +++++-------------- .../vanilla/internal/BuildVersions.java | 10 ++--- 3 files changed, 19 insertions(+), 36 deletions(-) rename subprojects/gradle-plugin/src/main/{templates => java-templates}/org/spongepowered/gradle/vanilla/internal/BuildVersions.java (81%) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index e7fab21..e6ef111 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -31,12 +31,15 @@ gson = { module = "com.google.code.gson:gson", version = "2.10.1" } ideaExt = { module = "gradle.plugin.org.jetbrains.gradle.plugin.idea-ext:gradle-idea-ext", version.ref = "ideaExt" } immutables-value = { module = "org.immutables:value", version.ref = "immutables" } immutables-gson = { module = "org.immutables:gson", version.ref = "immutables" } -junit-api = { module = "org.junit.jupiter:junit-jupiter-api", version.ref = "junit" } -junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit" } +junit-api = { module = "org.junit.jupiter:junit-jupiter-api" } +junit-bom = { module = "org.junit:junit-bom", version.ref = "junit" } +junit-engine = { module = "org.junit.jupiter:junit-jupiter-engine" } +junit-launcher = { module = "org.junit.platform:junit-platform-launcher" } mergeTool = { module = "net.minecraftforge:mergetool", version.ref = "mergeTool" } shadowPlugin = { module = "com.github.jengelman.gradle.plugins:shadow", version = "6.1.0" } [plugins] +blossom = { id = "net.kyori.blossom", version = "2.0.1" } eclipseApt = { id = "com.diffplug.eclipse.apt", version = "3.42.2" } gradlePluginPublish = { id = "com.gradle.plugin-publish", version = "1.2.1" } ideaExt = { id = "org.jetbrains.gradle.plugin.idea-ext", version.ref = "ideaExt" } diff --git a/subprojects/gradle-plugin/build.gradle.kts b/subprojects/gradle-plugin/build.gradle.kts index f37f886..93630ec 100644 --- a/subprojects/gradle-plugin/build.gradle.kts +++ b/subprojects/gradle-plugin/build.gradle.kts @@ -1,9 +1,8 @@ -import org.jetbrains.gradle.ext.TaskTriggersConfig - plugins { `java-gradle-plugin` alias(libs.plugins.gradlePluginPublish) alias(libs.plugins.indra.publishing.gradlePlugin) + alias(libs.plugins.blossom) alias(libs.plugins.ideaExt) } @@ -82,43 +81,24 @@ dependencies { "shadowCompileOnly"(libs.shadowPlugin) implementation(shadow.output) + testImplementation(platform(libs.junit.bom)) testImplementation(libs.junit.api) + testRuntimeOnly(libs.junit.launcher) testRuntimeOnly(libs.junit.engine) } -tasks { - // Generate source templates - val templateSource = project.file("src/main/templates") - val templateDest = project.layout.buildDirectory.dir("generated/sources/templates") - val generateTemplates by registering(Copy::class) { - group = "sponge" - description = "Generate classes from templates for VanillaGradle" - val properties = mutableMapOf( +sourceSets.main { + blossom.javaSources { + properties.putAll(mutableMapOf( "asmVersion" to libs.versions.asm.get(), "vineFlowerVersion" to libs.versions.vineFlower.get(), "mergeToolVersion" to libs.versions.mergeTool.get(), "accessWidenerVersion" to libs.versions.accessWidener.get() - ) - inputs.properties(properties) - - // Copy template - from(templateSource) - into(templateDest) - expand(properties) - } - - sourceSets.main { - java.srcDir(generateTemplates.map { it.outputs }) - } - - // Generate templates on IDE import as well - (rootProject.idea.project as? ExtensionAware)?.also { - (it.extensions["settings"] as ExtensionAware).extensions.getByType(TaskTriggersConfig::class).afterSync(generateTemplates) - } - project.eclipse { - synchronizationTasks(generateTemplates) + )) } +} +tasks { jar { from(jarMerge.output) from(jarDecompile.output) diff --git a/subprojects/gradle-plugin/src/main/templates/org/spongepowered/gradle/vanilla/internal/BuildVersions.java b/subprojects/gradle-plugin/src/main/java-templates/org/spongepowered/gradle/vanilla/internal/BuildVersions.java similarity index 81% rename from subprojects/gradle-plugin/src/main/templates/org/spongepowered/gradle/vanilla/internal/BuildVersions.java rename to subprojects/gradle-plugin/src/main/java-templates/org/spongepowered/gradle/vanilla/internal/BuildVersions.java index f3974e4..b122916 100644 --- a/subprojects/gradle-plugin/src/main/templates/org/spongepowered/gradle/vanilla/internal/BuildVersions.java +++ b/subprojects/gradle-plugin/src/main/java-templates/org/spongepowered/gradle/vanilla/internal/BuildVersions.java @@ -25,16 +25,16 @@ package org.spongepowered.gradle.vanilla.internal; /** - * Versions populated by the build process + * Versions populated by the build process. */ class BuildVersions { private BuildVersions() { } - public static final String ASM = "${asmVersion}"; - public static final String VINEFLOWER = "${vineFlowerVersion}"; - public static final String MERGE_TOOL = "${mergeToolVersion}"; - public static final String ACCESS_WIDENER = "${accessWidenerVersion}"; + public static final String ASM = "{{ asmVersion }}"; + public static final String VINEFLOWER = "{{ vineFlowerVersion }}"; + public static final String MERGE_TOOL = "{{ mergeToolVersion }}"; + public static final String ACCESS_WIDENER = "{{ accessWidenerVersion }}"; }