3

I'm launching a (legacy) Makefile with the exec-maven-plugin

However, if the Makefile fails, the exec-maven-plugin does NOT fail and the build continues and reports success

The maven log shows the following:

[INFO] Creating target /src/gateways/src/c++/smtp/smtp-logview/target/bin/logview
[INFO] /usr/bin/ld: cannot find -lstlport
[INFO] collect2: ld returned 1 exit status
[INFO] logview - 0 error(s), 0 warning(s)

But then, Maven continues and it looks like the exec-maven-plugin is not seeing this as an error

How can I get the plugin to fail when the Makefile returns this error

The pom configuration is:

<!--
    Plugin for launching the Makefile to create smtp-logview .a lib
-->
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>exec-maven-plugin</artifactId>
    <executions>

        <execution>
            <id>smtp-logview</id>
            <phase>compile</phase>
            <goals>
                <goal>exec</goal>
            </goals>
            <configuration>
                <executable>/usr/bin/make</executable>
                <workingDirectory>${basedir}/src/main/c++/com/compname/smtp/logview/</workingDirectory>
                <arguments>
                    <argument>--file=logview.mak</argument>
                    <argument>clean</argument>
                    <argument>all</argument>
                    <argument>BASEDIR=${basedir}</argument>
                    <argument>TECHNOLOGY=${technology-directory}</argument>
                    <argument>TARGETDIR=${project.build.directory}</argument>
                    <argument>CS_CUSTOM_BUILD=${basedir}/custom.mak</argument>
                    <argument>SYS_LIB=${system-lib-directory}</argument>
                </arguments>
            </configuration>
        </execution>

    </executions>
</plugin>
  • Will make give back the correct return code if the ld fails? – khmarbaise Apr 22 '14 at 09:24
  • khmarbaise - thanks for the suggestion and I think you may be correct. The shell command that invokes the linker returns a 0 / success result. Is there a way to get at the linker exit code ? – user3559446 Apr 22 '14 at 11:28
  • you can call `set -e` in your make so that every command that fails, stops your make script. See [this question](http://stackoverflow.com/q/821396/562363) for further information – Absurd-Mind Apr 22 '14 at 11:39
  • I've traced the problem to a 'set -o pipefail' command – user3559446 Apr 22 '14 at 12:24
  • I removed the -o option because the OS complained about an illegal option; it turns out that without the -o option the 'set pipefail' does not propagate the error. Restoring the -o option allows the error to be propagated and Maven to fail. Why the OS no longer complains about -o being an illegal option is as yet unknown – user3559446 Apr 22 '14 at 12:26

0 Answers0