Slackbot
10/18/2023, 10:17 AMChris Sawczuk
10/18/2023, 10:20 AMExecution failed for task ':bam:generatePomFileForMavenJavaPublication'.
> Failed to query the value of property 'dependencies'.
> Publishing is not able to resolve a dependency on a project with multiple publications that have different coordinates.
Found the following publications in project ':services':
- Maven publication 'mavenJava' with coordinates uk.bam:services:0.0.5-SNAPSHOT
- Maven publication 'mavenTestDoublesJava' with coordinates uk.bam:services-test-doubles:0.0.5-SNAPSHOTChris Sawczuk
10/18/2023, 10:20 AMChris Sawczuk
10/18/2023, 10:25 AMartifact(tasks.getByName("jar"))
But moved to
from(components["release"]))
Which lead to thisVampire
10/18/2023, 11:02 AMjvm-test-fixture plugin that does exactly that, creating an additional feature variant that by default also is published.Chris Sawczuk
10/18/2023, 11:12 AMVampire
10/18/2023, 11:25 AMChris Sawczuk
10/18/2023, 12:09 PMChris Sawczuk
10/18/2023, 12:23 PMpublishing {
afterEvaluate {
publications {
register<MavenPublication>("mavenJava") {
if (tasks.names.contains("jar")) {
artifact(tasks.getByName("jar"))
} else {
from(components["release"])
}
artifact(tasks.getByName("dokkaJavadocJar"))
artifact(tasks.getByName("sourcesJar"))
pom {
withXml {
val dependenciesNode = asNode().appendNode("dependencies")
listOf("javadoc", "sources").forEach { classifier ->
dependenciesNode.appendNode("dependency").apply {
appendNode("groupId", groupId)
appendNode("artifactId", artifactId)
appendNode("version", version)
appendNode("classifier", classifier)
}
}
configurations.getByName("api") {
dependencies.forEach {
val dependencyNode = dependenciesNode.appendNode("dependency")
dependencyNode.appendNode("groupId", it.group)
dependencyNode.appendNode("artifactId", it.name)
if (it.version != null) {
dependencyNode.appendNode("version", it.version)
}
}
}
}
}
}
register<MavenPublication>("mavenTestDoublesJava") {
artifactId = "${project.name}-test-doubles"
if (tasks.names.contains("debugJar")) {
artifact(tasks.getByName("debugJar"))
} else {
artifact(tasks.getByName("bundleDebugAar"))
}
artifact(tasks.getByName("debugSourcesJar")) {
classifier = "sources"
}
pom {
withXml {
val dependenciesNode = asNode().appendNode("dependencies")
listOf("sources").forEach { classifier ->
dependenciesNode.appendNode("dependency").apply {
appendNode("groupId", groupId)
appendNode("artifactId", artifactId)
appendNode("version", version)
appendNode("classifier", classifier)
}
}
}
}
}
}
}
}Vampire
10/18/2023, 12:27 PMafterEvaluate is evil in almost all situations, do you have a question?
afterEvaluate is most often just doing symptom treatment, shifting problems to a later, more hard to reproduce, more hard to find, and more hard to debug and fix point in time. It is like using SwingUtilities.invokeLater or Platform.runLater to "fix" a GUI problem. The main effect of using afterEvaluate is introducing ordering problems, timing problems, and race conditions. There are very little cases where it is necessary to mitigate some still existing shortcomings.Chris Sawczuk
10/18/2023, 1:25 PMChris Sawczuk
10/18/2023, 1:25 PMVampire
10/18/2023, 1:33 PMVampire
10/18/2023, 1:35 PMChris Sawczuk
10/18/2023, 1:36 PM