Smarter generation of .classpath file.
${basedir} prefix is cut off if present in any path.
Default locations of source and destination folder are used instead
of hardcoded paths like 'target/classes'.
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@113416 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -48,34 +48,49 @@
|
||||
</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:set var="outputDir" value="${maven.eclipse.output.dir}"/>
|
||||
<j:if test="${empty outputDir}">
|
||||
<j:set var="outputDir" value="target/classes"/>
|
||||
</j:if>
|
||||
<ant:echo>Creating ${basedir}/.classpath ...</ant:echo>
|
||||
|
||||
<j:file name="${basedir}/.classpath" prettyPrint="true" xmlns="dummy">
|
||||
<classpath>
|
||||
<classpath>
|
||||
<j:if test="${sourcesPresent}">
|
||||
<j:set var="srcDir" value="${pom.build.sourceDirectory}"/>
|
||||
<j:if test="${ srcDir.startsWith( basedir ) }">
|
||||
<ant:echo>Cutting of 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}">
|
||||
<j:set var="testSrcDir" value="${pom.build.unitTestSourceDirectory}"/>
|
||||
<j:if test="${ testSrcDir.startsWith( basedir ) }">
|
||||
<ant:echo>Cutting of 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:if test="${sourcesPresent}">
|
||||
<classpathentry kind="src" path="${pom.build.sourceDirectory}"/>
|
||||
</j:if>
|
||||
|
||||
<j:if test="${unitTestSourcesPresent}">
|
||||
<classpathentry kind="src" path="${pom.build.unitTestSourceDirectory}"/>
|
||||
<!-- 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: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()}"/>
|
||||
@@ -112,8 +127,39 @@
|
||||
</j:forEach>
|
||||
|
||||
<!-- add the unit test build directory so that any files generated via Maven are available -->
|
||||
<classpathentry kind="lib" path="target/test-classes"/>
|
||||
|
||||
|
||||
<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 of 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 of 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>
|
||||
|
||||
@@ -7,6 +7,12 @@
|
||||
|
||||
<body>
|
||||
<release version="1.3" date="In CVS">
|
||||
<action dev="michal" type="add">
|
||||
Smarter generation of .classpath file.
|
||||
${basedir} prefix is cut off if present in any path.
|
||||
Default Maven location of source and destination folder
|
||||
are used.
|
||||
</action>
|
||||
<action dev="evenisse" type="add">
|
||||
Added dependency functionality between projects
|
||||
</action>
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.eclipse.output.dir</td>
|
||||
<td>Yes (default=target/classes)</td>
|
||||
<td>Yes (default=${maven.build.dest)</td>
|
||||
<td>
|
||||
The directory to which Eclipse should output its classes.
|
||||
By default this is the same directory as Maven generates its code
|
||||
@@ -48,6 +48,13 @@
|
||||
does not interfere with Eclipse's build.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>maven.eclipse.test.output.dir</td>
|
||||
<td>Yes (default=${maven.test.dest} defined in test plugin)</td>
|
||||
<td>
|
||||
The directory to which Eclipse should output its test classes.
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<p>
|
||||
Note that you will need to defined a <code>MAVEN_REPO</code> Java
|
||||
|
||||
Reference in New Issue
Block a user