Use a forked exec-maven-plugin instead of maven-antrun-plugin

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.
This commit is contained in:
Trustin Lee 2014-05-23 20:03:14 +09:00
parent 223efc5f99
commit 9961cae7cf
4 changed files with 21 additions and 13 deletions

View File

@ -293,7 +293,7 @@
<goals> <goals>
<goal>run</goal> <goal>run</goal>
</goals> </goals>
<configuration combine.self="override"> <configuration>
<target> <target>
<taskdef resource="net/sf/antcontrib/antlib.xml" /> <taskdef resource="net/sf/antcontrib/antlib.xml" />
<propertyselector property="versions" match="^(${project.groupId}:(?!netty-example)[^:]+:jar)$" select="\1" /> <propertyselector property="versions" match="^(${project.groupId}:(?!netty-example)[^:]+:jar)$" select="\1" />

View File

@ -103,18 +103,21 @@
<build> <build>
<plugins> <plugins>
<!-- run-example.sh invokes this plugin to launch an example. -->
<plugin> <plugin>
<artifactId>maven-antrun-plugin</artifactId> <groupId>kr.motd.maven</groupId>
<artifactId>exec-maven-plugin</artifactId>
<configuration> <configuration>
<target> <executable>${java.home}/bin/java</executable>
<taskdef resource="net/sf/antcontrib/antlib.xml" /> <commandlineArgs>
<propertyregex ${argLine.common}
property="mergedArgs" regexp="[\r\n\s]+" replace=" " global="true" ${argLine.bootcp}
input="${argLine.common} ${argLine.bootcp} ${argLine.leak} ${argLine.coverage} ${argLine.example}" /> -classpath %classpath
<java classname="${exampleClass}" classpathref="maven.runtime.classpath" fork="true"> ${argLine.leak}
<jvmarg line="${mergedArgs}"/> ${argLine.coverage}
</java> ${argLine.example}
</target> ${exampleClass}
</commandlineArgs>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -857,7 +857,7 @@
<goals> <goals>
<goal>run</goal> <goal>run</goal>
</goals> </goals>
<configuration combine.self="override"> <configuration>
<target> <target>
<taskdef resource="net/sf/antcontrib/antlib.xml" /> <taskdef resource="net/sf/antcontrib/antlib.xml" />
@ -1070,6 +1070,11 @@
<artifactId>maven-hawtjni-plugin</artifactId> <artifactId>maven-hawtjni-plugin</artifactId>
<version>1.10</version> <version>1.10</version>
</plugin> </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. <!-- Workaround for the 'M2E plugin execution not covered' problem.
See: http://wiki.eclipse.org/M2E_plugin_execution_not_covered --> See: http://wiki.eclipse.org/M2E_plugin_execution_not_covered -->

View File

@ -91,5 +91,5 @@ fi
cd "`dirname "$0"`"/example cd "`dirname "$0"`"/example
echo "[INFO] Running: $EXAMPLE ($EXAMPLE_CLASS $EXAMPLE_ARGS)" 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"