Skip to content

Commit

Permalink
Add mainCapabilityAttribute to disambiguate project dependencies with…
Browse files Browse the repository at this point in the history
… multiple capabilities when bundling library jars (#257)
  • Loading branch information
jpenilla authored Oct 25, 2024
1 parent 91fac74 commit addb21d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,14 @@ abstract class CreateBundlerJar : ZippedTask() {
return when (val ident = id.componentIdentifier) {
is ModuleComponentIdentifier -> ModuleId.fromIdentifier(id)
is ProjectComponentIdentifier -> {
val capability = variant.capabilities.first()
val version = capability.version ?: throw PaperweightException("Unknown version for ${capability.group}:${capability.name}")
ModuleId(capability.group, capability.name, version)
val mainCap = variant.attributes.getAttribute(mainCapabilityAttribute)
if (mainCap != null) {
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}")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import kotlin.io.path.*
import org.cadixdev.lorenz.merge.MergeResult
import org.gradle.api.Project
import org.gradle.api.Task
import org.gradle.api.attributes.Attribute
import org.gradle.api.file.FileCollection
import org.gradle.api.file.FileSystemLocation
import org.gradle.api.file.ProjectLayout
Expand Down Expand Up @@ -416,3 +417,5 @@ fun modifyManifest(path: Path, create: Boolean = true, op: Manifest.() -> Unit)
path.outputStream().buffered().use { mf.write(it) }
}
}

val mainCapabilityAttribute: Attribute<String> = Attribute.of("io.papermc.paperweight.main-capability", String::class.java)

0 comments on commit addb21d

Please sign in to comment.