2

Using the spring-boot-maven-plugin both the run and repackage goal cause my compile and test stage to be re ran e.g.

mvn clean package spring-boot:run

and you see two compile and test runs...

in the maven debug out put I can see

...
[DEBUG] Goal:          org.springframework.boot:spring-boot-maven-plugin:1.0.2.RELEASE:repackage (default)
[DEBUG] Style:         Regular
[DEBUG] Configuration: <?xml version="1.0" encoding="UTF-8"?>
<configuration>
  <finalName default-value="${project.build.finalName}"/>
  <outputDirectory default-value="${project.build.directory}"/>
  <project default-value="${project}"/>
</configuration>
[DEBUG] --- init fork of myapp:1.0-SNAPSHOT for     org.springframework.boot:spring-boot-maven-plugin:1.0.2.RELEASE:run (default-cli) ---
[DEBUG] Dependencies (collect): []
[DEBUG] Dependencies (resolve): [compile, test]
[DEBUG] -----------------------------------------------------------------------

And looking at the plugin source code classes, RunMojo amd RepackageMojo I see

@Mojo(name = "run", requiresProject = true, defaultPhase = LifecyclePhase.VALIDATE, requiresDependencyResolution = ResolutionScope.TEST)
@Execute(phase = LifecyclePhase.TEST_COMPILE)
public class RunMojo extends AbstractMojo {

Thinking that the @Execute has something to do with it ?

Thanks

2 Answers 2

3

Yes. Why don't you just use "mvn spring-boot:run"? As far as I know, that's just the way Maven works.

2
  • A better example is the repackage goal, by default it is attached to the maven verify stage (which itself ensures the previous phases compile, package etc have been completed). So if you run 'mvn clean install' you get phases clean > compile > test > package > verify > then spring-boot:repackage kicks off > compile > test > install...
    – spstorey
    Commented May 22, 2014 at 12:47
  • It's the same story for that - you have to tie a Maven goal to a specific lifecycle phase. Normally you don't run spring-boot:repackage as a standalone goal, you tie it to the "package" lifecycle in your pom (the starter-parent does that for you), and then it doesn't need to re-execute the earlier goals.
    – Dave Syer
    Commented May 22, 2014 at 13:11
0

My bad...it is actually the cobertura plugin doing this which is understandable as it needs to recompile the source to instrument it for coverage.

Not the answer you're looking for? Browse other questions tagged or ask your own question.