maven-plugins/shell/plugin.jelly

100 lines
2.9 KiB
XML

<?xml version="1.0"?>
<project xmlns:j="jelly:core"
xmlns:test="test">
<goal name="shell"
description="Generate Zsh files"
/>
<goal name="shell:zsh"
description="Generate Zsh files">
<j:set var="outputDir" value="${maven.shell.zsh.dir}"/>
<j:if test="${empty outputDir}">
<j:set var="outputDir" value="${maven.build.dir}"/>
</j:if>
<j:file name="${maven.build.dir}/_mavenzsh.tmp" omitXmlDeclaration="true" xmlns="dummy">
<![CDATA[
#compdef maven
case "$service" in
maven)
_arguments -s \
'-D[Define a system property]' \
'-E[Produce logging information without adornments]' \
'-X[Produce execution debug output]' \
'-b[Suppress logo banner]' \
'-d[Set effective working directory]' \
'-e[Produce exception stack traces]' \
'-f[Set project file and effective working directory by finding the project file]' \
'-g[Display available goals]' \
'-h[Display help information]' \
'-i[Display system information]' \
'-o[Build is happening offline]' \
'-p[Set project file]:Project File:_files -g \*.xml' \
'-v[Display version information]' \
':Maven Goals:-@GREATER_THAN@mavengoals' \
':destination directory:_files -/' @AMBERSAND@@AMBERSAND@ return 0
;;
*)
esac
[[ -n "$state" ]] @AMBERSAND@@AMBERSAND@
case "$state" in
mavengoals)
tmp=(
]]>
<j:set var="mavenSession" value="${context.getMavenSession()}"/>
<j:set var="allGoals" value="${mavenSession.getAllGoalNames()}"/>
<j:new var="modList" className="java.util.ArrayList"/>
<j:set var="dummy" value="${modList.addAll(allGoals)}"/>
<j:invokeStatic method="sort" className="java.util.Collections" var="dummy">
<j:arg type="java.util.List" value="${modList}" />
</j:invokeStatic>
<j:forEach var="goal" items="${modList.iterator()}">
<j:set var="escgoal" value='${goal.replaceAll(":","\\:")}'/>
<j:choose>
<j:when test="${maven.shell.zdh.nodesc = 'true'}">
<j:set var="desc" value="${mavenSession.getGoalDescription(goal)}"/>
<j:set var="escdesc" value='${desc.replaceAll(":","\\:")}'/>
<j:set var="point" value="'"/>
<j:set var="pointesc" value='"'/>
<j:set var="escdesc" value='${escdesc.replaceAll(point,pointesc)}'/>
'${escgoal}:${escdesc}'
</j:when>
<j:otherwise>
'${escgoal}'
</j:otherwise>
</j:choose></j:forEach>
<![CDATA[
)
_describe 'Maven Goals' tmp --
;;
esac
]]>
</j:file>
<echo>Now start a new zsh shell</echo>
<filter token="AMBERSAND" value="&amp;"/>
<filter token="LESSER_THAN" value="&lt;"/>
<filter token="GREATER_THAN" value="&gt;"/>
<copy file="${maven.build.dir}/_mavenzsh.tmp" tofile="${outputDir}/_maven" filtering="true"/>
<delete file="${maven.build.dir}/_mavenzsh.tmp"/>
</goal>
</project>