How to configure pom dependencies without a component

We have a fairly complicated project which we’re trying to migrate from the ‘maven’ plugin to the newer ‘maven-publish’ plugin.

One of the things we do is publish 2 different maven artifacts from the same project, our main artifact, as well as a test-utilities artifact. In the past we accomplished this with repository filters which “just worked”. Now I’m trying to configure the same thing with publications, but I can’t figure out how to attach the dependencies.

 publications {
        library(MavenPublication) {
            artifactId = "library"
            artifact javadocJar
            artifact sourcesJar

            pom basePomConfiguration

        libraryTestUtils(MavenPublication) {
            artifactId = "library-test-utils"
            // I don't have a component to use here and I'm not sure how to configure a custom one
           //  I have configurations called testUtilsCompile and testUtilsRuntime
            artifact testUtilsJar
            artifact testUtilsJavadocJar
            artifact testUtilsSourcesJar
            pom basePomConfiguration
            pom {
                description = "Test Utilities"
          // We could add dependencies manually to the pom here, no obvious API for adding them to the pom.  

The documentation says there there is no easy way to do this ( which is a bit frustrating since the maven-publish plugin is out of incubation… ) but it’s not clear to me what the hard way to do it is. Is manually crafting xml nodes in the pom like this stack overflow post suggests the best way?

1 Like