From d77273435fa4fa7fc667017a8f13278bcf82182f Mon Sep 17 00:00:00 2001 From: Su5eD Date: Tue, 9 Jul 2024 15:36:46 +0200 Subject: [PATCH] Fix duplicate generated package name --- .github/workflows/release.yml | 1 + .../src/main/kotlin/ffapi.neo-entrypoint.gradle.kts | 11 ++++++++--- ffapi.gradle.properties | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b74b70c64..f0904920e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -45,6 +45,7 @@ jobs: run: ./gradlew clean build --stacktrace publish: strategy: + fail-fast: false matrix: include: - name: Maven diff --git a/buildSrc/src/main/kotlin/ffapi.neo-entrypoint.gradle.kts b/buildSrc/src/main/kotlin/ffapi.neo-entrypoint.gradle.kts index 275b5a9d7..1b2b38dcf 100644 --- a/buildSrc/src/main/kotlin/ffapi.neo-entrypoint.gradle.kts +++ b/buildSrc/src/main/kotlin/ffapi.neo-entrypoint.gradle.kts @@ -26,6 +26,7 @@ masterSourceSets.forEach { sourceSet -> outputDir.set(targetDir) fabricModJson.set(modMetadataJson) testEnvironment = sourceSet.name == "testmod" + includeVersion.set(project.parent?.name == "deprecated") } sourceSet.java.srcDir(task) val cleanTask = tasks.register(sourceSet.getTaskName("clean", baseTaskName), Delete::class.java) { @@ -49,6 +50,9 @@ abstract class GenerateForgeModEntrypoint : DefaultTask() { @get:InputFile val fabricModJson: RegularFileProperty = project.objects.fileProperty() + @get:Input + val includeVersion: Property = project.objects.property(Boolean::class) + @get:Input val testEnvironment: Property = project.objects.property(Boolean::class) @@ -56,6 +60,7 @@ abstract class GenerateForgeModEntrypoint : DefaultTask() { val outputDir: DirectoryProperty = project.objects.directoryProperty() private val projectNamePattern = "^fabric_(.+?)(?:_v\\d)?\$".toRegex() + private val projectVersionNamePattern = "^fabric_(.+?_v\\d)?\$".toRegex() @TaskAction fun run() { @@ -63,7 +68,7 @@ abstract class GenerateForgeModEntrypoint : DefaultTask() { val modid = normalizeModid(modMetadata.id) val className = "GeneratedEntryPoint" - val packageName = packageNameForEntryPoint(modid) + val packageName = packageNameForEntryPoint(modid, includeVersion.get()) val packagePath = packageName.replace('/', '.') val packageDir = outputDir.file(packagePath).get().asFile.toPath() packageDir.createDirectories() @@ -141,8 +146,8 @@ abstract class GenerateForgeModEntrypoint : DefaultTask() { } } - private fun packageNameForEntryPoint(modid: String): String { - val uniqueName = projectNamePattern.find(modid)?.groups?.get(1)?.value + private fun packageNameForEntryPoint(modid: String, includeVersion: Boolean): String { + val uniqueName = (if (includeVersion) projectVersionNamePattern else projectNamePattern).find(modid)?.groups?.get(1)?.value ?: throw RuntimeException("Unable to determine generated package name for mod $modid") return "org.sinytra.fabric.$uniqueName.generated" } diff --git a/ffapi.gradle.properties b/ffapi.gradle.properties index 1cda1c863..0c759c87c 100644 --- a/ffapi.gradle.properties +++ b/ffapi.gradle.properties @@ -1,7 +1,7 @@ loom.platform=neoforge fabric.loom.dontRemap=true -implementationVersion=2.0.0 +implementationVersion=2.0.1 versionMc=1.21 versionForge=21.0.57-beta