Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using Gradle wrapper (./gradlew.sh) with subprojects

Tags:

gradle

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

What's the idiomatic way to do this?

Should I configure the wrapper in every subproject by adding the following code to build.gradle in the root?

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

But then, do I check all the gradlew.bat, gradlew.sh, gradle/wrapper/gradle-wrapper.jar, etc. files from all the subproject directories into version control?? That seems inefficient, but if I don't then how can I execute ./gradlew.sh in a sub project directory? What is the preferred way to use gradle wrapper in a subproject?

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

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

like image 661
Jason Avatar asked Jan 13 '15 19:01

Jason


People also ask

How do I use Gradle wrapper command?

To run a Gradle command, open a command window on the project folder and enter the Gradle command. Gradle commands look like this: On Windows: gradlew <task1> <task2> … ​ e.g. gradlew clean allTests.

Do I need Gradle to run gradlew?

1. No need to install gradle locally. The gradlew script doesn't rely on a local Gradle installation. It goes and fetches a Gradle installation from the internet the first time it runs on your local machine, and caches it.

What is difference between Gradle and gradlew?

The difference lies in the fact that ./gradlew indicates you are using a gradle wrapper. The wrapper is generally part of a project and it facilitates installation of gradle.

What is gradlew wrapper?

Overview. Gradle is commonly used by developers to manage their project's build lifecycle. It's the default choice of build tool for all new Android projects. In this tutorial, we'll learn about Gradle Wrapper, an accompanying utility that makes it easier to distribute projects.


1 Answers

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

You can run the ./gradlew tasks --all to verify the wrapper can see the subproject tasks

Or you can run the ./gradlew <subproject_name>:tasks command to view just one subproject's tasks.

like image 92
jeffl8n Avatar answered Sep 23 '22 20:09

jeffl8n