I am trying to write a gradle plug that will configure uploadArchives task and set the right pom properties for the maven deployer.
I want to convert the following to a java plugin:
uploadArchives {
repositories {
mavenDeployer {
pom.project {
name 'FooBar'
url 'http://foo.bar.com'
inceptionYear '2011'
licenses {
license {
name 'The Apache Software License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
}
}
}
}
I’m doing the following in Plugin apply method:
Upload uploadTask = (Upload) project.getTasks().getByName("uploadArchives");
uploadTask.getRepositories().withType(MavenDeployer.class, new Action<MavenDeployer>() {
@Override
public void execute(MavenDeployer mavenDeployer) {
org.apache.maven.model.Model model = (org.apache.maven.model.Model) mavenDeployer.getPom().getModel();
}
}
Initially this failed due to org.apache.maven.model.Model not being in the classpath. So I added the following to my buildSrc/build.gradle:
dependencies {
compile 'org.apache.maven:maven-model:3.0.4'
}
After this, project compiles, but then it fails with:
A problem occurred evaluating project ':fooBarThing'.
> org.apache.maven.model.Model cannot be cast to org.apache.maven.Model
I am guessing that the versions of maven-model are somehow mismatching, but I was not able to get that sorted. Any suggestions how to proceed?
Thanks,
Aurimas