MinecraftForge / ForgeGradle

Minecraft mod development framework used by Forge and FML for the gradle build system
GNU Lesser General Public License v2.1
516 stars 443 forks source link

Add forgeDeobf configuration for dependencies deobfuscating with artifact transformer #865

Closed sasanquaa closed 2 years ago

sasanquaa commented 2 years ago

This pull request proposes a configuration to be used for deobfuscating Minecraft codes related to #609 #747.

Example usage:

buildscript {
    repositories {
        maven { url = 'https://maven.minecraftforge.net/' }
    }
    dependencies {
        classpath 'net.minecraftforge.gradle:ForgeGradle:5.1.43'
    }
}

apply plugin: 'net.minecraftforge.gradle'

java.toolchain.languageVersion = JavaLanguageVersion.of(8)

minecraft {
    mappings channel: 'official', version: '1.16.5'
}

repositories {
    ivy {
        url "https://download.nodecdn.net/containers/reforged/server/release"
        patternLayout {
            artifact "[revision]/[artifact].[ext]"
        }
        metadataSources {
            artifact()
        }
    }
}

dependencies {
    minecraft 'net.minecraftforge:forge:1.16.5-36.2.20'
    forgeDeobf ':Pixelmon-1.16.5-9.0.2-server:9.0.2'
}
SizableShrimp commented 2 years ago

What about sources? (https://github.com/gradle/gradle/issues/19207)

sasanquaa commented 2 years ago

Hmm, yeah this doesn't seem to work with sources though. Like in the issue, it is not triggering the transformer

marchermans commented 2 years ago

This is a known problem, and currently Gradle is not able to support this. There are at least two known issues with this:

  1. Sources can not be transformed, IDEs in particular use ArtifactResolutionQuery instances which do not use configurations or attributes as such they will, at least as of now, never use transformers.
  2. Dependencies which have dependencies marked as runtime only (like for example LWJGL with its natives) will not work when they are passed through transformers since as of now no IDE can handle a dependency with two different files in two different usecase configurations (IDEA for example will mark both as being a runtime dependency making compiling the mod fail).

As such I will be closing this PR for now, if you want to talk about this, you can come visit our Discord, or possibly even send me a DM and I will show you every possible way I have tried to make this work over the last two years. I personally have at least 3 issues open (one on IDEAs youtrack and two on Gradles repo) which handle this.

Greets,

Orion

LexManos commented 2 years ago

Just a clarification as it's somewhat related. A ArtifactTransformer would be useful for someething like AccessTransformers, as yes it would slightly desync the source files, it woulld be worth it for the cleanup of decompile/cache files. Soo if you want to look into something llike that. It may be worth it.