Search code examples
mavenmaven-3maven-exec-plugin

How to continue and not fail build on error in Exec Maven Plugin execution?


How can the maven build be made to continue despite an error in one of the execution added by the Maven exec plugin?

https://www.mojohaus.org/exec-maven-plugin/usage.html


Solution

  • Example solution using success code:

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>3.0.0</version>
      <executions>
        <execution>
          <id>docker-rmi</id>
            <phase>clean</phase>
            <goals>
              <goal>exec</goal>
            </goals>
            <configuration>
              <executable>docker</executable>
              <workingDirectory>${project.basedir}</workingDirectory>
              <arguments>
                <argument>rmi</argument>
                <argument>${project.groupId}/${project.artifactId}:${project.version</argument>
              </arguments>
              <successCodes>
                <successCode>0</successCode>
                <successCode>1</successCode>
              </successCodes>
            </configuration>
        </execution>
      </executions>
    </plugin>