equivalents for mvn update and mvn install in gradle

suatCoskun picture suatCoskun · Jun 26, 2017 · Viewed 17.5k times · Source

I am new in gradle hence I have some questions about gradle. Before gradle I worked with maven and in maven there are some commands such as

  • mvn update
  • mvn clean install

With mvn update we download the dependency packages from internet and the other packages from the different projects.

With mvn install we create the jar, war, ear or ejb so what are the equivalents for maven command in gradle?

  • mvn update ~= gradle ...

    and

  • mvn clean install ~= gradle clean ...

Answer

Andrii Abramov picture Andrii Abramov · Jun 26, 2017

Gradle will automatically fetch all required dependencies for you.

Long story short:

mvn update        ~= ./gradlew build --refresh-dependencies
mvn clean install ~= ./gradlew clean build

TL;DR

To force Gradle to redownload dependencies you can execute (How can I force gradle to redownload dependencies?):

./gradlew build --refresh-dependencies

To assemble you project without executing tests (Gradle build without tests):

./gradlew assemble

To completely build you project with test execution:

./gradlew build

You can skip certain tasks by providing -x argument:

./gradlew build -x test