MPECLIPSE-49 and 49 for working w/ source directories
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-1/plugins/trunk@116137 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b48f2ffb94
commit
c3933eb9ff
@ -25,3 +25,4 @@
|
|||||||
# and 'plugins' to generate only the plugins' default goals.
|
# and 'plugins' to generate only the plugins' default goals.
|
||||||
maven.eclipse.goals = plugins
|
maven.eclipse.goals = plugins
|
||||||
maven.gen.src=${maven.build.dir}/generated-sources
|
maven.gen.src=${maven.build.dir}/generated-sources
|
||||||
|
maven.eclipse.src.extension = zip
|
||||||
|
|||||||
@ -64,7 +64,10 @@
|
|||||||
<j:arg value="${file}"/>
|
<j:arg value="${file}"/>
|
||||||
<j:arg value="${resource.directory}"/>
|
<j:arg value="${resource.directory}"/>
|
||||||
</j:invokeStatic>
|
</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:forEach>
|
||||||
</j:if>
|
</j:if>
|
||||||
</j:if>
|
</j:if>
|
||||||
@ -120,7 +123,17 @@
|
|||||||
|
|
||||||
<j:if test="${depVersion != 'none'}">
|
<j:if test="${depVersion != 'none'}">
|
||||||
<j:set var="ignoreJUnit" value="true" />
|
<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>
|
||||||
|
|
||||||
<j:if test="${pom.build.unitTest != null}">
|
<j:if test="${pom.build.unitTest != null}">
|
||||||
@ -133,7 +146,10 @@
|
|||||||
<j:arg value="${file}"/>
|
<j:arg value="${file}"/>
|
||||||
<j:arg value="${resource.directory}"/>
|
<j:arg value="${resource.directory}"/>
|
||||||
</j:invokeStatic>
|
</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:forEach>
|
||||||
</j:if>
|
</j:if>
|
||||||
</j:if>
|
</j:if>
|
||||||
@ -152,11 +168,24 @@
|
|||||||
|
|
||||||
<maven:pluginVar var="cactusPlugin" plugin='cactus-maven' property='plugin' />
|
<maven:pluginVar var="cactusPlugin" plugin='cactus-maven' property='plugin' />
|
||||||
<j:set var="depVersion">${cactusPlugin.getDependency('cactus').getVersion()}</j:set>
|
<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:set var="ignoreCactus" value="true" />
|
||||||
</j:if>
|
</j:if>
|
||||||
|
|
||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<j:forEach var="lib" items="${pom.artifacts}">
|
<j:forEach var="lib" items="${pom.artifacts}">
|
||||||
<j:set var="eclipseDependency"
|
<j:set var="eclipseDependency"
|
||||||
value="${lib.dependency.getProperty('eclipse.dependency')}"/>
|
value="${lib.dependency.getProperty('eclipse.dependency')}"/>
|
||||||
@ -179,12 +208,24 @@
|
|||||||
<j:if test="${isClasspath}">
|
<j:if test="${isClasspath}">
|
||||||
<maven:makeRelativePath var="relativePath" basedir="${maven.repo.local}" path="${lib.path}"/>
|
<maven:makeRelativePath var="relativePath" basedir="${maven.repo.local}" path="${lib.path}"/>
|
||||||
<u:file var="checkExist" name="${maven.repo.local}/${relativePath}" />
|
<u:file var="checkExist" name="${maven.repo.local}/${relativePath}" />
|
||||||
<j:if test="${checkExist.exists()}">
|
<j:choose>
|
||||||
<classpathentry kind="var" path="MAVEN_REPO/${relativePath}"/>
|
<j:when test="${checkExist.exists()}">
|
||||||
</j:if>
|
<!-- check available sources -->
|
||||||
<j:if test="${!checkExist.exists()}">
|
<j:set var="mappedsrc" value="${lib.dependency.artifactDirectory}/${maven.eclipse.src.dir}/${lib.dependency.artifactId}-${lib.dependency.version}.${maven.eclipse.src.extension}"/>
|
||||||
<classpathentry kind="lib" path="${lib.path}"/>
|
<u:file var="checkSrcExist" name="${maven.repo.local}/${mappedsrc}" />
|
||||||
</j:if>
|
<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:if>
|
||||||
</j:otherwise>
|
</j:otherwise>
|
||||||
</j:choose>
|
</j:choose>
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
xmlns:u="jelly:util"
|
xmlns:u="jelly:util"
|
||||||
xmlns:x="jelly:xml">
|
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>
|
||||||
|
|
||||||
<goal name="test-init">
|
<goal name="test-init">
|
||||||
@ -38,10 +38,10 @@
|
|||||||
|
|
||||||
<u:file var="classpathFile" name="${dotClasspath}"/>
|
<u:file var="classpathFile" name="${dotClasspath}"/>
|
||||||
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
|
<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"/>
|
<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')])"/>
|
<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>
|
</goal>
|
||||||
|
|
||||||
@ -111,7 +111,7 @@
|
|||||||
<u:file var="classpathFile" name="${dotClasspath}"/>
|
<u:file var="classpathFile" name="${dotClasspath}"/>
|
||||||
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
|
<x:parse var="classpathDoc" xml="${classpathFile.toURL()}" />
|
||||||
<x:set var="count" select="count($classpathDoc/classpath/classpathentry[contains(@kind,'src')])"/>
|
<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>
|
</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')])"/>
|
<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"/>
|
<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>
|
</project>
|
||||||
@ -81,4 +81,32 @@
|
|||||||
<version>13-1.6.1</version>
|
<version>13-1.6.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</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>
|
</project>
|
||||||
|
|||||||
1
eclipse/src/plugin-test/src/main/dir.txt
Normal file
1
eclipse/src/plugin-test/src/main/dir.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
needed for plugin test
|
||||||
1
eclipse/src/plugin-test/src/test/dir.txt
Normal file
1
eclipse/src/plugin-test/src/test/dir.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
needed for plugin test
|
||||||
@ -25,6 +25,8 @@
|
|||||||
</properties>
|
</properties>
|
||||||
<body>
|
<body>
|
||||||
<release version="1.9" date="in cvs">
|
<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="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-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>
|
<action dev="epugh" type="fix" issue="MPECLIPSE-38">Jar overrides are now properly supported.</action>
|
||||||
|
|||||||
@ -64,6 +64,7 @@
|
|||||||
<li>an output directory for compiled code:
|
<li>an output directory for compiled code:
|
||||||
<code>target\classes</code>
|
<code>target\classes</code>
|
||||||
</li>
|
</li>
|
||||||
|
<li>any .zip source archives</li>
|
||||||
</ol>
|
</ol>
|
||||||
</description>
|
</description>
|
||||||
</goal>
|
</goal>
|
||||||
|
|||||||
@ -42,5 +42,83 @@
|
|||||||
document.
|
document.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</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>
|
</body>
|
||||||
</document>
|
</document>
|
||||||
|
|||||||
@ -108,6 +108,13 @@
|
|||||||
the generated code to be clearly in the build directory.
|
the generated code to be clearly in the build directory.
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</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>
|
</table>
|
||||||
<p>
|
<p>
|
||||||
Note that you will need to defined a <code>MAVEN_REPO</code> Java
|
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.
|
<code>MAVEN_REPO</code> that points to your local Maven repository.
|
||||||
</p>
|
</p>
|
||||||
</section>
|
</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>
|
</body>
|
||||||
</document>
|
</document>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user