subprojects {
tasks.withType(Jar) {
baseName = "datalogger-$project.name"
}
}
Alternatively, you could set archivesBaseName
in a similar way.
Question
I started using Gradle for multi-projects. However, the Gradle manual does not give many hints for the best practice regarding the naming of subprojects.
I have the multiproject with the name 'datalogger' that consists of two subprojects 'core' and 'entries':
- datalogger
--- core
--- entries
When I build the project, I get the jars 'core-1.0.jar' and 'entries-1.0.jar'. How do I manage that the naming is 'datalogger-core-1.0.jar' and 'datalogger-entries-1.0.jar' in a generic way? I know, I could change the name of the folders as follows:
- datalogger
--- datalogger-core
--- datalogger-entries
But that would not be regarded as good approach, I assume. I could also manually change the archivesBaseName
of each project. But I would rather find a way to do this in a generic way, as mentioned before.
Solution
subprojects {
tasks.withType(Jar) {
baseName = "datalogger-$project.name"
}
}
Alternatively, you could set archivesBaseName
in a similar way.
OTHER TIPS
We're handling this by renaming the subprojects, new names will be taken into account when creating/naming your jars: ref: how to rename the project in gradle instead of using folder name?
include 'xxx', 'yyy'
rootProject.children.each { it.name = rootProject.name + it.name }