Auto-prepend to any subproject name

I experimented with different approaches to auto-prepend the root-projectname to any subproject name.

Let me show what I have: a project / directory called “myProj”


with settings.gradle containing

include 'module1'
include 'module2'


include ':module1'
include ':module2'

What happens:

  • the default behaviour is: the rootProjectname is the same as it’s directory is named, unless you specify the name in settings.gradle = 'myProj'
  • The modules are called as their directories, unless you specify a different name in /settings.gradle per project(':module1').name = 'differentMod1Name'
  • all artifacts are typically called as their project / subproject are named

What I want to archive:

  • any subproject is still settled in a directory just called “moduleXY”
  • their name should auto-prepend by the name of the rootProject

i.e. in this example above:
I expect to get artifacts for myProj-moduleXY

yes, I can define it line by line for each subproject, but this is not the point neither practical if there are lots of
another use-case that have some charms to get it dynamically would be: someone forks of the project but just renames the rootProject, he should just be forced to change one line

Any ideas?! Or it is just impossible?!

Thanks for your input

I use this approach in my settings.gradle

def prefix(prefix) { = prefix
    rootProject.children.each { = "${prefix}-${}" }
include 'core',

directory structure is like


I think this is the same as what you’re looking for

mhh…yeah, indeed I thought I have tried this too and I stumbled to some sort of “prefix()” is not defined error … some sort of user error I think ,)
works fine and as expected.