Plugin that allows one to generate files that allows tab completion for maven goals for different shells, currently only zsh is supported
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113099 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
102
shell/plugin.jelly
Normal file
102
shell/plugin.jelly
Normal file
@@ -0,0 +1,102 @@
|
||||
<?xml version="1.0"?>
|
||||
|
||||
<project xmlns:j="jelly:core"
|
||||
xmlns:test="test">
|
||||
|
||||
<!--==================================================================-->
|
||||
<!-- Generate Eclipse .project and .classpath files -->
|
||||
<!--==================================================================-->
|
||||
<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="&"/>
|
||||
<filter token="LESSER_THAN" value="<"/>
|
||||
<filter token="GREATER_THAN" value=">"/>
|
||||
<copy file="${maven.build.dir}/_mavenzsh.tmp" tofile="${outputDir}/_maven" filtering="true"/>
|
||||
<delete file="${maven.build.dir}/_mavenzsh.tmp"/>
|
||||
|
||||
|
||||
|
||||
</goal>
|
||||
|
||||
</project>
|
||||
Reference in New Issue
Block a user