Skip to content

Use compileOnly scope instead of compile for Minecraft and Forge dependencies #574

@Cypher121

Description

@Cypher121

According to Gradle's notes on the compileOnly scope (https://blog.gradle.org/introducing-compile-only-dependencies), one of the use-cases for it is as follows:

Dependencies whose API is required at compile time but whose implementation is to be provided by a consuming library, application or runtime environment.

Last part fits forge dependency for mods perfectly.

As it stands right now, every library and mod declares forge as a compile dependency, which means 2 things:

  • It is declared a transitive dependency, causing mods to add it in addition to its own version of forge, unless one of them is explicitly removed.
  • It is declared a runtime dependency, which somewhat confusingly means mods are expected to provide it themselves at runtime. That means shadow jar will by default attempt to include forge and all of its dependencies in the mod. That behavior is not easy to avoid, as it is supposed to be avoided by having dependency marked compileOnly

Please consider putting moving the minecraft configuration from compile to compileOnly.

P.S. https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph is a good reference on how dependency scopes are set up for java projects. Note that compile and runtime scopes are not there at all, as they have been deprecated since Gradle 3.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions