generatePomFileForMavenJavaPublication not in 1.9?

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

org.gradle.api.publish.internal.DefaultPublishingExtension_Decorated@66ef2238

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

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

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

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.
  BUILD FAILED
  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).

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'.

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

That did the trick, thanks!

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

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

Some text on the plugin documentation page, http://www.gradle.org/docs/current/userguide/userguide_single.html#publishing_maven:generate-pom, 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.