Stop run, if maven target executed after make fails.

I'm writing an application using the quasar framework. This requires a maven goal to be run to instrument the java class files. I was glad to find that there is an "Execute after make" option, in the "Maven Projects" view.

When I click run, the maven goal is executed, but occasionally will legitimately fail. At this point, I expect IntelliJ IDEA to stop, but instead it continues, wiping the error message, and runs the application.

Is there a way to get IntelliJ IDEA 15 to stop if one of the goals fail?

thanks!

3 comments
Comment actions Permalink

Hi Andrew,

It should work exactly this way - do not run App if "After make" goal execution fails. You can check it using standard maven test goal, just add a failing test to the module.
Which maven goal do you use? Is it something from custom written plugin goal? Does it terninate process with the correct exit code in case of fail?

0
Comment actions Permalink

If I run:

$ mvn

...

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (instrument-classes) on project undertows: An Ant BuildException has occured: Unable to instrument net/bramp/threads/sleep/QuasarSleepHandler$SleepFiber#run()Ljava/lang/Void; because of blocking call to java/lang/Thread#sleep(J)V -> [Help 1]

...


$ echo $?

1

Ah but you may be onto something, if I run:

$ mvn antrun:run

$ echo $?

I always get zero. This is the target I'm telling IntelliJ to run after make.   I will continue to investigate, why running the target directly seems to not produce the error.

0
Comment actions Permalink

Ok, resolved my issue now. This was a maven configuration mistake. When the target was ran specifically from the command line, it did not actually do its job, thus didn't return an error.

For future reference, I had maven config that looked like:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>

    <executions>
        <execution>
            <id>instrument-classes</id>
            <phase>process-classes</phase>

            <configuration>
                <tasks>
                    <property name="ant_classpath" refid="maven.dependency.classpath"/>
                    <taskdef name="instrumentationTask" classname="co.paralleluniverse.fibers.instrument.InstrumentationTask"
                             classpath="${ant_classpath}"/>

                    <instrumentationTask>
                        <fileset dir="${project.build.directory}/classes/" includes="**/*.class"/>
                    </instrumentationTask>
                </tasks>
            </configuration>

            <goals>
                <goal>run</goal>
            </goals>
        </execution>


But due to the non defaut ID listed, that config wouldn't be used when running directly from the CLI.  Now I've transformed my maven to drop the executions section:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>

    <configuration>
        <tasks>
            <property name="ant_classpath" refid="maven.dependency.classpath"/>
            <taskdef name="instrumentationTask" classname="co.paralleluniverse.fibers.instrument.InstrumentationTask"
                     classpath="${ant_classpath}"/>

            <instrumentationTask>
                <fileset dir="${project.build.directory}/classes/" includes="**/*.class"/>
            </instrumentationTask>
        </tasks>
    </configuration>
 
and that seems to work a lot better, with Intellij now halting if that plugin throws an error.
0

Please sign in to leave a comment.