5

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?

Joseph Gagnon
  • 1,731
  • 3
  • 30
  • 63
  • 4
    Can you add `repackage` after execution above . – Niraj Jha Feb 25 '20 at 15:35
  • 1
    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. – Joseph Gagnon Feb 25 '20 at 15:56
  • Can you mark my suggestion as answered? – Niraj Jha Feb 25 '20 at 16:05
  • 1
    How do I do that? To my knowledge, you actually have to post your answer *as* an answer. – Joseph Gagnon Feb 25 '20 at 16:13
  • 1
    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. – velocity Jul 22 '20 at 13:04

2 Answers2

8

You need to add <id>repackage</id> after execution above goals.

Niraj Jha
  • 455
  • 3
  • 10
1

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>
Deepanshu
  • 169
  • 6