CrackedPolishedBlackstoneBricksMC / voldeloom

Voldeloom But Weird
MIT License
21 stars 2 forks source link

Can't use RetroFuturaGradle dependencies out of the box #7

Open Fuyukai opened 1 year ago

Fuyukai commented 1 year ago

If you try adding an dependency compiled using RFG with modImplementation and co, you'll get two wrong behaviours depending on version:

7.6 (or lower, presumably): Gradle complains about variant mismatch. 8.3: Gradle brings in the wrong type of dependency automatically.

The solution for both is this incantation:

configurations.all {
    attributes {
        attribute(Attribute.of("com.gtnewhorizons.retrofuturagradle.obfuscation", String::class.java), "srg")
    }
}

Unfortunately, this then breaks dependency resolution (thanks, RFG). Not sure what to do about this, but it's broken either way, so I guess pick the less broken option?

Fuyukai commented 1 year ago

Actually, another option is (in a repository) disable Gradle module metadata with

            metadataSources {
                mavenPom()
                ignoreGradleMetadataRedirection()
            }

but this breaks dep resolution in a third way (RFG deps usually depend on the dev classifier). This could be fixed on this side though by forcibly stripping the dev classifier from transistive dependencies.

Fuyukai commented 1 year ago

Adding a repository like this:

    repositories {
        maven {
            url = uri("http://jenkins.usrv.eu:8081/nexus/content/groups/public/")
            isAllowInsecureProtocol = true

            metadataSources {
                mavenPom()
                ignoreGradleMetadataRedirection()
            }
        }
    }

and then forcing dependency selection like this (buildscript syntax):

configurations.all {
    resolutionStrategy.eachDependency {
        artifactSelection {
            if (this.hasSelectors() && requestedSelectors.any { it.classifier == "dev" }) {
                withoutArtifactSelectors()
                selectArtifact(DependencyArtifact.DEFAULT_TYPE, null, null)
            }
        }
    }
}

will correctly force SRG dependencies instead.