Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 602
Xelian Avatar asked Jan 12 '23 03:01

Xelian


1 Answers

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.

like image 61
Oliver Charlesworth Avatar answered Jan 20 '23 15:01

Oliver Charlesworth