3

This question may be more related to Maven in general than Spring Boot but there is something I don't understand.

I'm using Spring boot maven plugin. It has different goals (help, repackage, start etc...)

When it comes for example to repackage goal, I can see that on official Spring documentation :

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 

Is this goal already bound to a specific phase of Maven's lifecycle ?

Basically what is the point of the snippet above ? Why not just using this :

<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build> 

And If I need to run repackage goal : just doing spring-boot:repackage

2 Answers 2

3

This is as explicit as it can get in the documentation, right below the example you linked, as seen here:

The example above repackages a jar or war archive that is built during the package phase of the Maven lifecycle...

Of course bonding that goal to the package phase, means that the typical mvn clean install will run all other goals from all other phases, up to package (validate, compile, test); unlike your spring-boot:repackage.

Sign up to request clarification or add additional context in comments.

3 Comments

OK thanks but if spring-boot:repackage is already bound to package phase, why secifying it again in pom.xml with <execution> tags ?
@AntonBoarf it is not already bound, the documentation and sample says that it does bound it when you add that goal.
OK thanks, I thought when you wanted to bind you had to add a <phase>package</phase> tag inside the <execution>
1

Check this answer out: https://stackoverflow.com/a/56184071/10335389

You can still add spring-boot:repackage to Maven's package command but it is just convenient to have the Jar file executable when using mvn package.

This might be a handy resource to look at: https://www.baeldung.com/spring-boot-repackage-vs-mvn-package

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.