Include/exclude modules conditionally from settings.gradle

I’m trying to include/exclude modules defined in settings.gradle.
I need to include or exclude modules in base on the command line parameter.
do you know if it is possible?
Thanks a lot

You can use project properties that can be set on the command line.

if( hasProperty( 'myprop' ) ) {
    include( 'subproject' )

./gradlew -Pmyprop ...

You can also use the value of the property for whatever you need.

if( hasProperty( 'myprop' ) ) {
    include( myprop )

./gradlew -Pmyprop=subproject ...

Building on Chris’ response:

if (!hasProperty('LibrariesOnly') || !Boolean.parseBoolean(getProperty('LibrariesOnly'))) {
    include ':first-app', ':second-app'


./gradlew -PLibrariesOnly=true build