Suppose I'm using Gradle for a modular library development. In my root project I have subprojects geometry
, algorithms
, visualizer
, and I'd like to publish a jar artifact of each.
As for now in my root build.gradle
I have the following part:
apply plugin: 'maven-publish'
publishing {
publications {
publishDemos(MavenPublication) {
groupId 'ru.ifmo.ctddev.igushkin.cg'
artifactId 'geometry'
version globalVersion
artifact project(':geometry').tasks.getByName('jar')
}
publishAlgorithms(MavenPublication) {
groupId 'ru.ifmo.ctddev.igushkin.cg'
artifactId 'algorithms'
version globalVersion
artifact project(':algorithms').tasks.getByName('jar')
}
publishVisualizer(MavenPublication) {
groupId 'ru.ifmo.ctddev.igushkin.cg'
artifactId 'visualizer'
version globalVersion
artifact project(':visualizer').tasks.getByName('jar')
}
}
}
My first question: is there a shorter way of describing the publications? For example, I'd like to state that for each subproject I need a publication with the artifactId
set from its name.
Next, my subprojects depend on each other, both algorithms
and visualizer
depend on classes from geometry
, but at this point the jars do not contain the dependencies, and, for example, the user will have to add dependencies to both geometry
and algorithms
if they want to use algorithms
.
So, is there a way for to provide some sort of auto-dependency, so that adding algorithms
would also add geometry
? If yes, how do I do it? If no, what is the idiomatic way of providing modular libraries? Should I assemble jars with dependencies instead?
UPD: Am I right that instead of artifact ...
I should just use from project(':...').components.java
, because it will pick up both artifacts and dependencies? How do I pick dependencies separately if I use artifact ...
?