Xelian
Xelian

Reputation: 17228

How to use multiple build.gradle files?

My project structure is:

enter image description here

I want user additionally to configure the build using some of the build scripts from specifications dir but the main build script to be used to configure the project as well. Using -b option give the ability to specify another build scrpt different from the default one, but I want this default one to be executed as well. I don't want to use apply from: and to add all scripts because user have to decide what he wants.

So is there a way to tell Gradle to add additional build script - command line with which to configure extra the Project?

Upvotes: 5

Views: 11260

Answers (1)

Oliver Charlesworth
Oliver Charlesworth

Reputation: 272772

If you need this this, you could do something like this:

apply from: "config/specifications/${project.spec}.gradle"

which would then allow users to do e.g.

./gradlew -P spec=example

See https://docs.gradle.org/current/userguide/build_environment.html#sec:gradle_properties_and_system_properties for more details on setting project properties from the command line.

Upvotes: 9

Related Questions