generatePomFileForMavenJavaPublication not in 1.9?

(per.bergland) #1

I tried updating from 1.7 to 1.9, but the following no longer works:

publishing {

generatePomFileForMavenJavaPublication {

destination = file("$projectDir/pom.xml")



the error is

org.gradle.api.internal.MissingMethodException: Could not find method generatePomFileForMavenJavaPublication()

for arguments [build_661sf6rpo04vept8ed2s9dvcbj$_run_closure1_closure4_closure6@578be643] on


is there a new way to control where the generated pom file winds up in 1.9?

(Benjamin Muschko) #2

The required configuration was slightly changed. Please see the plugin documentation page.

model {
    tasks.generatePomFileForMavenJavaPublication {
        destination = file("$project.projectDir/pom.xml")

(Matt Bellinger) #3

Sorry to raise an old question, but I get a similar issue when trying to make the pom file generation task depend on another task:

generatePomFileForMavenJavaPublication.dependsOn 'someOtherTask'

This causes:

FAILURE: Build failed with an exception.
  * Where:
Build file 'C:\Projects\someProject\build.gradle' line: 19
  * What went wrong:
A problem occurred evaluating project ':someProject'.
> Could not find property 'generatePomFileForMavenJavaPublication' on project ':someProject'.
  * Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  Total time: 7.691 secs

The previous command worked with Gradle 1.8, and does not work with 1.10 (did not try 1.9 yet).

(Matt Bellinger) #4

If I comment out the dependsOn line and run ‘tasks’, it says the task exists:

Publishing tasks
generatePomFileForMavenJavaPublication - Generates the Maven POM file for publication 'mavenJava'.

(Benjamin Muschko) #5

You will probably have to wrap your code into an afterEvaluate block.

(Matt Bellinger) #6

That did the trick, thanks!

(Justin Ryan) #7

Your other choice is to re-act to the task:

project.tasks.matching { == 'generatePomFileForMavenJavaPublication' }.all {
    it.dependsOn 'someOtherTask'

(per.bergland) #8

Some text on the plugin documentation page,, is now incorrect btw:

“The simplest way to ensure that the publishing plugin is configured when you attempt to access the GenerateMavenPom task is to place the access inside a publishing block, as the above example demonstrates”

The “above example” no longer uses a publishing block, so the section needs to be updated.