Skip to content

Commit

Permalink
Use a forked exec-maven-plugin instead of maven-antrun-plugin
Browse files Browse the repository at this point in the history
Motivation:

maven-antrun-plugin does not redirect stdin, and thus it's impossible to
run interactive examples such as securechat-client and telnet-client.
org.codehaus.mojo:exec-maven-plugin redirects stdin, but it buffers
stdout and stderr, and thus an application output is not flushed timely.

Modifications:

Deploy a forked version of exec-maven-plugin which flushes output
buffers in a timely manner.

Result:

Interactive examples work.  Launches faster than maven-antrun-plugin.
  • Loading branch information
trustin committed May 23, 2014
1 parent 223efc5 commit 9961cae
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@
<goals>
<goal>run</goal>
</goals>
<configuration combine.self="override">
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<propertyselector property="versions" match="^(${project.groupId}:(?!netty-example)[^:]+:jar)$" select="\1" />
Expand Down
23 changes: 13 additions & 10 deletions example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,18 +103,21 @@

<build>
<plugins>
<!-- run-example.sh invokes this plugin to launch an example. -->
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<groupId>kr.motd.maven</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<propertyregex
property="mergedArgs" regexp="[\r\n\s]+" replace=" " global="true"
input="${argLine.common} ${argLine.bootcp} ${argLine.leak} ${argLine.coverage} ${argLine.example}" />
<java classname="${exampleClass}" classpathref="maven.runtime.classpath" fork="true">
<jvmarg line="${mergedArgs}"/>
</java>
</target>
<executable>${java.home}/bin/java</executable>
<commandlineArgs>
${argLine.common}
${argLine.bootcp}
-classpath %classpath
${argLine.leak}
${argLine.coverage}
${argLine.example}
${exampleClass}
</commandlineArgs>
</configuration>
</plugin>
</plugins>
Expand Down
7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@
<goals>
<goal>run</goal>
</goals>
<configuration combine.self="override">
<configuration>
<target>
<taskdef resource="net/sf/antcontrib/antlib.xml" />

Expand Down Expand Up @@ -1070,6 +1070,11 @@
<artifactId>maven-hawtjni-plugin</artifactId>
<version>1.10</version>
</plugin>
<plugin>
<groupId>kr.motd.maven</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.0.0.Final</version>
</plugin>

<!-- Workaround for the 'M2E plugin execution not covered' problem.
See: http://wiki.eclipse.org/M2E_plugin_execution_not_covered -->
Expand Down
2 changes: 1 addition & 1 deletion run-example.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,5 @@ fi

cd "`dirname "$0"`"/example
echo "[INFO] Running: $EXAMPLE ($EXAMPLE_CLASS $EXAMPLE_ARGS)"
exec mvn -nsu compile antrun:run -Dcheckstyle.skip=true -Dantfile=src/antrun/run-example.xml -DargLine.example="$EXAMPLE_ARGS" -DexampleClass="$EXAMPLE_CLASS"
exec mvn -q -nsu compile exec:exec -Dcheckstyle.skip=true -DargLine.example="$EXAMPLE_ARGS" -DexampleClass="$EXAMPLE_CLASS"

0 comments on commit 9961cae

Please sign in to comment.