Maven package phase equivalent in Gradle
Asked Answered
E

3

10

I'm building a Spring Boot project with Gradle migrating it from Maven. I wonder what Gradle task is doing the same thing as the package phase in Maven.

Thank you!

Eleven answered 19/3, 2018 at 20:7 Comment(1)
also see stackoverflow.com/questions/6122252Locklear
P
9

Maven build is based on build cycle phases, Gradle build is based on tasks and tasks dependencies.

Maven package phase can execute multiple plugin goals that is configured up to the package phase in the lifecycle. The same thing can be achieve with gradle using tasks(and maybe creating task dependencies to integrate them in to default build)

If you only care about running unit tests and creating jar file; gradle way would be gradle build. If other actions are also concern in the maven package phase, additional gradle tasks should be added.

Perez answered 19/3, 2018 at 20:44 Comment(0)
L
12

See the diagram from the java plugin documentation here

java plugin tasks

As Matej Marconak said:

  • If you want to run tests you'd run gradle build
  • If you just want to build the jar you'd run gradle assemble
Lisettelisha answered 21/3, 2018 at 8:46 Comment(0)
P
9

Maven build is based on build cycle phases, Gradle build is based on tasks and tasks dependencies.

Maven package phase can execute multiple plugin goals that is configured up to the package phase in the lifecycle. The same thing can be achieve with gradle using tasks(and maybe creating task dependencies to integrate them in to default build)

If you only care about running unit tests and creating jar file; gradle way would be gradle build. If other actions are also concern in the maven package phase, additional gradle tasks should be added.

Perez answered 19/3, 2018 at 20:44 Comment(0)
S
2

You can use gradle assemble or gradle build.

Squirt answered 19/3, 2018 at 20:11 Comment(3)
but assemble doesn't run tests as far as I seeEleven
gradle assemble only create .jar/.war, gradle build run test.Squirt
yeah, I mean something as close as possible:) ok, I guess, I'm fine with gradle buildEleven

© 2022 - 2024 — McMap. All rights reserved.