Trouble changing subproject name for nested subproject

I’m trying to implement a Gradle build to replace an existing Maven build. The result with the Gradle build has to be as close as possible to what the Maven build produces.

Some of the Maven projects produce artifact names that are different from their folder name, so I have to use the unfortunate practice of specifying the “name” property for the project in the root settings.gradle, and not in the subproject build.gradle itself.

This practice worked when I first tried it, with a subproject one level below the root.

I now have to do this with a subproject that is two levels below the root, but what I’ve done isn’t making any difference. I ran the build in the subproject itself, which I assume transparently looks up the directory hierarchy until it finds a “settings.gradle” file. The resulting archive name was based on the folder name, not my modified name.

In the root folder, this is my “settings.gradle” file:

include ':toaster'
include ':toaster-config'
include ':toaster-consumer'
include ':toaster-provider'
include ':toaster-it'
include ':clustering-testapp:configuration'
include ':clustering-testapp:model'
include ':clustering-testapp:provider'

// Change project name so archive name matches maven build.
// Unfortunately, this can't be done (yet) in the subproject build.gradle file.
project(":toaster").name                = "sample-toaster"
project(":clustering-testapp:configuration").name    = "clustering-it-config"

When I run a build in the “toaster” folder, it produces an archive name beginning with “sample-toaster”. When I run the build in the “clustering-testapp/configuration” folder, it produces an archive name beginning with “configuration”, not “clustering-it-config”.

I made a dumb mistake here, as the folder name is “clustering-test-app”. Once I fixed that, it let me focus on my next issues, which have nothing to do with this.

1 Like