Ingo Kegel
Ingo Kegel

Reputation: 48025

Reuse code in multiple settings.gradle

I have several multi-project builds that have a lot of common code in settings.gradle. How can I factor this code out to a separate file?

I have tried to use GroovyShell, but I cannot see how to configure the bindings so that method calls go into the surrounding Settings class.

Upvotes: 2

Views: 671

Answers (2)

Ingo Kegel
Ingo Kegel

Reputation: 48025

In the meantime, I found out that you can call

apply from: file('otherFile')

in settings.gradle, just like in projects. My problem is solved with that.

Upvotes: 2

akhikhl
akhikhl

Reputation: 2578

Do one of the following:

  • Specify gradle file on the command line. The command line option is -I or --init-script followed by the path to the script. The command line option can appear more than once, each time adding another init script.

  • Put a file called init.gradle in the USER_HOME/.gradle/ directory.

  • Put a file that ends with .gradle in the USER_HOME/.gradle/init.d/ directory.

  • Put a file that ends with .gradle in the GRADLE_HOME/init.d/ directory, in the Gradle distribution.

More information is here: http://www.gradle.org/docs/current/userguide/init_scripts.html

Upvotes: 0

Related Questions