I have a project which has a SharedCode
(Java) module and secondly an Android
(Android library) module which depends on the SharedCode
module. I've previously been using the maven
plugin in my build.gradle
files and I've been using the uploadArchives
task of that plugin to publish the artifacts from my two modules. This has worked and produced pom files which reflect the dependencies in my build.gradle
files.
I thought I'd replace the old maven
plugin with the new maven-publish
plugin. However, I see that the pom files produced by the maven-publish
plugin contain no dependencies. Is this by design, is this a bug in the plugin or am I using the plugin incorrectly?
The build.gradle
file in my SharedCode
module is as follows:
apply plugin: 'java'
apply plugin: 'maven-publish'
group = "${projectGroupId}"
version = "${projectVersionName}"
dependencies {
compile 'com.google.guava:guava:18.0'
}
publishing {
publications {
SharedCode(MavenPublication) {
groupId "${projectGroupId}"
artifactId 'SharedCode'
version "${projectVersionName}"
artifact("$buildDir/libs/SharedCode-${projectVersionName}.jar")
}
}
}
The build.gradle
file in my Android
module is as follows:
apply plugin: 'com.android.library'
apply plugin: 'maven-publish'
group = "${projectGroupId}"
version = "${projectVersionName}"
android {
// android stuff here...
}
dependencies {
compile project(':SharedCode')
}
publishing {
publications {
Android(MavenPublication) {
groupId "${projectGroupId}"
artifactId 'Android'
version "${projectVersionName}"
artifact "$buildDir/outputs/aar/Android-release.aar"
}
}
}
The pom file created from the SharedCode
module is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.sdk</groupId>
<artifactId>SharedCode</artifactId>
<version>0.0.2</version>
</project>
The pom file created from the Android
module is as follows:
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany.sdk</groupId>
<artifactId>Android</artifactId>
<version>0.0.2</version>
<packaging>aar</packaging>
</project>
Note the absence of the dependencies in the pom files.
artifact...
line forfrom components.java
in theSharedCode
module fixes the problem for theSharedCode
module. Just need to find a solution now for theAndroid
module. Will follow your leads to see if that leads to a solution. Will get back to you. – Moy