buildgradlemulti-project

Gradle multi-project, change default build filename (build.gradle)


We have a multiproject with a settings.gradle and no build.gradle in the root project.

The default behaviour of gradle is just look up the settings.gradle file on the top dir and read the build.gradle for every project defined before.

My problem is: depending on the environment where the multiproject has been checked out, I want to run as default "build2.gradle" instead of "build.gradle" when running a build from the root project.

What is the best way to do it??

Thanks


Solution

  • ok, done...

    In settings.gradle:

    String myFileName = "build2.gradle"
    
    rootProject.buildFileName = myFileName
    rootProject.children.each { project ->
        project.buildFileName = myFileName
        assert project.projectDir.isDirectory()
        assert project.buildFile.isFile()
    }