mirror of
https://github.com/apple/pkl.git
synced 2026-08-05 11:48:41 +02:00
Avoid duplicate pkl-gradle publication (#1777)
The java-gradle-plugin already creates the pluginMaven publication. Applying the library publishing convention creates another publication with the same coordinates, causing an overwrite warning during Sonatype publishing. Configure the shared POM metadata, validation, signing, and archive artifacts directly so pkl-gradle retains the convention behavior without creating the duplicate library publication. Fixes #1742
This commit is contained in:
@@ -61,26 +61,31 @@ fun Project.configurePklPomMetadata() {
|
||||
}
|
||||
}
|
||||
|
||||
/** Configures POM validation task to check for unresolved versions and snapshots in releases. */
|
||||
fun Project.configurePomValidation() {
|
||||
/**
|
||||
* Configures POM validation for [publicationName] to check for unresolved versions and snapshots in
|
||||
* releases.
|
||||
*/
|
||||
fun Project.configurePomValidation(publicationName: String = "library") {
|
||||
val generatePomTaskName =
|
||||
"generatePomFileFor${publicationName.replaceFirstChar { it.uppercase() }}Publication"
|
||||
val generatePomTasks =
|
||||
tasks.withType<GenerateMavenPom>().matching { it.name == generatePomTaskName }
|
||||
val pomFiles = providers.provider { generatePomTasks.map { it.destination } }
|
||||
|
||||
val validatePom =
|
||||
tasks.register("validatePom") {
|
||||
if (tasks.findByName("generatePomFileForLibraryPublication") == null) {
|
||||
return@register
|
||||
}
|
||||
val generatePomFileForLibraryPublication =
|
||||
tasks.named<GenerateMavenPom>("generatePomFileForLibraryPublication")
|
||||
val outputFile =
|
||||
layout.buildDirectory.file("validatePom") // dummy output to satisfy up-to-date check
|
||||
|
||||
dependsOn(generatePomFileForLibraryPublication)
|
||||
inputs.file(generatePomFileForLibraryPublication.get().destination)
|
||||
dependsOn(generatePomTasks)
|
||||
inputs.files(pomFiles)
|
||||
outputs.file(outputFile)
|
||||
onlyIf { pomFiles.get().isNotEmpty() }
|
||||
|
||||
doLast {
|
||||
outputFile.get().asFile.delete()
|
||||
|
||||
val pomFile = generatePomFileForLibraryPublication.get().destination
|
||||
val pomFile = pomFiles.get().single()
|
||||
assert(pomFile.exists())
|
||||
|
||||
val text = pomFile.readText()
|
||||
|
||||
@@ -20,10 +20,20 @@ plugins {
|
||||
id("pklJSpecify")
|
||||
`java-gradle-plugin`
|
||||
`maven-publish`
|
||||
id("pklPublishLibrary")
|
||||
signing
|
||||
}
|
||||
|
||||
configurePklPomMetadata()
|
||||
|
||||
configurePomValidation("pluginMaven")
|
||||
|
||||
configurePklSigning()
|
||||
|
||||
artifacts {
|
||||
tasks.findByName("javadocJar")?.let { archives(it) }
|
||||
tasks.findByName("sourcesJar")?.let { archives(it) }
|
||||
}
|
||||
|
||||
dependencies {
|
||||
// Declare a `compileOnly` dependency on `projects.pklTools`
|
||||
// to ensure correct code navigation in IntelliJ.
|
||||
|
||||
Reference in New Issue
Block a user