epugh 2004/10/15 02:45:05 Modified: eclipse plugin.properties eclipse/src/plugin-resources/templates classpath.jelly eclipse/xdocs goals.xml index.xml changes.xml properties.xml eclipse/src/plugin-test project.xml maven.xml Added: eclipse/src/plugin-test/src/test dir.txt eclipse/src/plugin-test/src/main dir.txt Log: MPECLIPSE-49 and 49 for working w/ source directories Revision Changes Path 1.6 +1 -0 maven-plugins/eclipse/plugin.properties Index: plugin.properties =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/plugin.properties,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- plugin.properties 4 Jul 2004 16:20:28 -0000 1.5 +++ plugin.properties 15 Oct 2004 09:45:05 -0000 1.6 @@ -25,3 +25,4 @@ # and 'plugins' to generate only the plugins' default goals. maven.eclipse.goals = plugins maven.gen.src=${maven.build.dir}/generated-sources +maven.eclipse.src.extension = zip 1.24 +51 -10 maven-plugins/eclipse/src/plugin-resources/templates/classpath.jelly Index: classpath.jelly =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/src/plugin-resources/templates/classpath.jelly,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- classpath.jelly 14 Oct 2004 15:24:51 -0000 1.23 +++ classpath.jelly 15 Oct 2004 09:45:05 -0000 1.24 @@ -64,7 +64,10 @@ <j:arg value="${file}"/> <j:arg value="${resource.directory}"/> </j:invokeStatic> - <classpathentry kind="src" path="${resourceDirectory}"/> + <!-- don't add duplicate directories --> + <j:if test="${!resourceDirectory.equals(srcDir)}"> + <classpathentry kind="src" path="${resourceDirectory}" including="${include}" excluding="${exclude}" /> + </j:if> </j:forEach> </j:if> </j:if> @@ -120,7 +123,17 @@ <j:if test="${depVersion != 'none'}"> <j:set var="ignoreJUnit" value="true" /> - <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-${depVersion}.jar"/> + <!-- check junit sources --> + <j:set var="mappedsrc" value="junit/${maven.eclipse.src.dir}/junit-${depVersion}.${maven.eclipse.src.extension}"/> + <u:file var="checkSrcExist" name="${maven.repo.local}/${mappedsrc}" /> + <j:choose> + <j:when test="${checkSrcExist.exists()}"> + <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-${depVersion}.jar" sourcepath="MAVEN_REPO/${mappedsrc}"/> + </j:when> + <j:otherwise> + <classpathentry kind="var" path="MAVEN_REPO/junit/jars/junit-${depVersion}.jar"/> + </j:otherwise> + </j:choose> </j:if> <j:if test="${pom.build.unitTest != null}"> @@ -133,7 +146,10 @@ <j:arg value="${file}"/> <j:arg value="${resource.directory}"/> </j:invokeStatic> - <classpathentry kind="src" path="${resourceDirectory}" output="${testOutputDir}"/> + <!-- don't add duplicate directories --> + <j:if test="${!resourceDirectory.equals(testSrcDir)}"> + <classpathentry kind="src" path="${resourceDirectory}" output="${testOutputDir}" /> + </j:if> </j:forEach> </j:if> </j:if> @@ -152,11 +168,24 @@ <maven:pluginVar var="cactusPlugin" plugin='cactus-maven' property='plugin' /> <j:set var="depVersion">${cactusPlugin.getDependency('cactus').getVersion()}</j:set> - <classpathentry kind="var" path="MAVEN_REPO/cactus/jars/cactus-${depVersion}.jar"/> + <!-- check cactus sources --> + <j:set var="mappedsrc" value="cactus/${maven.eclipse.src.dir}/cactus-${depVersion}.${maven.eclipse.src.extension}"/> + <u:file var="checkSrcExist" name="${maven.repo.local}/${mappedsrc}" /> + <j:choose> + <j:when test="${checkSrcExist.exists()}"> + <classpathentry kind="var" path="MAVEN_REPO/cactus/jars/cactus-${depVersion}.jar" sourcepath="MAVEN_REPO/${mappedsrc}"/> + </j:when> + <j:otherwise> + <classpathentry kind="var" path="MAVEN_REPO/cactus/jars/cactus-${depVersion}.jar"/> + </j:otherwise> + </j:choose> <j:set var="ignoreCactus" value="true" /> </j:if> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + + + <j:forEach var="lib" items="${pom.artifacts}"> <j:set var="eclipseDependency" value="${lib.dependency.getProperty('eclipse.dependency')}"/> @@ -179,12 +208,24 @@ <j:if test="${isClasspath}"> <maven:makeRelativePath var="relativePath" basedir="${maven.repo.local}" path="${lib.path}"/> <u:file var="checkExist" name="${maven.repo.local}/${relativePath}" /> - <j:if test="${checkExist.exists()}"> - <classpathentry kind="var" path="MAVEN_REPO/${relativePath}"/> - </j:if> - <j:if test="${!checkExist.exists()}"> - <classpathentry kind="lib" path="${lib.path}"/> - </j:if> + <j:choose> + <j:when test="${checkExist.exists()}"> + <!-- check available sources --> + <j:set var="mappedsrc" value="${lib.dependency.artifactDirectory}/${maven.eclipse.src.dir}/${lib.dependency.artifactId}-${lib.dependency.version}.${maven.eclipse.src.extension}"/> + <u:file var="checkSrcExist" name="${maven.repo.local}/${mappedsrc}" /> + <j:choose> + <j:when test="${checkSrcExist.exists()}"> + <classpathentry kind="var" path="MAVEN_REPO/${relativePath}" sourcepath="MAVEN_REPO/${mappedsrc}" /> + </j:when> + <j:otherwise> + <classpathentry kind="var" path="MAVEN_REPO/${relativePath}"/> + </j:otherwise> + </j:choose> + </j:when> + <j:otherwise> + <classpathentry kind="lib" path="${lib.path}"/> + </j:otherwise> + </j:choose> </j:if> </j:otherwise> </j:choose> 1.7 +1 -0 maven-plugins/eclipse/xdocs/goals.xml Index: goals.xml =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/xdocs/goals.xml,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- goals.xml 9 Aug 2004 15:01:39 -0000 1.6 +++ goals.xml 15 Oct 2004 09:45:05 -0000 1.7 @@ -64,6 +64,7 @@ <li>an output directory for compiled code: <code>target\classes</code> </li> + <li>any .zip source archives</li> </ol> </description> </goal> 1.3 +78 -0 maven-plugins/eclipse/xdocs/index.xml Index: index.xml =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/xdocs/index.xml,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- index.xml 4 Mar 2004 18:04:37 -0000 1.2 +++ index.xml 15 Oct 2004 09:45:05 -0000 1.3 @@ -42,5 +42,83 @@ document. </p> </section> + + <section name="Defining dependencies as eclipse projects"> + <p> + The dependencies defined in the POM need not to be jars strictly. They can + be projects in the eclipse workspace. If a dependency is an eclipse project + a property needs to be added to that dependency to indicate so. + </p> + <source><![CDATA[ + <dependency> + <groupId>group</groupId> + <artifactId>artifact</artifactId> + <version>version</version> + <properties> + <eclipse.dependency>true</eclipse.dependency> + </properties> + </dependency> +]]></source> + <p> + This indicates that the dependency is another project in the workspace. + Note that the name of the referenced project is the artifactId. + </p> + <p> + The inverse also works. If you have included extra jars that shouldn't be + in the eclipse classpath then you can set <code>eclipse.dependency=false</code> + </p> + </section> + <section name="Source Code Integration w/ Eclipse"> + <subsection name="Artifact Sources"> + <p> + Frequently you will want to include for compiled jars the source .java files to help + with debugging. + </p> + <p> + The plugin will check if the file specified is located in <code>MAVEN_REPO/${groupId}/src/</code> directory + and ending in <code>maven.eclipse.src.extension</code> exists and will add it as a source attachment. + Using default values the dependency <code>MAVEN_REPO/eclipse/<em>jars</em>/eclipse-ui-3.0.0.<em>jar</em></code> + will be mapped to <code>MAVEN_REPO/eclipse/<em>src</em>/eclipse-ui-3.0.0.<em>zip</em></code> + </p> + <p> + While this implementation isn't the perfect solution, for example no downloading of + source .zip files, it is a minimal solution that will work now. Future versions + of Maven will have more sophisticated solutions for dealing with source code. There is + no guarantee that this implementation will remain in later versions of Maven and this + plugin. + </p> + </subsection> + <subsection name="Generated Source Code"> + <p> + When Eclipse is not generating source code for you there is a conflict between + Maven generating the source code and then Eclipse treating it as compiled code. + Typically when generating code using Maven the code ends up in the target/classes + directory. This is fine as long as Maven is doing the build. However, if Eclipse + is then setup to do the build, when Eclipse performs a clean build all the generated + code in target/classes will be removed. + </p> + <p> + The alternatives typically are to place the generated code in the /src/java directory + and allow Maven and Eclipse to treat it the same. However, this leads to a tendency + to check generated code into source control, which typically is not appropriate for + generated code. Alternatively, it can be placed in some sort of /src/generated or + target/generated directory. In Maven2, generated code lives in target/generated-sources, + in a manner similiar to generated xdoc's live in target/generated-xdocs. Within the + target/generated-sources would be each type of generated code. + </p> + <p> + For example, if you used the XDoclet Plugin for Maven to generate Hibernate mapping files, + they would be placed in /target/generated-sources/xdoclet/. While, if you used the + Hibernate Plugin for Maven to generate the SQL scripts for generating a database then that + would be placed in /target/generated-sources/schema/. + <br/> + Settings in project.properties: + <source> +maven.xdoclet.hibernatedoclet.destDir=${maven.build.dir}/generated-sources/xdoclet +maven.hibernate.output.dir=${maven.build.dir}/generated-sources/schema + </source> + </p> + </subsection> + </section> </body> </document> 1.33 +2 -0 maven-plugins/eclipse/xdocs/changes.xml Index: changes.xml =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/xdocs/changes.xml,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- changes.xml 14 Oct 2004 15:24:51 -0000 1.32 +++ changes.xml 15 Oct 2004 09:45:05 -0000 1.33 @@ -25,6 +25,8 @@ </properties> <body> <release version="1.9" date="in cvs"> + <action dev="epugh" type="fix" issue="MPECLIPSE-49" due-to="Fabrizio Giustina">duplicate build path added if resouce directory is the same as java source dir.</action> + <action dev="epugh" type="fix" issue="MPECLIPSE-48" due-to="Fabrizio Giustina">Simple implementation of handling source artifacts.</action> <action dev="evenisse" type="fix" issue="MPECLIPSE-47">Add resources directories and test resources directories to .classpath.</action> <action dev="epugh" type="fix" issue="MPECLIPSE-46" due-to="Archimedes Trajano">Overriden jar that resides outside maven repo doesn't get resolved properly.</action> <action dev="epugh" type="fix" issue="MPECLIPSE-38">Jar overrides are now properly supported.</action> 1.12 +8 -56 maven-plugins/eclipse/xdocs/properties.xml Index: properties.xml =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/xdocs/properties.xml,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- properties.xml 4 Jul 2004 16:20:28 -0000 1.11 +++ properties.xml 15 Oct 2004 09:45:05 -0000 1.12 @@ -108,6 +108,13 @@ the generated code to be clearly in the build directory. </td> </tr> + <tr> + <td>maven.eclipse.src.extension</td> + <td>Yes (default=<code>zip</code>)</td> + <td> + The extension used for source attachments. + </td> + </tr> </table> <p> Note that you will need to defined a <code>MAVEN_REPO</code> Java @@ -117,61 +124,6 @@ <code>MAVEN_REPO</code> that points to your local Maven repository. </p> </section> - <section name="Defining dependencies as eclipse projects"> - <p> - The dependencies defined in the POM need not to be jars strictly. They can - be projects in the eclipse workspace. If a dependency is an eclipse project - a property needs to be added to that dependency to indicate so. - </p> - <source><![CDATA[ - <dependency> - <groupId>group</groupId> - <artifactId>artifact</artifactId> - <version>version</version> - <properties> - <eclipse.dependency>true</eclipse.dependency> - </properties> - </dependency> -]]></source> - <p> - This indicates that the dependency is another project in the workspace. - Note that the name of the referenced project is the artifactId. - </p> - <p> - The inverse also works. If you have included extra jars that shouldn't be - in the eclipse classpath then you can set <code>eclipse.dependency=false</code> - </p> - </section> - <section name="Generated Source Code integration w/ Eclipse"> - <p> - When Eclipse is not generating source code for you there is a conflict between - Maven generating the source code and then Eclipse treating it as compiled code. - Typically when generating code using Maven the code ends up in the target/classes - directory. This is fine as long as Maven is doing the build. However, if Eclipse - is then setup to do the build, when Eclipse performs a clean build all the generated - code in target/classes will be removed. - </p> - <p> - The alternatives typically are to place the generated code in the /src/java directory - and allow Maven and Eclipse to treat it the same. However, this leads to a tendency - to check generated code into source control, which typically is not appropriate for - generated code. Alternatively, it can be placed in some sort of /src/generated or - target/generated directory. In Maven2, generated code lives in target/generated-sources, - in a manner similiar to generated xdoc's live in target/generated-xdocs. Within the - target/generated-sources would be each type of generated code. - </p> - <p> - For example, if you used the XDoclet Plugin for Maven to generate Hibernate mapping files, - they would be placed in /target/generated-sources/xdoclet/. While, if you used the - Hibernate Plugin for Maven to generate the SQL scripts for generating a database then that - would be placed in /target/generated-sources/schema/. - <br/> - Settings in project.properties: - <source> -maven.xdoclet.hibernatedoclet.destDir=${maven.build.dir}/generated-sources/xdoclet -maven.hibernate.output.dir=${maven.build.dir}/generated-sources/schema - </source> - </p> - </section> + </body> </document> 1.1 maven-plugins/eclipse/src/plugin-test/src/test/dir.txt Index: dir.txt =================================================================== needed for plugin test 1.9 +28 -0 maven-plugins/eclipse/src/plugin-test/project.xml Index: project.xml =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/src/plugin-test/project.xml,v retrieving revision 1.8 retrieving revision 1.9 diff -u -r1.8 -r1.9 --- project.xml 24 Sep 2004 15:51:01 -0000 1.8 +++ project.xml 15 Oct 2004 09:45:05 -0000 1.9 @@ -81,4 +81,32 @@ <version>13-1.6.1</version> </dependency> </dependencies> + <build> + <sourceDirectory>src/main</sourceDirectory> + <unitTestSourceDirectory>src/test</unitTestSourceDirectory> + <unitTest> + <includes> + <include>**/TestAll.java</include> + </includes> + <resources> + <resource> + <directory>src/test-resources</directory> + <filtering>false</filtering> + </resource> + </resources> + </unitTest> + <resources> + <resource> + <directory>src/main</directory> + </resource> + <resource> + <directory>src/resources</directory> + <includes> + <include>**/*.properties</include> + <include>**/*.xml</include> + </includes> + <filtering>false</filtering> + </resource> + </resources> +</build> </project> 1.13 +17 -5 maven-plugins/eclipse/src/plugin-test/maven.xml Index: maven.xml =================================================================== RCS file: /home/cvs/maven-plugins/eclipse/src/plugin-test/maven.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -r1.12 -r1.13 --- maven.xml 24 Sep 2004 15:51:01 -0000 1.12 +++ maven.xml 15 Oct 2004 09:45:05 -0000 1.13 @@ -20,7 +20,7 @@ xmlns:u="jelly:util" xmlns:x="jelly:xml"> - <goal name="testPlugin" prereqs="test-eclipse,test-natures,test-builders,test-natures-and-builders,test-classpath-has-generated-source,test-classpath-has-overridden-jar"> + <goal name="testPlugin" prereqs="test-eclipse,test-natures,test-builders,test-natures-and-builders,test-classpath-has-generated-source,test-classpath-has-overridden-jar,test-noduplicates"> </goal> <goal name="test-init"> @@ -38,10 +38,10 @@ <u:file var="classpathFile" name="${dotClasspath}"/> <x:parse var="classpathDoc" xml="${classpathFile.toURL()}" /> - <x:set var="countJUnit" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/junit\jars\junit-3.8.1.jar')])"/> + <x:set var="countJUnit" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/junit/jars/junit-3.8.1.jar')])"/> <assert:assertEquals expected="1" value="${countJUnit.intValue().toString()}" msg="JUnit dependency not found"/> <x:set var="countCactus" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/cactus/jars/cactus-13-1.6.1.jar')])"/> - <assert:assertEquals expected="1" value="${countCactus.intValue().toString()}" msg="More than one Cactus dependencies found"/> + <assert:assertEquals expected="1" value="${countCactus.intValue().toString()}" msg="Only one Cactus dependency should be found"/> </goal> @@ -111,7 +111,7 @@ <u:file var="classpathFile" name="${dotClasspath}"/> <x:parse var="classpathDoc" xml="${classpathFile.toURL()}" /> <x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@kind,'src')])"/> - <assert:assertEquals expected="3" value="${count.intValue().toString()}" msg="Not enough generated src directories found"/> + <assert:assertEquals expected="7" value="${count.intValue().toString()}" msg="Wrong number of generated src directories found"/> </goal> @@ -128,6 +128,18 @@ <x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@path,'MAVEN_REPO/commons-logging\jars\commons-logging-1.0.3.jar')])"/> <assert:assertEquals expected="1" value="${count.intValue().toString()}" msg="maven.jar.override didn't work"/> - </goal> + </goal> + + <goal name="test-noduplicates"> + <attainGoal name="test-init"/> + <attainGoal name="eclipse"/> + + <assert:assertFileExists file="${dotClasspath}" /> + + <u:file var="classpathFile" name="${dotClasspath}"/> + <x:parse var="classpathDoc" xml="${classpathFile.toURL()}" /> + <x:set var="countUniqueSrc" select="count($classpathDoc/classpath/classpathentry[contains(@path,'src\main')])"/> + <assert:assertEquals expected="1" value="${countUniqueSrc.intValue().toString()}" msg="Src directory should be added only once"/> + </goal> </project> 1.1 maven-plugins/eclipse/src/plugin-test/src/main/dir.txt Index: dir.txt =================================================================== needed for plugin test
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]