epugh 2004/07/04 09:20:28
Modified: eclipse plugin.properties
eclipse/src/plugin-resources/templates classpath.jelly
eclipse/src/plugin-test maven.xml
eclipse/xdocs properties.xml
Log:
Add better support for generated sources
Revision Changes Path
1.5 +1 -0 maven-plugins/eclipse/plugin.properties
Index: plugin.properties
===================================================================
RCS file: /home/cvs/maven-plugins/eclipse/plugin.properties,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- plugin.properties 4 Mar 2004 18:04:37 -0000 1.4
+++ plugin.properties 4 Jul 2004 16:20:28 -0000 1.5
@@ -24,3 +24,4 @@
# This accepts two values: 'all' for all the goals,
# and 'plugins' to generate only the plugins' default goals.
maven.eclipse.goals = plugins
+maven.gen.src=${maven.build.dir}/generated-sources
1.17 +9 -0
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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- classpath.jelly 28 Jun 2004 22:07:32 -0000 1.16
+++ classpath.jelly 4 Jul 2004 16:20:28 -0000 1.17
@@ -27,6 +27,15 @@
trim="true">
<classpath>
+ <!-- Add any generated source directories as seperate src directories -->
+ <u:available file="${maven.gen.src}">
+ <u:file var="genSrcRootDir" name="${maven.gen.src}"/>
+ <j:forEach var="genSrcDir" items="${genSrcRootDir.listFiles()}">
+ <maven:makeRelativePath var="srcDir" basedir="${basedir}"
path="${genSrcDir}"/>
+ <classpathentry kind="src" path="${srcDir}"/>
+ </j:forEach>
+ </u:available>
+
<j:if test="${sourcesPresent}">
<maven:makeRelativePath var="srcDir" basedir="${basedir}"
path="${pom.build.sourceDirectory}"/>
<j:set var="excluding" value=""/>
1.5 +82 -53 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.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- maven.xml 6 May 2004 05:43:12 -0000 1.4
+++ maven.xml 4 Jul 2004 16:20:28 -0000 1.5
@@ -20,7 +20,7 @@
xmlns:u="jelly:util"
xmlns:x="jelly:xml">
- <goal name="testPlugin"
prereqs="test-init,test-eclipse,test-natures,test-builders,test-natures-and-builders">
+ <goal name="testPlugin"
prereqs="test-init,test-eclipse,test-natures,test-builders,test-natures-and-builders,test-classpath-has-generated-source">
</goal>
<goal name="test-init">
@@ -38,57 +38,86 @@
</goal>
- <goal name="test-natures">
- <delete file="${dotProject}" failonerror="false"/>
- <j:set var="maven.eclipse.projectnatures" value="n1,a.b.c.n2"/>
- <attainGoal name="eclipse:generate-project"/>
-
- <assert:assertFileExists file="${dotProject}" />
-
- <u:file var="projectFile" name="${dotProject}"/>
- <x:parse var="projectDoc" xml="${projectFile.toURL()}" />
- <x:set var="natures" select="$projectDoc/projectDescription/natures/nature"/>
- <assert:assertEquals expected="n1" value="${natures[1].text}" msg="n1 is not the
second nature"/>
- <assert:assertEquals expected="a.b.c.n2" value="${natures[2].text}"
msg="a.b.c.n2 is not the third nature"/>
- </goal>
-
- <goal name="test-builders">
- <j:set var="maven.eclipse.buildcommands" value="c1,c2,c3"/>
- <delete file="${dotProject}" failonerror="false"/>
- <attainGoal name="eclipse:generate-project"/>
-
- <assert:assertFileExists file="${dotProject}" />
- <u:file var="projectFile" name="${dotProject}"/>
- <x:parse var="projectDoc" xml="${projectFile.toURL()}" />
- <x:set var="builders"
select="$projectDoc/projectDescription/buildSpec/buildCommand/name"/>
-
- <assert:assertEquals expected="c1" value="${builders[1].text}" msg="c1 is not
the second build command name"/>
- <assert:assertEquals expected="c2" value="${builders[2].text}" msg="c2 is not
the third build command name"/>
- <assert:assertEquals expected="c3" value="${builders[3].text}" msg="c3 is not
the fourth build command name"/>
- </goal>
-
-
- <goal name="test-natures-and-builders">
- <delete file="${dotProject}" failonerror="false"/>
- <j:set var="maven.eclipse.projectnatures" value="n7,n9,n11"/>
- <j:set var="maven.eclipse.buildcommands" value="c11,c21,c31"/>
- <attainGoal name="eclipse:generate-project"/>
-
- <assert:assertFileExists file="${dotProject}" />
- <u:file var="projectFile" name="${dotProject}"/>
- <x:parse var="projectDoc" xml="${projectFile.toURL()}" />
- <x:set var="natures" select="$projectDoc/projectDescription/natures/nature"/>
- <x:set var="builders"
select="$projectDoc/projectDescription/buildSpec/buildCommand/name"/>
-
- <!-- check natures -->
- <assert:assertEquals expected="n7" value="${natures[1].text}" msg="n7 is not the
second nature"/>
- <assert:assertEquals expected="n9" value="${natures[2].text}" msg="n9 is not the
second nature"/>
- <assert:assertEquals expected="n11" value="${natures[3].text}" msg="n11 is not
the second nature"/>
-
- <!-- check builders -->
- <assert:assertEquals expected="c11" value="${builders[1].text}" msg="c11 is not
the second build command name"/>
- <assert:assertEquals expected="c21" value="${builders[2].text}" msg="c21 is not
the second build command name"/>
- <assert:assertEquals expected="c31" value="${builders[3].text}" msg="c31 is not
the second build command name"/>
- </goal>
+ <goal name="test-natures">
+ <delete file="${dotProject}" failonerror="false"/>
+ <j:set var="maven.eclipse.projectnatures" value="n1,a.b.c.n2"/>
+ <attainGoal name="eclipse:generate-project"/>
+
+ <assert:assertFileExists file="${dotProject}" />
+
+ <u:file var="projectFile" name="${dotProject}"/>
+ <x:parse var="projectDoc" xml="${projectFile.toURL()}" />
+ <x:set var="natures" select="$projectDoc/projectDescription/natures/nature"/>
+ <assert:assertEquals expected="n1" value="${natures[1].text}" msg="n1 is not
the second nature"/>
+ <assert:assertEquals expected="a.b.c.n2" value="${natures[2].text}"
msg="a.b.c.n2 is not the third nature"/>
+ </goal>
+
+ <goal name="test-builders">
+ <j:set var="maven.eclipse.buildcommands" value="c1,c2,c3"/>
+ <delete file="${dotProject}" failonerror="false"/>
+ <attainGoal name="eclipse:generate-project"/>
+
+ <assert:assertFileExists file="${dotProject}" />
+ <u:file var="projectFile" name="${dotProject}"/>
+ <x:parse var="projectDoc" xml="${projectFile.toURL()}" />
+ <x:set var="builders"
select="$projectDoc/projectDescription/buildSpec/buildCommand/name"/>
+
+ <assert:assertEquals expected="c1" value="${builders[1].text}" msg="c1 is not
the second build command name"/>
+ <assert:assertEquals expected="c2" value="${builders[2].text}" msg="c2 is not
the third build command name"/>
+ <assert:assertEquals expected="c3" value="${builders[3].text}" msg="c3 is not
the fourth build command name"/>
+ </goal>
+
+
+ <goal name="test-natures-and-builders">
+ <delete file="${dotProject}" failonerror="false"/>
+ <j:set var="maven.eclipse.projectnatures" value="n7,n9,n11"/>
+ <j:set var="maven.eclipse.buildcommands" value="c11,c21,c31"/>
+ <attainGoal name="eclipse:generate-project"/>
+
+ <assert:assertFileExists file="${dotProject}" />
+ <u:file var="projectFile" name="${dotProject}"/>
+ <x:parse var="projectDoc" xml="${projectFile.toURL()}" />
+ <x:set var="natures" select="$projectDoc/projectDescription/natures/nature"/>
+ <x:set var="builders"
select="$projectDoc/projectDescription/buildSpec/buildCommand/name"/>
+
+ <!-- check natures -->
+ <assert:assertEquals expected="n7" value="${natures[1].text}" msg="n7 is not
the second nature"/>
+ <assert:assertEquals expected="n9" value="${natures[2].text}" msg="n9 is not
the second nature"/>
+ <assert:assertEquals expected="n11" value="${natures[3].text}" msg="n11 is not
the second nature"/>
+
+ <!-- check builders -->
+ <assert:assertEquals expected="c11" value="${builders[1].text}" msg="c11 is not
the second build command name"/>
+ <assert:assertEquals expected="c21" value="${builders[2].text}" msg="c21 is not
the second build command name"/>
+ <assert:assertEquals expected="c31" value="${builders[3].text}" msg="c31 is not
the second build command name"/>
+ </goal>
+
+ <goal name="test-classpath-has-generated-source">
+ <delete file="${dotProject}" failonerror="false"/>
+ <delete file="${dotClasspath}" failonerror="false"/>
+ <mkdir dir="${maven.gen.src}/gensrc1"/>
+ <mkdir dir="${maven.gen.src}/gensrc2"/>
+ <attainGoal name="eclipse"/>
+
+ <assert:assertFileExists file="${dotProject}" />
+ <assert:assertFileExists file="${dotClasspath}" />
+
+ <u:file var="classpathFile" name="${dotClasspath}"/>
+ <x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
+ <!-- FIXME. This should filter where kind="src" -->
+ <x:set var="count" select="count($classpathDoc/classpath/classpathentry)"/>
+ <assert:assertEquals expected="5" value="${count.intValue().toString()}"/>
+
+ </goal>
+
+ <goal name="test1">
+ <u:file var="dude" name="${maven.build.dir}"/>
+ <echo>Dude ${dude}</echo>
+ <echo>Dude Parent ${dude.parent}</echo>
+ <echo>Dude Parent ${dude.files}</echo>
+ <j:forEach var="file" items="${dude.listFiles()}">
+ <echo>file ${file}</echo>
+ </j:forEach>
+ </goal>
+
</project>
1.11 +43 -2 maven-plugins/eclipse/xdocs/properties.xml
Index: properties.xml
===================================================================
RCS file: /home/cvs/maven-plugins/eclipse/xdocs/properties.xml,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- properties.xml 28 Jun 2004 22:07:31 -0000 1.10
+++ properties.xml 4 Jul 2004 16:20:28 -0000 1.11
@@ -81,7 +81,7 @@
the classpath, like <code>src/conf</code>.
</td>
</tr>
- <tr>
+ <tr>
<td>maven.eclipse.buildcommands</td>
<td>Yes</td>
<td>
@@ -89,7 +89,7 @@
to include in the project description file.
</td>
</tr>
- <tr>
+ <tr>
<td>maven.eclipse.projectnatures</td>
<td>Yes</td>
<td>
@@ -98,6 +98,16 @@
will be added after the java nature.
</td>
</tr>
+ <tr>
+ <td>maven.gen.src</td>
+ <td>Yes (default=${maven.build.dir}/generated-sources)</td>
+ <td>
+ The directory that generated source code is placed. Maven will select
+ any directories under this as source code. This prevents the generated
+ source from being removed whenever Eclipse does a clean build, and
allows
+ the generated code to be clearly in the build directory.
+ </td>
+ </tr>
</table>
<p>
Note that you will need to defined a <code>MAVEN_REPO</code> Java
@@ -131,6 +141,37 @@
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>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]