Generate pom task not working with Gradle 7.4

Hi All

We have upgraded our Spring boot application from Gradle 6.8.3 version to 7.4, but after upgrading generatePom task of gradle has started failing and giving below error:

Execution failed for task

Could not find method pom() for arguments on task of type org.gradle.api.DefaultTask.

The generatePom task is written like this:
task generatePom {
doLast {
pom().writeTo(“.pom”)
}
}

Could someone please suggest how this can be resolved in Gradle 7.4

The pom() method that you are using was provided by the legacy maven plugin. Since this plugin has been removed in Gradle 7, the method is no longer available. The maven plugin was replaced by the maven-publish plugin, which does not provide a comparable replacement for pom(). The maven-publish plugin automatically creates pom generation tasks based on the configured publications.
https://docs.gradle.org/current/userguide/publishing_maven.html#publishing_maven:tasks

1 Like

Thanks for sharing this information. It is of great help!!!