Index: src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
===================================================================
--- src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (revision 497414)
+++ src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (working copy)
@@ -86,6 +86,8 @@
private static final String BUILDER_PDE_SCHEMA = "org.eclipse.pde.SchemaBuilder"; //$NON-NLS-1$
+ private static final String BUILDER_M2ECLIPSE = "org.maven.ide.eclipse.maven2Builder"; //$NON-NLS-1$
+
private static final String NATURE_WST_MODULE_CORE_NATURE = "org.eclipse.wst.common.modulecore.ModuleCoreNature"; //$NON-NLS-1$
private static final String NATURE_JDT_CORE_JAVA = "org.eclipse.jdt.core.javanature"; //$NON-NLS-1$
@@ -94,6 +96,8 @@
private static final String NATURE_PDE_PLUGIN = "org.eclipse.pde.PluginNature"; //$NON-NLS-1$
+ private static final String NATURE_M2ECLIPSE = "org.maven.ide.eclipse.maven2Nature"; //$NON-NLS-1$
+
private static final String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER = "org.eclipse.jdt.launching.JRE_CONTAINER"; //$NON-NLS-1$
private static final String REQUIRED_PLUGINS_CONTAINER = "org.eclipse.pde.core.requiredPlugins"; //$NON-NLS-1$
@@ -210,6 +214,17 @@
private boolean useProjectReferences;
/**
+ * When set to true, the plugin will add the a classpath container for the
+ * the Maven dependencies and will NOT write out the classpaths that are
+ * part of the dependency. The appropriate nature and builder will also be added
+ * to the .project file.
+ *
+ * @parameter expression="${m2eclipse}" default-value="false"
+ * @required
+ */
+ private boolean m2eclipse;
+
+ /**
* The default output directory
*
* @parameter expression="${outputDirectory}" alias="outputDirectory" default-value="${project.build.outputDirectory}"
@@ -390,6 +405,24 @@
}
/**
+ * Getter for m2eclipse.
+ * @return Returns the m2eclipse.
+ */
+ public boolean getM2eclipse()
+ {
+ return this.m2eclipse;
+ }
+
+ /**
+ * Setter for useProjectReferences.
+ * @param useProjectReferences The useProjectReferences to set.
+ */
+ public void setM2eclipse( boolean m2eclipse )
+ {
+ this.m2eclipse = m2eclipse;
+ }
+
+ /**
* Getter for wtpversion.
* @return Returns the wtpversion.
*/
@@ -526,6 +559,10 @@
private void parseConfigurationOptions()
{
+ if ( m2eclipse )
+ {
+ getLog().info( Messages.getString( "EclipsePlugin.m2eclipse" ) );
+ }
if ( "R7".equalsIgnoreCase( wtpversion ) ) //$NON-NLS-1$
{
wtpVersionFloat = 0.7f;
@@ -760,6 +797,7 @@
config.setDeps( deps );
config.setEclipseProjectDirectory( eclipseProjectDir );
config.setLocalRepository( localRepository );
+ config.setM2eclipse( m2eclipse );
config.setManifestFile( manifest );
config.setPde( pde );
config.setProject( project );
@@ -800,16 +838,21 @@
{
projectnatures = new ArrayList();
- if ( wtpVersionFloat >= 1.0f )
+ if ( isJavaProject )
{
- projectnatures.add( NATURE_WST_FACET_CORE_NATURE ); // WTP 1.0 nature
+ projectnatures.add( NATURE_JDT_CORE_JAVA );
}
- if ( isJavaProject )
+ if ( m2eclipse )
{
- projectnatures.add( NATURE_JDT_CORE_JAVA );
+ projectnatures.add( NATURE_M2ECLIPSE );
}
+ if ( wtpVersionFloat >= 1.0f )
+ {
+ projectnatures.add( NATURE_WST_FACET_CORE_NATURE ); // WTP 1.0 nature
+ }
+
if ( wtpVersionFloat >= 0.7f )
{
projectnatures.add( NATURE_WST_MODULE_CORE_NATURE ); // WTP 0.7/1.0 nature
@@ -872,6 +915,11 @@
buildcommands.add( new BuildCommand( BUILDER_PDE_MANIFEST ) );
buildcommands.add( new BuildCommand( BUILDER_PDE_SCHEMA ) );
}
+
+ if ( m2eclipse )
+ {
+ buildcommands.add( BUILDER_M2ECLIPSE );
+ }
}
public EclipseSourceDir[] buildDirectoryList( MavenProject project, File basedir, File buildOutputDirectory )
Index: src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
===================================================================
--- src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (revision 497414)
+++ src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (working copy)
@@ -126,6 +126,11 @@
private static final String FILE_DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$
/**
+ * Classpath container used when setting up m2eclipse readiness.
+ */
+ private static final String M2ECLIPSE_DEPENDENCY_CONTAINER = "org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"; //$NON-NLS-1$
+
+ /**
* @see org.apache.maven.plugin.eclipse.writers.EclipseWriter#write()
*/
public void write()
@@ -349,6 +354,16 @@
}
}
+ // if we are setting it up to be m2eclipse ready then the container for dependencies
+ // needs to come after the dependency list above since we could have projects referenced
+ // by source that need to be above this
+ if ( config.isM2eclipse() ) {
+ writer.startElement( ELT_CLASSPATHENTRY );
+ writer.addAttribute( ATTR_KIND, "con" ); //$NON-NLS-1$
+ writer.addAttribute( ATTR_PATH, M2ECLIPSE_DEPENDENCY_CONTAINER );
+ writer.endElement(); // name
+ }
+
writer.endElement();
IOUtil.close( w );
@@ -365,9 +380,17 @@
String javadocpath = null;
if ( dep.isReferencedProject() && !config.isPde() )
- {
- path = "/" + dep.getArtifactId(); //$NON-NLS-1$
- kind = ATTR_SRC;
+ {
+ // if using m2eclipse then don't add the project as a dependency
+ if ( config.isM2eclipse() )
+ {
+ return;
+ }
+ else
+ {
+ path = "/" + dep.getArtifactId(); //$NON-NLS-1$
+ kind = ATTR_SRC;
+ }
}
else if ( dep.isReferencedProject() && config.isPde() )
{
@@ -386,6 +409,7 @@
if ( dep.isSystemScoped() )
{
+
path = IdeUtils.toRelativeAndFixSeparator( config.getEclipseProjectDirectory(), artifactPath, false );
if ( log.isDebugEnabled() )
@@ -395,10 +419,15 @@
}
kind = ATTR_LIB;
+
+ if ( config.isM2eclipse() ) {
+ return;
+ }
}
else
{
File localRepositoryFile = new File( config.getLocalRepository().getBasedir() );
+ boolean isM2RepositoryItem = false;
// if the dependency is not provided and the plugin runs in "pde mode", the dependency is
// added to the Bundle-Classpath:
@@ -418,6 +447,7 @@
else
{
String fullPath = artifactPath.getPath();
+ isM2RepositoryItem = true;
path = M2_REPO + "/" //$NON-NLS-1$
+ IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, new File( fullPath ), false );
@@ -429,6 +459,7 @@
{
if ( ATTR_VAR.equals( kind ) )
{
+ isM2RepositoryItem = true;
sourcepath = M2_REPO
+ "/" //$NON-NLS-1$
+ IdeUtils
@@ -438,9 +469,16 @@
{
// source archive must be referenced with the full path, we can't mix a lib with a variable
sourcepath = IdeUtils.getCanonicalPath( dep.getSourceAttachment() );
+ // we are no longer referencing the M2_REPO
+ isM2RepositoryItem = false;
}
}
+ // if using m2eclipse and the item is marked with the M2_REPO then no need add it in
+ if ( config.isM2eclipse() && isM2RepositoryItem ) {
+ return;
+ }
+
if ( dep.getJavadocAttachment() != null )
{
// NB eclipse (3.1) doesn't support variables in javadoc paths, so we need to add the
Index: src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWriterConfig.java
===================================================================
--- src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWriterConfig.java (revision 497414)
+++ src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWriterConfig.java (working copy)
@@ -78,6 +78,11 @@
private File manifestFile;
/**
+ * M2eclipse ready.
+ */
+ private boolean m2eclipse;
+
+ /**
* PDE mode.
*/
private boolean pde;
@@ -280,6 +285,24 @@
}
/**
+ * Getter for m2eclipse.
+ * @return Returns the m2eclipse.
+ */
+ public boolean isM2eclipse()
+ {
+ return this.m2eclipse;
+ }
+
+ /**
+ * Setter for m2eclipse.
+ * @param m2eclipse The m2eclipse to set.
+ */
+ public void setM2eclipse( boolean m2eclipse )
+ {
+ this.m2eclipse = m2eclipse;
+ }
+
+ /**
* Getter for buildCommands.
* @return Returns the buildCommands.
*/
Index: src/main/resources/org/apache/maven/plugin/eclipse/messages.properties
===================================================================
--- src/main/resources/org/apache/maven/plugin/eclipse/messages.properties (revision 497414)
+++ src/main/resources/org/apache/maven/plugin/eclipse/messages.properties (working copy)
@@ -16,6 +16,7 @@
EclipsePlugin.artifactissystemscoped=The artifact has scope ''system''. Artifact id: {0}. System path: {1}
EclipsePlugin.unsupportedwtp=Unsupported WTP version: {0}. This plugin currently supports only the following versions: {1}.
EclipsePlugin.wtpversion=Adding support for WTP version {0}.
+EclipsePlugin.m2eclipse=Adding support for m2eclipse plugin.
EclipsePlugin.missingjrecontainer=You did specify a list of classpath containers without the base org.eclipse.jdt.launching.JRE_CONTAINER.\n If you specify custom classpath containers you should also add org.eclipse.jdt.launching.JRE_CONTAINER to the list
EclipsePlugin.deprecatedpar=Plugin parameter "{0}" is deprecated, please use "{1}"
EclipsePlugin.cantcopyartifact=Can''t copy artifact "{0}".