Reduce the execution time of maven-antrun-plugin

Related issue: #2508

Motivation:

The '<exec/>' task takes unnecessarily long time due to a known issue:

- https://issues.apache.org/bugzilla/show_bug.cgi?id=54128

Modifications:

- Reduce the number of '<exec/>' tasks for faster build
- Use '<propertyregex/>' to extract the output

Result:

Slightly faster build
This commit is contained in:
Trustin Lee 2014-08-13 15:41:42 -07:00
parent f1c757c089
commit 5c24ca2216

62
pom.xml
View File

@ -885,53 +885,31 @@
<taskdef resource="net/sf/antcontrib/antlib.xml" />
<!-- Get the information about the latest commit -->
<exec executable="git" outputproperty="gitOutput.shortCommitHash" resultproperty="gitExitCode.shortCommitHash" failonerror="false" failifexecutionfails="false">
<exec
executable="git" outputproperty="gitOutput.lastCommit" resultproperty="gitExitCode.lastCommit"
failonerror="false" failifexecutionfails="false">
<arg value="log" />
<arg value="-1" />
<arg value="--format=format:%h" />
</exec>
<if>
<equals arg2="0" arg1="${gitExitCode.shortCommitHash}" />
<then>
<property name="shortCommitHash" value="${gitOutput.shortCommitHash}" />
</then>
<else>
<property name="shortCommitHash" value="0" />
</else>
</if>
<exec executable="git" outputproperty="gitOutput.longCommitHash" resultproperty="gitExitCode.longCommitHash" failonerror="false" failifexecutionfails="false">
<arg value="log" />
<arg value="-1" />
<arg value="--format=format:%H" />
</exec>
<if>
<equals arg2="0" arg1="${gitExitCode.longCommitHash}" />
<then>
<property name="longCommitHash" value="${gitOutput.longCommitHash}" />
</then>
<else>
<property name="longCommitHash" value="0000000000000000000000000000000000000000" />
</else>
</if>
<exec executable="git" outputproperty="gitOutput.commitDate" resultproperty="gitExitCode.commitDate" failonerror="false" failifexecutionfails="false">
<arg value="log" />
<arg value="-1" />
<arg value="--format=format:%cd" />
<arg value="--format=format:%h %H %cd" />
<arg value="--date=iso" />
</exec>
<if>
<equals arg2="0" arg1="${gitExitCode.commitDate}" />
<then>
<property name="commitDate" value="${gitOutput.commitDate}" />
</then>
<else>
<property name="commitDate" value="1970-01-01 00:00:00 +0000" />
</else>
</if>
<propertyregex
property="shortCommitHash" input="${gitOutput.lastCommit}"
regexp="^([0-9a-f]+) .*$" select="\1" casesensitive="true"
defaultValue="0" />
<propertyregex
property="longCommitHash" input="${gitOutput.lastCommit}"
regexp="^[0-9a-f]+ ([0-9a-f]{40}) .*$" select="\1" casesensitive="true"
defaultValue="0000000000000000000000000000000000000000" />
<propertyregex
property="commitDate" input="${gitOutput.lastCommit}"
regexp="^[0-9a-f]+ [0-9a-f]{40} (.*)$" select="\1" casesensitive="true"
defaultValue="1970-01-01 00:00:00 +0000" />
<exec executable="git" outputproperty="gitOutput.repoStatus" resultproperty="gitExitCode.repoStatus" failonerror="false" failifexecutionfails="false">
<!-- Get the information abount whether the repository is clean or dirty -->
<exec
executable="git" outputproperty="gitOutput.repoStatus" resultproperty="gitExitCode.repoStatus"
failonerror="false" failifexecutionfails="false">
<arg value="status" />
<arg value="--porcelain" />
</exec>