Index: src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (revision 580915) +++ src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (working copy) @@ -43,6 +43,7 @@ import org.apache.maven.plugin.eclipse.writers.EclipseWriterConfig; import org.apache.maven.plugin.eclipse.writers.wtp.EclipseWtpApplicationXMLWriter; 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; @@ -103,7 +104,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. @@ -682,6 +683,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 ) ); @@ -813,10 +818,14 @@ { 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(); + } new EclipseSettingsWriter().init( getLog(), config ).write(); Index: src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (revision 580915) +++ 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,36 @@ 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.getWtpapplicationxml() && kind.equals( ATTR_VAR ) + && !dep.isTestDependency() && !dep.isProvided() && !dep.isSystemScoped()) + { + 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: src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseManifestWriter.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseManifestWriter.java (revision 580915) +++ src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseManifestWriter.java (working copy) @@ -17,7 +17,6 @@ import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; @@ -25,8 +24,6 @@ import java.util.jar.Attributes; import java.util.jar.Manifest; -import org.apache.maven.archiver.ManifestConfiguration; -import org.apache.maven.archiver.MavenArchiver; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.eclipse.Constants; @@ -34,7 +31,6 @@ import org.apache.maven.plugin.eclipse.Messages; import org.apache.maven.plugin.eclipse.writers.wtp.AbstractWtpResourceWriter; import org.apache.maven.plugin.ide.IdeDependency; -import org.apache.maven.plugin.ide.IdeUtils; import org.apache.maven.plugin.logging.Log; import org.apache.maven.project.MavenProject; Index: src/main/java/org/apache/maven/plugin/eclipse/writers/workspace/EclipseCodeFormatterProfile.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/writers/workspace/EclipseCodeFormatterProfile.java (revision 580915) +++ src/main/java/org/apache/maven/plugin/eclipse/writers/workspace/EclipseCodeFormatterProfile.java (working copy) @@ -1,18 +1,14 @@ package org.apache.maven.plugin.eclipse.writers.workspace; -import java.io.BufferedReader; import java.io.ByteArrayOutputStream; -import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; import java.io.Reader; import java.net.URL; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.eclipse.Messages; -import org.apache.maven.plugin.logging.Log; import org.codehaus.plexus.util.IOUtil; import org.codehaus.plexus.util.xml.Xpp3Dom; import org.codehaus.plexus.util.xml.Xpp3DomBuilder; Index: src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java (revision 580915) +++ src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/AbstractWtpResourceWriter.java (working copy) @@ -18,8 +18,9 @@ */ package org.apache.maven.plugin.eclipse.writers.wtp; +import java.io.File; + import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.model.Plugin; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.eclipse.Messages; import org.apache.maven.plugin.eclipse.writers.AbstractEclipseWriter; @@ -28,12 +29,7 @@ import org.apache.maven.plugin.ide.JeeUtils; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.xml.XMLWriter; -import org.codehaus.plexus.util.xml.Xpp3Dom; -import java.io.File; -import java.util.Iterator; -import java.util.List; - /** * Base class to hold common constants used by extending classes. * Index: src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponent20Writer.java =================================================================== --- src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponent20Writer.java (revision 0) +++ src/main/java/org/apache/maven/plugin/eclipse/writers/wtp/EclipseWtpComponent20Writer.java (revision 0) @@ -0,0 +1,70 @@ +/* + * 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 org.apache.maven.artifact.repository.ArtifactRepository; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.ide.IdeDependency; +import org.apache.maven.plugin.ide.IdeUtils; +import org.apache.maven.project.MavenProject; +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 writeWarOrEarResources( XMLWriter writer, MavenProject project, ArtifactRepository localRepository ) + throws MojoExecutionException +{ + // use /WEB-INF/lib for war projects and / or the configured defaultLibBundleDir for ear projects + String deployDir = IdeUtils.getPluginSetting( config.getProject(), ARTIFACT_MAVEN_EAR_PLUGIN, + "defaultLibBundleDir", + "/" ); + + if (project.getPackaging().equals("war")) + { + deployDir = "/WEB-INF/lib"; + } + // dependencies + for ( int j = 0; j < config.getDeps().length; j++ ) + { + IdeDependency dep = config.getDeps()[j]; + + // non-project dependencies are not exported in WTP2 + if ( dep.isReferencedProject() ) + { + super.addDependency( writer, dep, localRepository, config.getProject().getBasedir(), deployDir ); + } + } +} +}