Skip to content

Commit

Permalink
Add Gradle module metadata with dependency on Minecraft dependencies …
Browse files Browse the repository at this point in the history
…Gradle module (#10)

* Publish metadata that references mc dependency publishing

* Work around tools without versions

* Work around tools without versions

* More logging

* Filter TOOLS better

---------

Co-authored-by: Luke Bemish <[email protected]>
  • Loading branch information
shartte and lukebemish authored Jun 10, 2024
1 parent 3464b09 commit 1e7ac26
Showing 1 changed file with 78 additions and 2 deletions.
80 changes: 78 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ plugins {

import net.minecraftforge.mcpconfig.tasks.*
import net.neoforged.srgutils.MinecraftVersion

import javax.inject.Inject
import java.nio.file.Files
import java.util.function.BiFunction
import java.util.stream.Collectors
Expand All @@ -25,6 +27,11 @@ ext {

logger.lifecycle('Timestamp: ' + TIMESTAMP)

abstract class ComponentMaker {
@Inject
abstract SoftwareComponentFactory getComponentFactory()
}

task downloadVersionManifest(type: Download) {
src 'https://launchermeta.mojang.com/mc/game/version_manifest_v2.json'
dest file('build/versions/version_manifest.json')
Expand Down Expand Up @@ -111,7 +118,7 @@ subprojects {
BUNDLE_EXTRACT_LIBS = null
if (CONFIG.containsKey('bundler_extract_libs'))
BUNDLE_EXTRACT_LIBS = Utils.readConfig(CONFIG, 'bundler_extract_libs', [:])
TOOLS = [FERNFLOWER, MERGETOOL, RENAMETOOL, MERGEMAPTOOL, MCINJECTOR, BUNDLE_EXTRACT_JAR, BUNDLE_EXTRACT_LIBS].findAll {it != null}
TOOLS = [FERNFLOWER, MERGETOOL, RENAMETOOL, MERGEMAPTOOL, MCINJECTOR, BUNDLE_EXTRACT_JAR, BUNDLE_EXTRACT_LIBS].findAll {it?.version != null}
}

java.toolchain.languageVersion = JavaLanguageVersion.of(JAVA_TARGET)
Expand All @@ -138,6 +145,13 @@ subprojects {
name 'forge'
url 'https://maven.neoforged.net/releases'
}
maven {
name 'mojang meta'
url 'https://maven.neoforged.net/mojang-meta/'
content {
includeModule('net.neoforged', 'minecraft-dependencies')
}
}
for (tool in TOOLS) {
if (tool.repo) {
maven {
Expand Down Expand Up @@ -799,12 +813,74 @@ subprojects {
}
}

def componentMaker = objects.newInstance(ComponentMaker)
def neoformComponent = componentMaker.componentFactory.adhoc('neoform')
components.add(neoformComponent)

configurations {
neoformData {
canBeResolved = false
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JAVA_TARGET)
}
outgoing {
capability "net.neoforged:neoform:${project.version + '-' + rootProject.TIMESTAMP}"
}
neoformComponent.addVariantsFromConfiguration(it) {}
}
neoformLibraries {
canBeResolved = false
}
neoformRuntimeElements {
canBeResolved = false
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JAVA_TARGET)
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))
}
outgoing {
capability "net.neoforged:neoform-dependencies:${project.version + '-' + rootProject.TIMESTAMP}"
}
neoformComponent.addVariantsFromConfiguration(it) {}
extendsFrom neoformLibraries
}
neoformApiElements {
canBeResolved = false
attributes {
attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, JAVA_TARGET)
attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_API))
}
outgoing {
capability "net.neoforged:neoform-dependencies:${project.version + '-' + rootProject.TIMESTAMP}"
}
neoformComponent.addVariantsFromConfiguration(it) {}
extendsFrom neoformLibraries
}
}

artifacts {
neoformData makeZip
}

TOOLS.each {
dependencies.add('neoformData', it.version) { transitive = false }
}

['server', 'client', 'joined'].each {
CONFIG?.libraries?.get(it)?.each { dependencies.add('neoformApiElements', it) { transitive = false } }
}

dependencies {
neoformLibraries("net.neoforged:minecraft-dependencies:${project.version}") {
endorseStrictVersions()
}
}

publishing {
publications {
timed(MavenPublication) {
artifactId rootProject.name
version project.version + '-' + rootProject.TIMESTAMP
artifact makeZip
from components.neoform
pom {
name = 'NeoForm'
description = 'Configuration files used for deobfuscating and modding Minecraft.'
Expand Down

0 comments on commit 1e7ac26

Please sign in to comment.