[Solved] Maven-publish no pom entires if publications is before dependencies block

(Since this is in an incubating feature, I don’t know if “Bug” or “Yet to be implemented” is more correct :wink: )
We eventually figured out what was causing this particular problem I had posted on the Old Forum.

We were setting up the publications block before the dependencies block in the project. This caused there to be no entries in the pom file.

Not a particularly onerous requirement but should be explicitly called out of desired, it is very easy to do and hard to figure out what was causing the problem.

We were doing it as part of a utility block that got copied to relevant projects. I suspect you may see the same thing if you use an allProjects block in your master file to set up publishing but set up dependencies individually…

Because it was an issue with the order of the blocks, that is why afterEvaluate solved the issue for us. (Since others seemed to be struggling with the problem even after trying that, I suspect this is a different issue than some of the others ran into)

Continuing the discussion from Maven-publish pom incorrect unless publications is in afterEvaluate:

I’m having the same problem with Gradle 2.14.1. But my publishing block is after the dependencies block.

The pom produced by maven-publish has no dependencies listed at all.

Hi Scott,

thank you for the report. Could you provide an example where this happens?

I resolved this in another thread.

The problem was how I declared the artifact. I was using:

publishing {
    publications {
    main(MavenPublication) {
            artifact jar
        }
    }
}

instead of:

publishing {
    publications {
        main(MavenPublication) {
            from components.java
        }
    }
}

Only a ‘component’ has the dependency information. A jar is just a file.