Skip to content

Commit

Permalink
chore(build): Use blossom rather than ad-hoc template processing
Browse files Browse the repository at this point in the history
This will require IntelliJ users to remove old template processing task triggers from their Gradle configs for the project.
  • Loading branch information
zml2008 committed Jan 24, 2024
1 parent 78f1e5b commit 81426e2
Show file tree
Hide file tree
Showing 9 changed files with 39 additions and 209 deletions.
4 changes: 0 additions & 4 deletions build-logic/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,5 @@ gradlePlugin {
id = "implementation-structure"
implementationClass = "org.spongepowered.gradle.impl.SpongeImplementationPlugin"
}
templateResources {
id = "templated-resources"
implementationClass = "org.spongepowered.gradle.impl.TemplatedResourcesPlugin"
}
}
}

This file was deleted.

This file was deleted.

16 changes: 8 additions & 8 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ buildscript {
plugins {
alias(libs.plugins.shadow)
id("implementation-structure")
id("templated-resources")
alias(libs.plugins.blossom)
id("net.smoofyuniverse.loom") version "1.1-SNAPSHOT"
}

Expand Down Expand Up @@ -429,14 +429,14 @@ tasks {
assemble {
dependsOn(universalJar)
}
}

templateResources {
val props = mutableMapOf(
"version" to project.version,
"description" to project.description
)
inputs.properties(props)
expand(props)
sourceSets {
main {
blossom.resources {
property("version", project.provider { project.version.toString() })
property("description", project.description.toString())
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ issueTrackerURL="https://github.com/SpongePowered/Sponge/issues"

[[mods]]
modId="spongeforge"
version="${version}"
version="{{ version }}"
displayName="SpongeForge"
displayTest="IGNORE_SERVER_VERSION"
credits="SpongePowered and Contributors"
authors="SpongePowered"
description = "${description}"
description = "{{ description }}"

[[dependencies.spongeforge]]
modId="forge"
Expand All @@ -24,14 +24,14 @@ side="BOTH"
[[dependencies.spongeforge]]
modId="sponge"
mandatory=true
versionRange="[${version}]"
versionRange="[{{ version }}]"
ordering="AFTER"
side="BOTH"


[[mods]]
modId="sponge"
version="${version}"
version="{{ version }}"
displayName="Sponge"
displayTest="IGNORE_SERVER_VERSION"
credits="SpongePowered and Contributors"
Expand Down
9 changes: 5 additions & 4 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ javapoet = { module = "com.squareup:javapoet", version = "1.13.0" }
accessWidener = { module = "net.fabricmc:access-widener", version = "2.1.0" }

# Sponge
adventure-serializerConfigurate4 = { module = "net.kyori:adventure-serializer-configurate4" }
configurate-jackson = { module = "org.spongepowered:configurate-jackson" }
adventure-serializerConfigurate4 = { module = "net.kyori:adventure-serializer-configurate4" } # version inherited from bom in API catalog
configurate-jackson = { module = "org.spongepowered:configurate-jackson" } # version inherited from bom in API catalog
db-h2 = { module = "com.h2database:h2", version = "1.4.196" }
db-hikariCp = { module = "com.zaxxer:HikariCP", version = "2.6.3" }
db-maria = { module = "org.mariadb.jdbc:mariadb-java-client", version = "2.0.3" }
Expand All @@ -66,7 +66,8 @@ terminalConsoleAppender = { module = "net.minecrell:terminalconsoleappender", ve
vineflower = { module = "org.vineflower:vineflower", version.ref = "vineflower" }

[plugins]
vanillaGradle = { id = "org.spongepowered.gradle.vanilla" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
blossom = { id = "net.kyori.blossom", version = "2.1.0" }
indra-licenserSpotless = { id = "net.kyori.indra.licenser.spotless", version = "3.1.3" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
vanillaGradle = { id = "org.spongepowered.gradle.vanilla" }
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
55 changes: 14 additions & 41 deletions vanilla/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import org.jetbrains.gradle.ext.TaskTriggersConfig
import org.spongepowered.gradle.impl.GenerateResourceTemplates

plugins {
id("org.spongepowered.gradle.vanilla")
alias(libs.plugins.shadow)
id("implementation-structure")
id("templated-resources")
alias(libs.plugins.blossom)
eclipse
}

Expand Down Expand Up @@ -368,23 +365,24 @@ val vanillaManifest = java.manifest {
System.getenv()["GIT_BRANCH"]?.apply { attributes("Git-Branch" to this) }
}

vanillaLaunch.apply {
blossom.resources {
property("apiVersion", apiVersion)
property("minecraftVersion", minecraftVersion)
property("version", provider { project.version.toString() })
}
}
vanillaInstaller.apply {
blossom.javaSources {
property("minecraftVersion", minecraftVersion)
}
}

tasks {
jar {
manifest.from(vanillaManifest)
}

named("templateLaunchResources", GenerateResourceTemplates::class) {
inputs.property("version.api", apiVersion)
inputs.property("version.minecraft", minecraftVersion)
inputs.property("version.vanilla", project.version)

expand(
"apiVersion" to apiVersion,
"minecraftVersion" to minecraftVersion,
"version" to project.version
)
}

val vanillaInstallerJar by registering(Jar::class) {
archiveClassifier.set("installer")
manifest{
Expand Down Expand Up @@ -422,31 +420,6 @@ tasks {
dependsOn("integrationTestServer", "integrationTestClient")
}

val installerTemplateSource = project.file("src/installer/templates")
val installerTemplateDest = project.layout.buildDirectory.dir("generated/sources/installerTemplates")
val generateInstallerTemplates by registering(Copy::class) {
group = "sponge"
description = "Generate classes from templates for the SpongeVanilla installer"
val properties = mutableMapOf(
"minecraftVersion" to minecraftVersion
)
inputs.properties(properties)

// Copy template
from(installerTemplateSource)
into(installerTemplateDest)
expand(properties)
}
vanillaInstaller.java.srcDir(generateInstallerTemplates.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(generateInstallerTemplates)
}
project.eclipse {
synchronizationTasks(generateInstallerTemplates)
}

val installerResources = project.layout.buildDirectory.dir("generated/resources/installer")
vanillaInstaller.resources.srcDir(installerResources)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public final class Constants {

public static final class Libraries {

public static final String MINECRAFT_VERSION_TARGET = "${minecraftVersion}";
public static final String MINECRAFT_VERSION_TARGET = "{{ minecraftVersion }}";
public static final String MINECRAFT_MANIFEST_URL = "https://launchermeta.mojang.com/mc/game/version_manifest.json";
public static final String MINECRAFT_PATH_PREFIX = "net/minecraft";
public static final String MINECRAFT_SERVER_JAR_NAME = "minecraft_server";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{
"id": "minecraft",
"name": "Minecraft",
"version": "${minecraftVersion}",
"version": "{{ minecraftVersion }}",
"entrypoint": "org.spongepowered.common.launcher.Launcher",
"links": {
"homepage": "https://www.minecraft.net"
Expand All @@ -24,7 +24,7 @@
"loader": "java_plain",
"id": "spongeapi",
"name": "SpongeAPI",
"version": "${apiVersion}",
"version": "{{ apiVersion }}",
"entrypoint": "org.spongepowered.api.Sponge",
"description": "The Minecraft API specification",
"links": {
Expand All @@ -42,7 +42,7 @@
{
"id": "sponge",
"name": "Sponge",
"version": "${minecraftVersion}-${apiVersion}",
"version": "{{ minecraftVersion }}-{{ apiVersion }}",
"entrypoint": "org.spongepowered.common.SpongeCommon",
"description": "The common Sponge implementation",
"links": {
Expand All @@ -59,18 +59,18 @@
"dependencies": [
{
"id": "minecraft",
"version": "${minecraftVersion}"
"version": "{{ minecraftVersion }}"
},
{
"id": "spongeapi",
"version": "${apiVersion}"
"version": "{{ apiVersion }}"
}
]
},
{
"id": "spongevanilla",
"name": "SpongeVanilla",
"version": "${version}",
"version": "{{ version }}",
"entrypoint": "org.spongepowered.vanilla.SpongeVanilla",
"description": "Vanilla Minecraft with Sponge",
"links": {
Expand All @@ -87,7 +87,7 @@
"dependencies": [
{
"id": "sponge",
"version": "${minecraftVersion}-${apiVersion}"
"version": "{{ minecraftVersion }}-{{ apiVersion }}"
}
]
}
Expand Down

0 comments on commit 81426e2

Please sign in to comment.