I'm upgrading gradle from 2.6 to 7.0 and after the upgrade I'm getting this error
Could not find method pom() for arguments ... on task of type org.grale.api.DefaultTask.
after I removed the apply plugin: 'maven' which was deprecated and replaced in with 'maven-publish'
I tried to find the replacement for pom method in mavel-publish, but I did not succeed
task createPomFiles {
pom {
project {
groupId groupId
artifactId 'generic-connector'
version version
}
}.writeTo("$project.buildDir/resources/../pom.xml")
}
Relates to: How to make gradle generate a valid pom.xml file at the root of a project for maven users?
To generate a
pom.xmlfile for your Gradle 7.0+ project, I suggest you the following steps:1. Add maven-publish to Plugins Declaration
I reckon you already did that, but for reference:
2. Define a Publication
Make sure to customise the definition for your needs (
groupId,artifactId, etc.). For reference, see Maven Publish Plugin's documentation3. Create a Task to Rename pom.xml (Optional)
As a nice to have feature, you can add a task to rename and copy the generated
pom.xmlfile.Here, I specified a task to copy the default
build//publications/mavenJava/pom-default.xmltobuild/pom.xml. Feel free to modify as you need.4. Finalise the Build with pom.xml Generation
It's not mandatory, but if you wish to have your
pom.xmlgenerated with your builds, append this to yourbuild.gradlefile:If you skip this step, you can generate your pom.xml for your project issuing:
A Minimalistic Full Example