132 lines
5.9 KiB
XML

<?xml version="1.0"?>
<!--
/*
* Copyright 2001-2004 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<document>
<properties>
<title>Maven Eclipse Plugin</title>
<author email="vmassol@octo.com">Vincent Massol</author>
<author email="dion@apache.org">dIon Gillard</author>
</properties>
<body>
<section name="Maven Eclipse Plugin">
<p>
This plug-in provides the ability to generate Eclipse project files
(<code>.classpath</code> and <code>.project</code> files), as well as
configure Eclipse to use Maven as an <i>External Tool</i>.
</p>
<p>
For more information on the functionality provided by this plugin,
please see the <a href="goals.html">Goals</a> document.
</p>
<p>
For more information on how to customise the functionality provided
by this plugin, please see the <a href="properties.html">properties</a>
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 is able to download sources archive at <code>${groupId}/java-sources/${artifactId}-${version}-sources.jar</code>
from the repository. This behavior can be disabled by configuring the <code>maven.eclipse.src.download</code> property.
As an example, the source archive for 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>java-sources</em>/eclipse-ui-3.0.0<em>-sources.jar</em></code>
</p>
<p>
For backward compatibility the plugin still accepts source archives located at
<code>MAVEN_REPO/${groupId}/src/${artifactId}-${version}.${maven.eclipse.src.extension}</code> but it won't
download them from the repository.
</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>
By default, the plugin will load as seperate source folders any directory found in
<code>${maven.build.dir}/generated-sources</code>. So, if you generate your mock objects into
<code>${maven.build.dir}/generated-sources/mocks</code> and your wsdl classes into
<code>${maven.build.dir}/generated-sources/wsdl</code> then each of these directories will be mounted
as source folders. Note: You must have already created these directories, otherwise the
plugin won't know to add them as source folders. Before running <code>maven eclipse</code>
just ensure you have already generated all of your source code.
</p>
<p>
For example, if you used the XDoclet Plugin for Maven to generate Hibernate mapping files,
they would be placed in <code>/target/generated-sources/xdoclet/</code>. While, if you used the
Hibernate Plugin for Maven to generate the SQL scripts for generating a database then that
would be placed in <code>/target/generated-sources/schema/</code>.
<br/>
Settings in project.properties:
</p>
<source>
maven.xdoclet.hibernatedoclet.destDir=${maven.build.dir}/generated-sources/xdoclet
maven.hibernate.output.dir=${maven.build.dir}/generated-sources/schema
</source>
</subsection>
</section>
</body>
</document>