From 0a89757ba8476f6b062102c559f283f0b32866d2 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Wed, 8 May 2024 21:14:50 +0200 Subject: [PATCH 1/7] Publishing Gradle metadata --- build.gradle | 16 +++ projects/neoforge/build.gradle | 187 ++++++++++++++++++++++++++++----- 2 files changed, 179 insertions(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index 9244f6a6a5..5ef4afe42c 100644 --- a/build.gradle +++ b/build.gradle @@ -43,6 +43,22 @@ allprojects { group 'net.neoforged' repositories { mavenLocal() + + maven { + name 'Maven for PR #10' // https://github.com/neoforged/NeoForm/pull/10 + url 'https://prmaven.neoforged.net/NeoForm/pr10' + content { + includeModule('net.neoforged', 'neoform') + } + } + + maven { + name 'Maven for PR #1' // https://github.com/neoforged/GradleMinecraftDependencies/pull/1 + url 'https://prmaven.neoforged.net/GradleMinecraftDependencies/pr1' + content { + includeModule('net.neoforged', 'minecraft-dependencies') + } + } } } diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index 0100bf10cf..6bcf157fe7 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -207,8 +207,6 @@ tasks.withType(Javadoc.class).configureEach { options.addStringOption('Xdoclint:all,-missing', '-public') } -tasks.withType(GenerateModuleMetadata).configureEach { enabled = false } - configurations { forValidation { canBeConsumed = true @@ -230,6 +228,169 @@ artifacts { } } +AdhocComponentWithVariants javaComponent = (AdhocComponentWithVariants) project.components.findByName("java") +// Ensure the two default variants are not published, since they +// contain Minecraft classes +javaComponent.withVariantsFromConfiguration(configurations.apiElements) { + it.skip() +} +javaComponent.withVariantsFromConfiguration(configurations.runtimeElements) { + it.skip() +} + +configurations { + modDevBundle { + canBeResolved = false + canBeConsumed = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "data")) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + } + outgoing { + capability("net.neoforged:neoforge-moddev-bundle:${project.version}") + } + javaComponent.addVariantsFromConfiguration(it) {} // Publish it + } + modDevConfig { + canBeResolved = false + canBeConsumed = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "data")) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + } + outgoing { + capability("net.neoforged:neoforge-moddev-config:${project.version}") + } + javaComponent.addVariantsFromConfiguration(it) {} // Publish it + } + installerJar { + canBeResolved = false + canBeConsumed = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "installer")) + attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.SHADOWED)) + // The installer targets JDK 8 + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) + } + // Publish it + javaComponent.addVariantsFromConfiguration(it) {} + } + universalJar { + canBeResolved = false + canBeConsumed = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) + attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JavaVersion.current().majorVersion.toInteger()) + attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR)) + } + // Publish it + javaComponent.addVariantsFromConfiguration(it) {} + } + changelog { + canBeResolved = false + canBeConsumed = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.DOCUMENTATION)) + attribute(DocsType.DOCS_TYPE_ATTRIBUTE, objects.named(DocsType, "changelog")) + } + // Publish it, but only for release versions + if (!rootProject.isPreReleaseVersion) { + javaComponent.addVariantsFromConfiguration(it) {} + } + } + modDevApiElements { + canBeResolved = false + canBeConsumed = true + afterEvaluate { + extendsFrom userdevCompileOnly, installerLibraries, moduleOnly + } + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_API)) + } + outgoing { + capability("net.neoforged:neoforge-dependencies:${project.version}") + } + javaComponent.addVariantsFromConfiguration(it) {} + } + modDevRuntimeElements { + canBeResolved = false + canBeConsumed = true + afterEvaluate { + extendsFrom installerLibraries, moduleOnly + } + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) + } + outgoing { + capability("net.neoforged:neoforge-dependencies:${project.version}") + } + javaComponent.addVariantsFromConfiguration(it) {} + } + modDevModulePath { + canBeResolved = false + canBeConsumed = true + afterEvaluate { + extendsFrom moduleOnly + } + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + } + outgoing { + capability("net.neoforged:neoforge-moddev-module-path:${project.version}") + } + javaComponent.addVariantsFromConfiguration(it) {} + } +} + +dependencies { + modDevApiElements("net.neoforged:neoform:${project.minecraft_version}-${project.neoform_version}") { + capabilities { + requireCapability 'net.neoforged:neoform-dependencies' + } + endorseStrictVersions() + } + modDevRuntimeElements("net.neoforged:neoform:${project.minecraft_version}-${project.neoform_version}") { + capabilities { + requireCapability 'net.neoforged:neoform-dependencies' + } + endorseStrictVersions() + } +} + +afterEvaluate { + artifacts { + modDevBundle(userdevJar) { + setClassifier("userdev") // Legacy + } + modDevConfig(createUserdevJson.output) { + builtBy(createUserdevJson) + setClassifier("moddev-config") + } + universalJar(signUniversalJar.output) { + builtBy(signUniversalJar) + setClassifier("universal") + } + installerJar(signInstallerJar.output) { + builtBy(signInstallerJar) + setClassifier("installer") + } + // Only publish a changelog for releases + changelog(rootProject.createChangelog.outputFile) { + builtBy(rootProject.createChangelog) + setClassifier("changelog") + setExtension("txt") + } + } +} + publishing { publications.create('NeoForge', MavenPublication) { groupId = project.group @@ -238,28 +399,6 @@ publishing { from components.java - artifacts = [] - - afterEvaluate { - artifact (signUniversalJar.output) { - classifier 'universal' - } - artifact (signInstallerJar.output) { - classifier 'installer' - } - artifact (userdevJar) { - classifier 'userdev' - } - artifact (sourcesJar) { - classifier 'sources' - } - } - - if (!rootProject.isPreReleaseVersion) { - // Only publish a changelog for releases - changelog.publish(it) - } - versionMapping { usage('java-api') { fromResolutionOf('runtimeClasspath') From 18183270ad1e93f1aa63e6c252792959288bf419 Mon Sep 17 00:00:00 2001 From: Technici4n <13494793+Technici4n@users.noreply.github.com> Date: Mon, 27 May 2024 21:09:34 +0200 Subject: [PATCH 2/7] Add variant with the FML test fixtures --- projects/neoforge/build.gradle | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index 6bcf157fe7..58c8995b3d 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -348,6 +348,19 @@ configurations { } javaComponent.addVariantsFromConfiguration(it) {} } + modDevTestFixtures { + canBeResolved = false + canBeConsumed = true + attributes { + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EXTERNAL)) + attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) + } + outgoing { + capability("net.neoforged:neoforge-moddev-test-fixtures:${project.version}") + } + javaComponent.addVariantsFromConfiguration(it) {} + } } dependencies { @@ -363,6 +376,9 @@ dependencies { } endorseStrictVersions() } + modDevTestFixtures("net.neoforged.fancymodloader:junit-fml:${project.fancy_mod_loader_version}") { + endorseStrictVersions() + } } afterEvaluate { From a67306f57efe0706ebad76ac50022b27033044fb Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Sun, 2 Jun 2024 01:45:48 +0200 Subject: [PATCH 3/7] Add NeoForm and its tool dependencies to the moddev bundle. --- projects/neoforge/build.gradle | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index 58c8995b3d..202dd5d112 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -364,6 +364,12 @@ configurations { } dependencies { + modDevBundle("net.neoforged:neoform:${project.minecraft_version}-${project.neoform_version}") { + capabilities { + requireCapability 'net.neoforged:neoform' + } + endorseStrictVersions() + } modDevApiElements("net.neoforged:neoform:${project.minecraft_version}-${project.neoform_version}") { capabilities { requireCapability 'net.neoforged:neoform-dependencies' From bbf007c2e01a3dd6530ea29da331dee3efb5f5b1 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 10 Jun 2024 21:08:21 +0200 Subject: [PATCH 4/7] Remove temp PR repos --- build.gradle | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/build.gradle b/build.gradle index 5ef4afe42c..9244f6a6a5 100644 --- a/build.gradle +++ b/build.gradle @@ -43,22 +43,6 @@ allprojects { group 'net.neoforged' repositories { mavenLocal() - - maven { - name 'Maven for PR #10' // https://github.com/neoforged/NeoForm/pull/10 - url 'https://prmaven.neoforged.net/NeoForm/pr10' - content { - includeModule('net.neoforged', 'neoform') - } - } - - maven { - name 'Maven for PR #1' // https://github.com/neoforged/GradleMinecraftDependencies/pull/1 - url 'https://prmaven.neoforged.net/GradleMinecraftDependencies/pr1' - content { - includeModule('net.neoforged', 'minecraft-dependencies') - } - } } } From e67def10e74d68b2cb1e6ec4bfa60fa1a98b4b9c Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 10 Jun 2024 22:16:14 +0200 Subject: [PATCH 5/7] Move changelog generation to subproject to reduce reliance on rootProject --- build.gradle | 5 ----- projects/neoforge/build.gradle | 15 +++++++++++---- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 9244f6a6a5..183cf8203f 100644 --- a/build.gradle +++ b/build.gradle @@ -27,11 +27,6 @@ if (isPreReleaseVersion) { } } - changelog { - from '20.6' - disableAutomaticPublicationRegistration() - } - project.version = gradleutils.version.toString() } diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index 202dd5d112..e97fdd192c 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -3,7 +3,14 @@ plugins { id 'maven-publish' } -rootProject.gradleutils.setupSigning(project: project, signAllPublications: true) +apply plugin: 'net.neoforged.gradleutils' + +gradleutils.setupSigning(project: project, signAllPublications: true) + +changelog { + from '20.6' + disableAutomaticPublicationRegistration() +} dynamicProject { runtime("${project.minecraft_version}-${project.neoform_version}", @@ -405,8 +412,8 @@ afterEvaluate { setClassifier("installer") } // Only publish a changelog for releases - changelog(rootProject.createChangelog.outputFile) { - builtBy(rootProject.createChangelog) + changelog(createChangelog.outputFile) { + builtBy(createChangelog) setClassifier("changelog") setExtension("txt") } @@ -456,6 +463,6 @@ publishing { } } repositories { - maven rootProject.gradleutils.getPublishingMaven() + maven gradleutils.getPublishingMaven() } } From c9a67d9cee94cc5027c02f8440829e6407d8277d Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 10 Jun 2024 22:48:33 +0200 Subject: [PATCH 6/7] Move changelog generation to subproject to reduce reliance on rootProject --- projects/neoforge/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index e97fdd192c..c0502cec06 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -411,7 +411,6 @@ afterEvaluate { builtBy(signInstallerJar) setClassifier("installer") } - // Only publish a changelog for releases changelog(createChangelog.outputFile) { builtBy(createChangelog) setClassifier("changelog") From 50ea26b6d214aea99733549e0dab0c9e77c0d591 Mon Sep 17 00:00:00 2001 From: Sebastian Hartte Date: Mon, 10 Jun 2024 23:07:44 +0200 Subject: [PATCH 7/7] change installer to capability --- projects/neoforge/build.gradle | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/projects/neoforge/build.gradle b/projects/neoforge/build.gradle index c0502cec06..453ca11005 100644 --- a/projects/neoforge/build.gradle +++ b/projects/neoforge/build.gradle @@ -274,12 +274,15 @@ configurations { canBeResolved = false canBeConsumed = true attributes { - attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, "installer")) + attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY)) attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME)) - attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.SHADOWED)) + attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling, Bundling.EMBEDDED)) // The installer targets JDK 8 attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8) } + outgoing { + capability("net.neoforged:neoforge-installer:${project.version}") + } // Publish it javaComponent.addVariantsFromConfiguration(it) {} }