I want to publish a maven artifact from a project which includes all the classes from the submodules (like a fatJar) instead of having them as dependencies in the pom file in the published artifact.
Assuming I have a gradle project setup like
root
- moduleToPublish
- dependendencyOne
- dependendencyTwo
and I want to publish an artifact for moduleToPublish
, I setup its buid.gradle
like below (note the direct dependencies on the other submodules)
dependencies {
compile project(':dependencyOne')
compile project(':dependencyTwo')
compile other3PMavenDependencies...
}
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
}
When I run ./gradlew :moduleToPublish:publish
, only classes from moduleToPublish
are included in the artifact whereas the submodule dependencies land in the pom file along with the 3p dependencies.
In my case though, I would like to have the artifact include classes from those submodules as well and I am not sure how to get there. This is because I want all my consumers to be able to consume a single artifact that includes all dependencies from my project instead of me publishing the individual dependencies and then have the consumers use them separately. I have these modules split in gradle though because internal modules use parts of them at different times - so I do not want to merge them as a single gradle module.
I tried artifact ':dependencyOne'
assuming it would use the MavenArtifact plugin but that only complained about more than one artifact being published. Any help here would be great.