Include a config file in settings.gradle


(Oliver) #1

I posted this to StackOverflow (http://stackoverflow.com/questions/41818973/include-config-file-from-settings-gradle) but haven’t gotten a response so thought I’d try here. Feel free to respond here or on SO.

I have two separate projects which I want to keep separate. However, sometimes I want to be able to combine them, briefly, into a composite build. Sometimes it’s nice if I can do that for a while without affecting other devs. So, I want something like this. My main settings.gradle, which would be checked into version control, would look like this:

// normal stuff
if (File('extra-settings.gradle).exists()) {
   // This is what I don't know how to do
   includeOtherSettingsFile('extra-settings.gradle')
}

Then extra-settings.gradle, which is not checked into source control, might look like this:

includeBuild('../anxml') {
    dependencySubstitution {
        substitute module('com.analyticspot.ml:framework') with project(':framework')
    }
}

This way I could add an extra-settings.gradle file to make a temporary composite build. Keep it that way for several commits without affecting other programmers or worrying that I’d accidentally commit my temporary changes to settings.gradle and then, when I’m done, I could just delete it.

I know about Prezi Pride and it seems great but won’t work for our current build (we use buildSrc, rootDir, etc.)

Can it be done?