Add mainCapabilityAttribute to disambiguate project dependencies with multiple capabilities when bundling library jars
This commit is contained in:
parent
91fac7484b
commit
833ca1def7
2 changed files with 11 additions and 3 deletions
|
@ -200,9 +200,14 @@ abstract class CreateBundlerJar : ZippedTask() {
|
||||||
return when (val ident = id.componentIdentifier) {
|
return when (val ident = id.componentIdentifier) {
|
||||||
is ModuleComponentIdentifier -> ModuleId.fromIdentifier(id)
|
is ModuleComponentIdentifier -> ModuleId.fromIdentifier(id)
|
||||||
is ProjectComponentIdentifier -> {
|
is ProjectComponentIdentifier -> {
|
||||||
val capability = variant.capabilities.first()
|
val mainCap = variant.attributes.getAttribute(mainCapabilityAttribute)
|
||||||
val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}")
|
if (mainCap != null) {
|
||||||
ModuleId(capability.group, capability.name, version)
|
ModuleId.parse(mainCap)
|
||||||
|
} else {
|
||||||
|
val capability = variant.capabilities.first()
|
||||||
|
val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}")
|
||||||
|
ModuleId(capability.group, capability.name, version)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else -> throw PaperweightException("Unknown artifact result type: ${ident::class.java.name}")
|
else -> throw PaperweightException("Unknown artifact result type: ${ident::class.java.name}")
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@ import kotlin.io.path.*
|
||||||
import org.cadixdev.lorenz.merge.MergeResult
|
import org.cadixdev.lorenz.merge.MergeResult
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import org.gradle.api.Task
|
import org.gradle.api.Task
|
||||||
|
import org.gradle.api.attributes.Attribute
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.file.FileSystemLocation
|
import org.gradle.api.file.FileSystemLocation
|
||||||
import org.gradle.api.file.ProjectLayout
|
import org.gradle.api.file.ProjectLayout
|
||||||
|
@ -416,3 +417,5 @@ fun modifyManifest(path: Path, create: Boolean = true, op: Manifest.() -> Unit)
|
||||||
path.outputStream().buffered().use { mf.write(it) }
|
path.outputStream().buffered().use { mf.write(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val mainCapabilityAttribute: Attribute<String> = Attribute.of("io.papermc.paperweight.main-capability", String::class.java)
|
||||||
|
|
Loading…
Reference in a new issue