You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by Eddie Post <po...@hotmail.com> on 2004/01/07 16:54:23 UTC

Maven Eclipse Contribution

Hellu,

I had some problems getting the eclipse plugin to work well with the Junit 
syntax.
I noticed that the eclipse plugin work with the following syntax in the 
project.xml:
----
	<unitTestSourceDirectory> ${basedir}/src/test </unitTestSourceDirectory>
----

However, I noticed in the maven manual that you should use (I think the 
other is depriated):
-----
<unitTest>
	<resources>
		<resource>
			<directory>${basedir}/src/test</directory>
		</resource>
	</resources>
</unitTest>
-----

So I changed the classpath.jelly a little bit of the maven-eclipse plugin.
I added the code below (simple changes, most of it is copied from existing 
code in the plugin but with other xml variables). This works fine (probably 
can be better but this is the first time I saw jelly code).
How is this code handled ? Will it be added to a new version of this plugin 
??

Regards,
Ed Bras

-----
<j:forEach var="resource" items="${pom.build.unitTest.resources}">
    <ant:echo>Contains JUnit tests</ant:echo>

    <maven:makeRelativePath var="testSrcDir" basedir="${basedir}" 
path="${resource.directory}"/>

    <!-- Eclipse supports an output directory per input directory -->
    <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>

    <maven:makeRelativePath var="testOutputDir" basedir="${basedir}" 
path="${testOutputDir}" />

    <ant:echo>Setting compile of ${testSrcDir} to 
${testOutputDir}</ant:echo>
    <classpathentry kind="src" path="${testSrcDir}" 
output="${testOutputDir}"/>




    <!-- Add JUNIT to classpath: 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:forEach>

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org


Re: Maven Eclipse Contribution

Posted by "Mark H. Wilkinson" <mh...@kremvax.net>.
On Wed, 2004-01-07 at 15:54, Eddie Post wrote:
> Hellu,
> 
> I had some problems getting the eclipse plugin to work well with the Junit 
> syntax.
> I noticed that the eclipse plugin work with the following syntax in the 
> project.xml:
> ----
> 	<unitTestSourceDirectory> ${basedir}/src/test </unitTestSourceDirectory>
> ----
> 
> However, I noticed in the maven manual that you should use (I think the 
> other is depriated):
> -----
> <unitTest>
> 	<resources>
> 		<resource>
> 			<directory>${basedir}/src/test</directory>
> 		</resource>
> 	</resources>
> </unitTest>

I'm sure others will correct me if I'm wrong, but I don't think that
<unitTestSourceDirectory> is deprecated - it's still in the POM version
4 schema, for example. You use the <unitTestSourceDirectory> element to
say where the Java source code for the unit tests are. You use the
<unitTest><resources> element to indicate where other resources (files
that should be included verbatim in the test-classes directory) are
located.

-Mark.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org