I am publishing an artifact A to a self maintained maven repository on GitHub. The project has several transitive dependencies B, C, D which are hosted in different repositories. The dependencies B, C, D are specified in the gradle generated pom.xml (uploadArchives) of A but not the paths to the repositories. Therefore, the transitive dependencies B, C, D are not downloaded when A is specified as a dependency in another project.
Is it possible to tell gradle to include the urls of the maven repositories of B, C, D in the pom.xml of A?
The way to do this is to customize the generated POM. Here is an example, assuming that the maven
plugin is used for publishing:
uploadArchives {
repositories {
mavenDeployer {
// add further information to the generated POM
// syntax maps 1:1 to POM syntax
pom.project {
// could also generate this programmatically
// based on the repos declared in the build
repositories {
repository {
id 'myrepo'
url 'http//my.repo.com'
}
}
}
}
}
}
The new, incubating maven-publish
plugin offers a similar hook.
Note that Gradle itself doesn't honor repositories declared in POMs when resolving dependencies, but only repositories declared by your build. Also check out http://www.sonatype.com/people/2009/02/why-putting-repositories-in-your-poms-is-a-bad-idea/.