To embed external Jar-files into your mod file, you can use the jarjar configuration added by the plugin.
Subprojects
For example, if you have a coremod in a subproject and want to embed its jar file, you can use the following syntax.
dependencies {
jarJar project(":coremod")
}
When another mod also has a coremod subproject, Jar-in-Jar will use the group set in both projects to decide
whether they conflict or not.
The filename will also be automatically prefixed with your group to avoid Java module-name conflicts.
External Dependencies
When you want to bundle external dependencies, Jar-in-Jar has to be able to select a single copy of that dependency
when it is bundled by multiple mods (possibly even in different versions). To support this scenario, you should set
a supported version range to avoid mod incompatibilities.
dependencies {
jarJar(implementation("org.commonmark:commonmark")) {
version {
// The version range your mod is actually compatible with.
// Note that you may receive a *lower* version than your preferred if another
// Mod is only compatible up to 1.7.24, for example, your mod might get 1.7.24 at runtime.
strictly '[0.1, 1.0)'
prefer '0.21.0' // The version actually used in your dev workspace
}
}
}
PR Publishing
### The artifacts published by this PR:
- :package: [`net.neoforged.moddev:net.neoforged.moddev.gradle.plugin:0.1.94-pr-33-jij-docs-and-example`](https://github.com/neoforged/ModDevGradle/packages/2179884)
- :package: [`net.neoforged:moddev-gradle:0.1.94-pr-33-jij-docs-and-example`](https://github.com/neoforged/ModDevGradle/packages/2179883)
- :package: [`net.neoforged.moddev.repositories:net.neoforged.moddev.repositories.gradle.plugin:0.1.94-pr-33-jij-docs-and-example`](https://github.com/neoforged/ModDevGradle/packages/2179885)
### Repository Declaration
In order to use the artifacts published by the PR, add the following repository to your buildscript:
```gradle
repositories {
maven {
name 'Maven for PR #33' // https://github.com/neoforged/ModDevGradle/pull/33
url 'https://prmaven.neoforged.net/ModDevGradle/pr33'
content {
includeModule('net.neoforged.moddev', 'net.neoforged.moddev.gradle.plugin')
includeModule('net.neoforged', 'moddev-gradle')
includeModule('net.neoforged.moddev.repositories', 'net.neoforged.moddev.repositories.gradle.plugin')
}
}
}
```
Jar-in-Jar
To embed external Jar-files into your mod file, you can use the
jarjar
configuration added by the plugin.Subprojects
For example, if you have a coremod in a subproject and want to embed its jar file, you can use the following syntax.
When another mod also has a
coremod
subproject, Jar-in-Jar will use thegroup
set in both projects to decide whether they conflict or not. The filename will also be automatically prefixed with your group to avoid Java module-name conflicts.External Dependencies
When you want to bundle external dependencies, Jar-in-Jar has to be able to select a single copy of that dependency when it is bundled by multiple mods (possibly even in different versions). To support this scenario, you should set a supported version range to avoid mod incompatibilities.
Version ranges use the Maven version range format: