Gradle build only one module

Gradle

Gradle Problem Overview


I have a multiple module gradle build. I want to execute targets for one module using root. Ex :

gradle build -Pmodule=ABC
gradle jar -Pmodule=ABC
gradle test -Pmodule=ABC
gradle compileJava -Pmodule=ABC
gradle customTask -Pmodule=ABC
etc.

So every target can be run from root specifying the module. Is there a simple way to do this?

Thanks !

Gradle Solutions


Solution 1 - Gradle

To execute a task of a specific subproject, specify its task path. For example:

gradle :ABC:build

The leading : stands for the root project. ABC is the subproject, and build a task in that project.

Solution 2 - Gradle

Found a quick way

gradle build -p moduleA

moduleA is the module's directory.

Above command builds a moduleA and all its submodules, and moduleA should be its path

Solution 3 - Gradle

On Mac OS, the only variant which is working with me :

./gradlew  ABC:build

ABC is the name of module

( It might be working on Linux too )

Solution 4 - Gradle

enter image description here

If your IDE is Android Studio ,there is a simple way.Just choose the module folder you want to compile ,then click Build and choose Make Module 'your module folder'.

Solution 5 - Gradle

In Android Studio, if you need to generate a signed bundle or apk, you can choose the needed module in Module select field: Build > Generate Signed Bundle or APK > choose Android App Bundle or APK > Module

choice

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVirajView Question on Stackoverflow
Solution 1 - GradlePeter NiederwieserView Answer on Stackoverflow
Solution 2 - GradleVirajView Answer on Stackoverflow
Solution 3 - GradleMaher AbuthraaView Answer on Stackoverflow
Solution 4 - Gradleshaojun lyuView Answer on Stackoverflow
Solution 5 - GradlewowandyView Answer on Stackoverflow