Did the generated task name for generating Pom files in the maven-publish plugin change in 2.2-nightly?

I was trying out the 2.2-nightly for the sonar runner updates, but my build failed because it could no longer find the ‘generatePomFileFor*Publication’ tasks.

* What went wrong:
A problem occurred configuring project ':subProject'.
> Could not find property 'generatePomFileForMavenJavaPublication' on project ':subProject'.

Nothing in my build files changed, so I am not sure why this is happening.

If it helps, the part it is failing on is within an afterEvaluate block:

afterEvaluate {
    generatePomFileForMavenJavaPublication.dependsOn 'someOtherTask'
  // <--- Failing here
}

Hi Matt,

Thanks for checking out the nigthly build and reporting this to us. This is a breaking change introduced recently. We will add information to the release notes about it soon.

From now on you will have to put this logic in ‘model {}’ block like this:

model {
    tasks.generatePomFileForMavenJavaPublication {
        dependsOn 'someOtherTask'
    }
}

Please let me know if you’re interested in detailed explanation why that is and I will provide it.

I’d like to know more.

In particular, is it possible to access this model magic from the Java API, or is it a groovy/DSL-only thing?

Thanks

That worked, thank you very much.

Yes, it is possible to contribute to model configuration from a plugin class.

Please be aware that this stuff is incubating and under active development so you should expect breaking changes. It is also undocumented as of now(this should change for 2.2) so you will have to dig into some code and tests to understand how to use it.

Basically the trick is to add a static, @RuleSource annotated class to a plugin which can have methods annotated with @Model, @Mutate and @Finalize. As an example have a look at MavenPublishPlugin.Rules class. Also, you might get better understanding of usage and limitations from integration tests for modelCore project.

Give me a shout if you have any more questions.

Thanks, appreciate it.