I have modified my build.gradle in a way that I get a custom jar file that copies in class files from a sibling project like this:
configurations {
localCompile.transitive = false
compile.extendsFrom(localCompile)
}
dependencies {
localCompile project(":shared")
}
jar {
from {
configurations.localCompile.collect { it.isDirectory() ? it : zipTree(it) }
}
}
This creates a jar file that has the contents of this project aswell as the contents of the shared project.
Now I want to publish this to maven so I add the maven-publish plugin and the floolwing publication definition to my build.gradle:
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
This works mostly nicely the only problem is the generated pom lists the shared project alongisde all other dependencies from this project:
<dependency>
<groupId>com.example</groupId>
<artifactId>shared</artifactId>
<version>0.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
Since I’m not publishing that this dependency can never be resolved by any programms that consume my client library.
Instead I also tried to define the publication like this:
mavenJava(MavenPublication) {
artifact jar
}
This works a bit better as it doen’t define any dependencies, but that is also not what I want because the dependencies are there.
A problem both methodes have is that the dependencies that the shared project has don’t appear in the client pom file.
What I would like to do is define a custom maven publication that includes the dependencies of my client library aswell as the dependencies of the shared siblingproject. But not include the sibling project as a dependency.
How can I do this?