This message was deleted.
# community-support
s
This message was deleted.
c
Copy code
Execution 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-SNAPSHOT
that's what I'm getting out
I was previously adding artifacts to the publication using
Copy code
artifact(tasks.getByName("jar"))
But moved to
Copy code
from(components["release"]))
Which lead to this
v
The question is, why you do that. Wouldn't it be better to just publish a feature variant? Or right away using the
jvm-test-fixture
plugin that does exactly that, creating an additional feature variant that by default also is published.
c
Android complicates the matter 😞 and the test-doubles is currently implemented as a feature (java.registerFeature)
v
Ah, ok, and is there a reason not to simply publish that feature? (I'm not doing Android)
c
am I alright to paste what my publish configuration looks like? It's around 100 lines
👍 1
Copy code
publishing {
    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)
                            }
                        }
                    }
                }
            }
        }
    }
}
v
Besides that
afterEvaluate
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.
c
I was just hoping that something in there seemed bananas, but if it doesn't then no 😞 no question
thanks for sense checking Vampire
v
I did not. And bananas is a matter of definition. If this should be the proper publishing of the feature variant, it probably is bananas. :-D
Actually, as far as I remember you do not need to do anything to publish a feature variant, it is published automatically if you do not disable it: https://docs.gradle.org/current/userguide/feature_variants.html#sec::publishing_feature_variants
c
the analogue emoji is giving me hope that there is some more knowledge for me to gain and then understand and fix this issue, thanks again, especially for the documentatio nlink