Search code examples
mavenopenldapexec-maven-plugin

How to define the condition of Maven fail?


I use a Maven plugin called exec-maven-plugin to execute an external LDAP script called ldapmodify. However, even this script is executed successfully, Maven install fails. Here is the output when I run Maven install:

INFO] --- exec-maven-plugin:1.4.0:exec (default) @ entity-matching-bootstrap ---
ldap_connect_to_host: TCP localhost:389
ldap_new_socket: 508
ldap_prepare_socket: 508
ldap_connect_to_host: Trying ::1 389
ldap_pvt_connect: fd: 508 tm: -1 async: 0
attempting to connect: 
connect success
ldap_add: Already exists (68)
adding new entry "dc=my-domain,dc=com"

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 5.969 s
[INFO] Finished at: 2018-10-24T15:29:49-04:00
[INFO] Final Memory: 26M/63M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.4.0:exec (default) on project entity-matching-bootstrap: Command execution failed. Process exited with an error: 68 (Exit value: 68) -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

The result of excecuting the script means that the entry I want to add already exists in LDAP. And the return code 68 is seen as a failure by Maven. Is it possible to set Maven or exec-maven-plugin not fail on this condition? Thanks.


Solution

  • See Exec Maven Plugin / exec:exec:

    successCodes   int[]   Exit codes to be resolved as successful execution for non-compliant applications (applications not returning 0 for success).