Index: maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
===================================================================
--- maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (revision 572678)
+++ maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (working copy)
@@ -40,6 +40,7 @@
import org.apache.maven.plugin.eclipse.writers.EclipseSettingsWriter;
import org.apache.maven.plugin.eclipse.writers.EclipseWriterConfig;
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponent15Writer;
+import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponent20Writer;
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpComponentWriter;
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpFacetsWriter;
import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpmodulesWriter;
@@ -100,7 +101,7 @@
protected static final String REQUIRED_PLUGINS_CONTAINER = "org.eclipse.pde.core.requiredPlugins"; //$NON-NLS-1$
// warning, order is important for binary search
- public static final String[] WTP_SUPPORTED_VERSIONS = new String[] { "1.0", "1.5", "R7", "none" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ public static final String[] WTP_SUPPORTED_VERSIONS = new String[] { "1.0", "1.5", "2.0", "R7", "none" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
/**
* Constant for 'artifactId' element in POM.xml.
@@ -665,6 +666,10 @@
{
wtpVersionFloat = 1.5f;
}
+ else if ( "2.0".equalsIgnoreCase( wtpversion ) ) //$NON-NLS-1$
+ {
+ wtpVersionFloat = 2.0f;
+ }
if ( !"none".equalsIgnoreCase( wtpversion ) )
{
getLog().info( Messages.getString( "EclipsePlugin.wtpversion", wtpversion ) );
@@ -792,10 +797,16 @@
{
new EclipseWtpComponentWriter().init( getLog(), config ).write();
}
- if ( wtpVersionFloat >= 1.5 )
+ if ( wtpVersionFloat == 1.5f )
{
new EclipseWtpComponent15Writer().init( getLog(), config ).write();
}
+
+ if ( wtpVersionFloat == 2.0f )
+ {
+ new EclipseWtpComponent20Writer().init( getLog(), config ).write();
+ config.setIncludeJ2eeDeps(true);
+ }
new EclipseSettingsWriter().init( getLog(), config ).write();
Index: maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
===================================================================
--- maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (revision 572678)
+++ maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (working copy)
@@ -362,6 +362,8 @@
String kind;
String sourcepath = null;
String javadocpath = null;
+
+ boolean attributeElemOpen = false;
if ( dep.isReferencedProject() && !config.isPde() )
{
@@ -463,16 +465,35 @@
if ( javadocpath != null )
{
- writer.startElement( "attributes" ); //$NON-NLS-1$
+ if (!attributeElemOpen) {
+ writer.startElement( "attributes" ); //$NON-NLS-1$
+ attributeElemOpen = true;
+ }
writer.startElement( "attribute" ); //$NON-NLS-1$
writer.addAttribute( "value", "jar:file:/" + javadocpath + "!/" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
writer.addAttribute( "name", "javadoc_location" ); //$NON-NLS-1$ //$NON-NLS-2$
writer.endElement();
+ }
+
+ if ( config.getIncludeJ2eeDeps() && kind.equals( ATTR_VAR ) )
+ {
+ if (!attributeElemOpen) {
+ writer.startElement( "attributes" ); //$NON-NLS-1$
+ attributeElemOpen = true;
+ }
+
+ writer.startElement( "attribute" ); //$NON-NLS-1$
+ writer.addAttribute( "value", "/WEB-INF/lib" ); //$NON-NLS-1$ //$NON-NLS-2$
+ writer.addAttribute( "name", "org.eclipse.jst.component.dependency" ); //$NON-NLS-1$ //$NON-NLS-2$
writer.endElement();
+
}
+ if (attributeElemOpen) {
+ writer.endElement();
+ }
writer.endElement();
}
Index: maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWriterConfig.java
===================================================================
--- maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWriterConfig.java (revision 572678)
+++ maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWriterConfig.java (working copy)
@@ -123,6 +123,11 @@
private String contextName;
+ /**
+ * Indicates whether or not the classpath entries should be marked to export as j2ee deps.
+ * For WTP 2.0+ compatibility.
+ */
+ private boolean includeJ2eeDeps = false;
/**
* Getter for deps.
@@ -416,4 +421,14 @@
this.contextName = deployName;
}
+ public boolean getIncludeJ2eeDeps()
+ {
+ return this.includeJ2eeDeps;
+ }
+
+ public void setIncludeJ2eeDeps( boolean includeJ2eeDeps )
+ {
+ this.includeJ2eeDeps = includeJ2eeDeps;
+ }
+
}
Index: maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponent20Writer.java
===================================================================
--- maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponent20Writer.java (revision 0)
+++ maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponent20Writer.java (revision 0)
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+package org.apache.maven.plugin.eclipse.writers.wtp;
+
+import java.io.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.ide.IdeDependency;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Component writer for WTP 2.0. Version has changed since 1.5. Other changes to .classpath
+ * @author Fabrizio Giustina
+ * @version $Id: EclipseWtpComponent15Writer.java 554291 2007-07-08 01:38:37Z brianf $
+ */
+public class EclipseWtpComponent20Writer
+ extends EclipseWtpComponent15Writer
+{
+
+ /**
+ * Version number added to component configuration.
+ * @return 2.0
+ */
+ protected String getProjectVersion()
+ {
+ return "2.0"; //$NON-NLS-1$
+ }
+
+ protected void addDependency( XMLWriter writer, IdeDependency dep, ArtifactRepository localRepository, File basedir )
+ throws MojoExecutionException
+ {
+ // non-project dependencies are not exported in WTP2
+ if ( dep.isReferencedProject() )
+ {
+ super.addDependency( writer, dep, localRepository, basedir );
+ }
+ }
+}