Skip to content

Commit

Permalink
chore: switch to blossom for templates, resolve gradle deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Sep 9, 2023
1 parent fd1ecf9 commit b1541a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 36 deletions.
7 changes: 5 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
38 changes: 9 additions & 29 deletions subprojects/gradle-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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)
}

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}";

}

0 comments on commit b1541a6

Please sign in to comment.