MinecraftForge / ForgeGradle

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

Manual specification of JarJar version information #888

Closed marchermans closed 1 year ago

marchermans commented 1 year ago

This PR enables users of Jar-In-Jar to manually specify the version ranges and pinned versions to use for the dependency they want to include.

This is useful because under normal situations the system will use attributes to marshal this information from the configured dependency into the execution of the tasks. However, due to restrictions on Gradle's end, these attributes can only be used on a dependency that does not target a particular classified dependency (regardless of maven or subproject).

To allow for the use of Jar-In-Jar a dependency information handler will be introduced by this PR which is queried first for dependency version(range) information after which the attributes have used a fallback.

Example:

jarJar {
   versionInformation {
      pin(dependency(project(path: ':core', configuration: 'forgeReobfuscated')), project(':core').version)
      ranged(dependency(project(path: ':core', configuration: 'forgeReobfuscated')), "[${project(':core').version}]")
   }
}

This example configures a subproject which is consumed from a specific secondary published artifact (the forgeReobfuscated one in particular) to use the exact version of the core project.