Using Gradle Wrappers (./gradlew.sh) with Subprojects

I have a multi-project build with several subprojects and I want to use the gradle wrapper.

What is the idiomatic way to do this?

Should I configure the shell in each subproject by adding the following code in build.gradle to the root directory?

 allprojects { task wrapper(type: Wrapper) { gradleVersion = '2.2' } } 

But then I check all the files gradlew.bat , gradlew.sh , gradle/wrapper/gradle-wrapper.jar , etc. from all subprojects to version control? This seems inefficient, but if I do not, how can I execute ./gradlew.sh in the subprojects directory? What is the preferred way to use gradle wrapper in a subproject?

Do developers just use the gradle installed on the file system for this case?

The most important question is the first: what is the idiomatic way to do this?

+7
gradle
source share
1 answer

You should just have a shell task outside the allprojects block, so you only have one gradlew.bat , gradlew.sh and gradle/wrapper/gradle-wrapper.jar at the top level of the project structure.

You can run ./gradlew tasks --all to make sure that the shell can see subproject tasks

Or you can run the ./gradlew <subproject_name>:tasks command to view only one subproject task.

+7
source share

All Articles