git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113613 13f79535-47bb-0310-9956-ffa450edef68
359 lines
15 KiB
XML
359 lines
15 KiB
XML
<?xml version="1.0"?>
|
|
|
|
<project
|
|
xmlns:j="jelly:core"
|
|
xmlns:ant="jelly:ant"
|
|
xmlns:test="test"
|
|
xmlns:cactus="cactus"
|
|
xmlns:util="jelly:util">
|
|
|
|
<test:dependency-handle/>
|
|
<cactus:dependency-handle/>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse .project and .classpath files -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse"
|
|
description="Generate Eclipse project files"
|
|
prereqs="eclipse:generate-project, eclipse:generate-classpath">
|
|
<ant:echo>Now refresh your project in Eclipse (right click on the project and select "Refresh")</ant:echo>
|
|
</goal>
|
|
|
|
<goal name="eclipse:generate-project"
|
|
description="Generate Eclipse .project file">
|
|
|
|
<ant:echo>Creating ${basedir}/.project ...</ant:echo>
|
|
|
|
<j:file name="${basedir}/.project" prettyPrint="true" xmlns="dummy">
|
|
<projectDescription>
|
|
<name>${pom.artifactId}</name>
|
|
<comment>${pom.description}</comment>
|
|
<projects>
|
|
<j:forEach var="lib" items="${pom.artifacts}">
|
|
<j:set var="eclipseDependency"
|
|
value="${lib.dependency.getProperty('eclipse.dependency')}"/>
|
|
<j:if test="${eclipseDependency == 'true'}">
|
|
<project>${lib.dependency.artifactId}</project>
|
|
</j:if>
|
|
</j:forEach>
|
|
</projects>
|
|
<buildSpec>
|
|
<buildCommand>
|
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
|
<arguments>
|
|
</arguments>
|
|
</buildCommand>
|
|
</buildSpec>
|
|
<natures>
|
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
|
</natures>
|
|
</projectDescription>
|
|
</j:file>
|
|
</goal>
|
|
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse .classpath file -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:generate-classpath"
|
|
description="Generate Eclipse .classpath file">
|
|
|
|
<ant:echo>Creating ${basedir}/.classpath ...</ant:echo>
|
|
|
|
<j:file name="${basedir}/.classpath" prettyPrint="true" xmlns="dummy">
|
|
<classpath>
|
|
<j:if test="${sourcesPresent}">
|
|
<j:set var="srcDir" value="${pom.build.sourceDirectory}"/>
|
|
<j:if test="${ srcDir.startsWith( basedir ) }">
|
|
<ant:echo>Cutting off basedir from sourceDirectory</ant:echo>
|
|
<j:set var="srcDir" value="${srcDir.substring(basedir.length())}"/>
|
|
<!--
|
|
cut off also slash or backslash from basedir.
|
|
Is there a way to make it in one step in Jelly?
|
|
-->
|
|
<j:set var="srcDir" value="${srcDir.substring(1)}"/>
|
|
</j:if>
|
|
<classpathentry kind="src" path="${srcDir}"/>
|
|
</j:if>
|
|
|
|
<j:if test="${unitTestSourcesPresent}">
|
|
<ant:echo>Contains JUnit Tests!</ant:echo>
|
|
<j:set var="testSrcDir" value="${pom.build.unitTestSourceDirectory}"/>
|
|
<j:if test="${ testSrcDir.startsWith( basedir ) }">
|
|
<ant:echo>Cutting off basedir from testSourceDirectory</ant:echo>
|
|
<j:set var="testSrcDir" value="${testSrcDir.substring(basedir.length())}"/>
|
|
<!-- cut off also slash or backslash -->
|
|
<j:set var="testSrcDir" value="${testSrcDir.substring(1)}"/>
|
|
</j:if>
|
|
<classpathentry kind="src" path="${testSrcDir}"/>
|
|
<!-- Here are the rules:
|
|
If the project has maven.eclipse.junit property, add that ver of junit
|
|
If the project has maven.eclipse.junit property and it is empty, don't add junit
|
|
If the project has junit dep, use that.
|
|
Use the test plugin version
|
|
-->
|
|
<j:set var="verX" value="${maven.eclipse.junit}X"/>
|
|
|
|
<j:set var="depVersion">${pom.getPluginContext('maven-test-plugin').getVariable('plugin').getDependency('junit').getVersion()}</j:set>
|
|
|
|
<j:if test="${pom.getDependency('junit') != null}">
|
|
<j:set var="depVersion" value="${pom.getDependency('junit').getVersion()}"/>
|
|
</j:if>
|
|
|
|
<j:if test="${verX != 'X'}">
|
|
<j:set var="depVersion">${maven.eclipse.junit}</j:set>
|
|
</j:if>
|
|
|
|
<j:if test="${verX == 'noneX'}">
|
|
<j:set var="depVersion" value="none"/>
|
|
</j:if>
|
|
|
|
<j:if test="${depVersion != 'none'}">
|
|
<classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-${depVersion}.jar"/>
|
|
</j:if>
|
|
</j:if>
|
|
|
|
<j:set var="cactusSrcDir"
|
|
value="${pom.getPluginContext('maven-cactus-plugin').getVariable('cactus.src.dir')}"/>
|
|
<util:available file="${cactusSrcDir}">
|
|
<j:set var="cactusSourcePresent" value="true"/>
|
|
</util:available>
|
|
|
|
<j:if test="${cactusSourcePresent == 'true'}">
|
|
<ant:echo>Contains Cactus Tests!</ant:echo>
|
|
<j:set var="testSrcDir" value="${cactusSrcDir}"/>
|
|
<j:if test="${ testSrcDir.startsWith( basedir ) }">
|
|
<ant:echo>Cutting off basedir from Cactus source directory</ant:echo>
|
|
<j:set var="testSrcDir" value="${testSrcDir.substring(basedir.length())}"/>
|
|
<!-- cut off also slash or backslash -->
|
|
<j:set var="testSrcDir" value="${testSrcDir.substring(1)}"/>
|
|
</j:if>
|
|
<classpathentry kind="src" path="${testSrcDir}"/>
|
|
|
|
<j:set var="depVersion">${pom.getPluginContext('maven-cactus-plugin').getVariable('plugin').getDependency('cactus').getVersion()}</j:set>
|
|
<classpathentry kind="var" path="MAVEN_REPO/cactus/jars/cactus-${depVersion}.jar"/>
|
|
</j:if>
|
|
|
|
<classpathentry kind="var" path="JRE_LIB" rootpath="JRE_SRCROOT" sourcepath="JRE_SRC"/>
|
|
<j:forEach var="lib" items="${pom.artifacts}">
|
|
<j:set var="eclipseDependency"
|
|
value="${lib.dependency.getProperty('eclipse.dependency')}"/>
|
|
<j:choose>
|
|
<j:when test="${eclipseDependency == 'true'}">
|
|
<classpathentry kind="src" path="/${lib.dependency.artifactId}"/>
|
|
</j:when>
|
|
<j:when test="${lib.dependency.groupId == 'junit'}">
|
|
<!-- ignoring junit dependency as we've already created it -->
|
|
</j:when>
|
|
<j:otherwise>
|
|
<classpathentry kind="var" path="MAVEN_REPO${lib.urlPath}"/>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
</j:forEach>
|
|
|
|
<!-- add the unit test build directory so that any files generated via Maven are available -->
|
|
|
|
|
|
<j:if test="${unitTestSourcesPresent}">
|
|
<j:set var="testOutputDir" value="${maven.eclipse.test.output.dir}"/>
|
|
<j:if test="${empty testOutputDir}">
|
|
<j:set var="testOutputDir"
|
|
value="${pom.getPluginContext('maven-test-plugin').getVariable('maven.test.dest')}"/>
|
|
</j:if>
|
|
<j:if test="${ testOutputDir.startsWith( basedir ) }">
|
|
<ant:echo>Cutting off basedir from testOutputDir</ant:echo>
|
|
<j:set var="testOutputDir" value="${testOutputDir.substring(basedir.length())}"/>
|
|
<!--
|
|
cut off also slash or backslash from basedir.
|
|
Is there a way to make it in one step in Jelly?
|
|
-->
|
|
<j:set var="testOutputDir" value="${testOutputDir.substring(1)}"/>
|
|
</j:if>
|
|
<classpathentry kind="lib" path="${testOutputDir}"/>
|
|
</j:if>
|
|
|
|
<j:set var="outputDir" value="${maven.eclipse.output.dir}"/>
|
|
<j:if test="${empty outputDir}">
|
|
<j:set var="outputDir" value="${maven.build.dest}"/>
|
|
</j:if>
|
|
<j:if test="${ outputDir.startsWith( basedir ) }">
|
|
<ant:echo>Cutting off basedir from outputDir</ant:echo>
|
|
<j:set var="outputDir" value="${outputDir.substring(basedir.length())}"/>
|
|
<!--
|
|
cut off also slash or backslash from basedir.
|
|
Is there a way to make it in one step in Jelly?
|
|
-->
|
|
<j:set var="outputDir" value="${outputDir.substring(1)}"/>
|
|
</j:if>
|
|
<classpathentry kind="output" path="${outputDir}"/>
|
|
</classpath>
|
|
</j:file>
|
|
|
|
|
|
</goal>
|
|
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse mappings for Maven goals -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:external-tools"
|
|
description="Generate an Eclipse external tool for each goal">
|
|
<ant:mkdir dir="${maven.build.dir}/eclipse/"/>
|
|
<j:set var="toolFile" value="${maven.build.dir}/eclipse/externaltools.xml" />
|
|
|
|
<ant:echo>Creating ${toolFile}</ant:echo>
|
|
|
|
<j:set var="os" value="${os.name}" />
|
|
<j:set var="windows" value="${os.toLowerCase().indexOf('windows') != '-1'}"/>
|
|
<ant:echo>Adapting the generated file for a ${os} box.</ant:echo>
|
|
|
|
<!-- Strangely, j:file inserts a space between ${maven.home} and /bin/maven ... -->
|
|
<j:set var="tool.loc" value="${maven.home}${file.separator}bin${file.separator}maven"/>
|
|
<j:if test="${windows}">
|
|
<j:set var="tool.loc" value="${tool.loc}.bat"/>
|
|
</j:if>
|
|
|
|
<j:file name="${toolFile}" prettyPrint="true" xmlns="dummy">
|
|
<externaltools>
|
|
<j:set var="project" value="${org.apache.commons.jelly.werkz.Project}"/>
|
|
|
|
<j:set var="session" value="${maven.session}"/>
|
|
<j:forEach var="goal" items="${session.allGoalNames}">
|
|
|
|
<j:set var="maven.eclipse.generate" value="false"/>
|
|
<j:set var="allGoals" value="${maven.eclipse.goals}" />
|
|
<j:choose>
|
|
<j:when test="${allGoals == 'all'}">
|
|
<j:set var="maven.eclipse.generate" value="true"/>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:if test="${goal.indexOf(':') == '-1'}">
|
|
<j:set var="maven.eclipse.generate" value="true"/>
|
|
</j:if>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<j:if test="${maven.eclipse.generate}">
|
|
<tool>
|
|
<entry key="!{tool_refresh}">$${project}</entry>
|
|
<entry key="!{tool_show_log}">true</entry>
|
|
<entry key="!{tool_loc}">${tool.loc}</entry>
|
|
<entry key="!{tool_args}">-e -p $${resource_loc} ${goal}</entry>
|
|
<entry key="!{tool_block}">false</entry>
|
|
<entry key="!{tool_type}">org.eclipse.ui.externaltools.type.program</entry>
|
|
<entry key="!{tool_dir}">$${container_loc}</entry>
|
|
<entry key="!{tool_build_types}"></entry>
|
|
<entry key="!{tool_name}">Maven ${goal}</entry>
|
|
</tool>
|
|
</j:if>
|
|
</j:forEach>
|
|
</externaltools>
|
|
</j:file>
|
|
|
|
<j:set var="ws" value="${maven.eclipse.workspace}X" />
|
|
<j:if test='${ws != "X"}'>
|
|
<j:set var="toDir" value="${maven.eclipse.workspace}/.metadata/.plugins/org.eclipse.ui.externaltools/" />
|
|
<ant:copy file="${toolFile}" todir="${toDir}"/>
|
|
</j:if>
|
|
|
|
<j:if test='${ws == "X"}'>
|
|
<ant:echo>
|
|
Please set maven.eclipse.workspace to the location of your eclipse workspace.
|
|
Alternatively, copy
|
|
${maven.build.dir}/eclipse/externaltools.xml
|
|
to
|
|
[maven.eclipse.workspace]/.metadata/.plugins/org.eclipse.ui.externaltools/externaltools.xml
|
|
</ant:echo>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
<!--==================================================================-->
|
|
<!-- Generate Eclipse mappings for Maven goals -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:external-tools-21"
|
|
description="Generate an Eclipse 2.1 external tool for each goal">
|
|
<ant:mkdir dir="${maven.build.dir}/eclipse/"/>
|
|
|
|
<ant:echo>Creating external tools </ant:echo>
|
|
|
|
<j:set var="os" value="${os.name}" />
|
|
<j:set var="windows" value="${os.toLowerCase().indexOf('windows') != '-1'}"/>
|
|
<ant:echo>Adapting the generated file for a ${os} box.</ant:echo>
|
|
|
|
<!-- Strangely, j:file inserts a space between ${maven.home} and /bin/maven ... -->
|
|
<j:set var="tool.loc" value="${maven.home}${file.separator}bin${file.separator}maven"/>
|
|
<j:if test="${windows}">
|
|
<j:set var="tool.loc" value="${tool.loc}.bat"/>
|
|
</j:if>
|
|
|
|
<j:set var="project" value="${org.apache.commons.jelly.werkz.Project}"/>
|
|
<j:set var="allGoals" value="${maven.eclipse.goals}" />
|
|
<j:set var="session" value="${maven.session}"/>
|
|
<j:forEach var="goal" items="${session.allGoalNames}">
|
|
<util:replace var="goalName" oldChar=":" newChar="-" value="${goal}"/>
|
|
|
|
<j:set var="fileName" value="${maven.build.dir}/eclipse/maven ${goalName}.launch"/>
|
|
|
|
<j:set var="maven.eclipse.generate" value="false"/>
|
|
<j:choose>
|
|
<j:when test="${allGoals == 'all'}">
|
|
<j:set var="maven.eclipse.generate" value="true"/>
|
|
</j:when>
|
|
<j:otherwise>
|
|
<j:if test="${goal.indexOf(':') == '-1'}">
|
|
<j:set var="maven.eclipse.generate" value="true"/>
|
|
</j:if>
|
|
</j:otherwise>
|
|
</j:choose>
|
|
|
|
<j:if test="${maven.eclipse.generate}">
|
|
<ant:echo>Generating ${fileName}</ant:echo>
|
|
<j:file name="${fileName}" prettyPrint="true" xmlns="dummy">
|
|
<j:import file="${plugin.resources}/templates/launch.jelly" inherit="true"/>
|
|
</j:file>
|
|
</j:if>
|
|
</j:forEach>
|
|
|
|
<j:set var="ws" value="${maven.eclipse.workspace}X" />
|
|
<j:if test='${ws != "X"}'>
|
|
<j:set var="toDir" value="${maven.eclipse.workspace}/.metadata/.plugins/org.eclipse.debug.core/.launches/" />
|
|
<ant:copy todir="${toDir}">
|
|
<ant:fileset dir="${maven.build.dir}/eclipse/" includes="*.launch" />
|
|
</ant:copy>
|
|
</j:if>
|
|
|
|
<j:if test='${ws == "X"}'>
|
|
<ant:echo>
|
|
Please set maven.eclipse.workspace to the location of your eclipse workspace.
|
|
Alternatively, copy
|
|
${maven.build.dir}/eclipse/*.launch
|
|
to
|
|
[maven.eclipse.workspace]/.metadata/.plugins/org.eclipse.debug.core/.launches/
|
|
</ant:echo>
|
|
</j:if>
|
|
|
|
</goal>
|
|
|
|
|
|
<!--==================================================================-->
|
|
<!-- Add MAVEN_REPO to classpath variables -->
|
|
<!--==================================================================-->
|
|
<goal name="eclipse:add-maven-repo"
|
|
description="Ensure that the classpath variable MAVEN_REPO is available">
|
|
|
|
<j:set var="ws" value="${maven.eclipse.workspace}X" />
|
|
<j:choose>
|
|
<j:when test='${ws != "X"}'>
|
|
<j:set var="variableFile" value="${maven.eclipse.workspace}/.metadata/.plugins/org.eclipse.jdt.core/pref_store.ini" />
|
|
<ant:propertyfile file="${variableFile}">
|
|
<ant:entry key="org.eclipse.jdt.core.classpathVariable.MAVEN_REPO"
|
|
default="${maven.repo.local}" />
|
|
</ant:propertyfile>
|
|
</j:when>
|
|
<j:otherwise>The property $${maven.eclipse.workspace} was not set. MAVEN_REPO may not be set.</j:otherwise>
|
|
</j:choose>
|
|
</goal>
|
|
|
|
</project>
|