Cannot skip repackage goal of spring-boot-maven-plugin
Asked Answered
M

2

8

I have a multi-module Maven project that contains an application consisting of several Spring Boot services. I am trying to set up integration and end-to-end tests for the services and am using a combination Maven plugins to orchestrate this.

I have one module that is intended to contain only end-to-end tests for groups of collaborating services that perform some work. It contains only test code and resources. I'm using the failsafe plugin (org.apache.maven.plugins:maven-failsafe-plugin) to perform the integration tests, the Spring Boot Maven plugin (org.springframework.boot:spring-boot-maven-plugin) to start and stop the "main" service and the Maven exec plugin (org.codehaus.mojo:exec-maven-plugin) to start the other services that are being used in the end-to-end tests.

I'm running into a problem that appears to be related to the repackage goal of the Spring Boot plugin. The e2e module has nothing that needs to be repackaged, so I want to skip this goal. Shouldn't be too hard, right?

      <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <executions>
          <execution>
            <goals>
              <goal>repackage</goal>
            </goals>
            <configuration>
              <skip>true</skip>
            </configuration>
          <execution>
          ...

Well, this doesn't work. It runs repackage despite this.

The problem with this, is that the Maven build fails because it can't find a "main" class to repackage (as an executable jar, I believe). Well, there is no main class for this module.

The more important question is: why is <skip>true</skip> being ignored?

Maxon answered 25/2, 2020 at 14:4 Comment(5)
Can you add <id>repackage</id> after execution above <goals>.Modiste
That did the trick. Apparently there is significance to the id element that I did not suspect. I thought it was just a convenient way to "label" items in a more human-readable way. I assume that the id element content of "repackage" is key.Maxon
Can you mark my suggestion as answered?Modiste
How do I do that? To my knowledge, you actually have to post your answer as an answer.Maxon
i thought execution-id acts only as a label to distinguish between different executions, but it seems this is depending on the plugin used like Spring plugin which expects the execution-id to be exactly "repackage". Thanks this helped to fix my problem.Willtrude
M
14

You need to add <id>repackage</id> after the <execution> tag and before the <goals> tag.

So the whole thing becomes:

<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
    <executions>
        <execution>
            <id>repackage</id>
            <goals>
                <goal>repackage</goal>
            </goals>
            <configuration>
                <skip>true</skip>
            </configuration>
        </execution>
    </executions>
</plugin>
Modiste answered 25/2, 2020 at 16:17 Comment(0)
E
2

I was also facing the same issue. I resolved it by using <pluginManagement> tag above <plugins>

      <pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                    <configuration>
                        <skip>true</skip>
                    </configuration>
                </execution>
            </executions>
        </plugin>
    </plugins>
    </pluginManagement>
Embalm answered 27/5, 2021 at 13:5 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.