First of all, this should only be used in very special cases. Including dependencies in your mod transitively means that you always have to check whether there are any unwanted dependencies down the line, and exclude these.
Note: if you use languages other than Java, e.g. Kotlin, the likelyhood that you need transitive includes increases
First, create a custom configuration. This is also where you specifiy the excludes.
val transitiveInclude: Configuration by configurations.creating {
exclude(group = "com.mojang")
exclude(group = "org.jetbrains.kotlin")
exclude(group = "org.jetbrains.kotlinx")
}
The excludes are important, since transitive includes can add a lot of unwanted dependencies which are already on the classpath.
Now you can use the new configuration inside the dependencies block.
dependencies {
transitiveInclude(implementation("org.litote.kmongo:kmongo-coroutine-serialization:4.6.0")!!)
}
The important part comes next, in order to resolve all dependencies transitively and add them to the non-transitive include
configuration of fabric-loom, do this at the end of the dependencies
block:
dependencies {
// all your declared dependencies
transitiveInclude.resolvedConfiguration.resolvedArtifacts.forEach {
include(it.moduleVersion.id.toString())
}
}
And you are done. You can now build
the project and check the META-INF/jars
directory inside your jars. Again, make sure that you excluded all unwanted dependencies.
@Phelms215 in the top level of the
build.gradle.kts
file