Skip to content

Commit

Permalink
Publishing Gradle metadata
Browse files Browse the repository at this point in the history
Changelog and classifiers

Add publications

Publish all moddev artifacts using capabilities

Publishing... stuff...

Add mavens for PRs

Use published neoform version

Use published neoform version
  • Loading branch information
shartte authored and Technici4n committed May 27, 2024
1 parent 7a8ec7c commit fc8c8d0
Show file tree
Hide file tree
Showing 3 changed files with 180 additions and 25 deletions.
16 changes: 16 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ org.gradle.debug=false
java_version=21

minecraft_version=1.20.6
neoform_version=20240429.153634
neoform_version=20240524.210247
# on snapshot versions, used to prefix the version
neoforge_snapshot_next_stable=21.0

Expand Down
187 changes: 163 additions & 24 deletions projects/neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,6 @@ tasks.withType(Javadoc.class).configureEach {
options.addStringOption('Xdoclint:all,-missing', '-public')
}

tasks.withType(GenerateModuleMetadata).configureEach { enabled = false }

configurations {
forValidation {
canBeConsumed = true
Expand All @@ -231,6 +229,169 @@ minecraft {
modIdentifier 'minecraft'
}

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
Expand All @@ -239,28 +400,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')
Expand Down

0 comments on commit fc8c8d0

Please sign in to comment.