Gradle Naming Multiple Projects: How can I set a property (like baseName) for all sub-projects?

I started using Gradle for multi-projects. However, the Gradle manual doesn't provide a lot of best practice advice regarding naming subprojects.

I have a multiproject named "datalogger" which consists of two subprojects "core" and "write":

- datalogger
--- core
--- entries

      

When I create a project, I get the core "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 general? I know I could change the name of the folders like this:

- datalogger
--- datalogger-core
--- datalogger-entries

      

But this is not considered a good approach, I suppose. I could also manually change archivesBaseName

each project. But I would rather find a way to do it in a generic way, as mentioned earlier.

+3


source to share


2 answers


subprojects {
    tasks.withType(Jar) {
        baseName = "datalogger-$project.name"
    }
}

      



Alternatively, you can install in a archivesBaseName

similar way.

+8


source


We handle this by renaming subprojects, new names will be taken into account when creating / naming your flasks: ref: how to rename project to gradle instead of folder name?



include 'xxx', 'yyy'
rootProject.children.each { it.name = rootProject.name + it.name }

      

+1


source







All Articles