Author: fgiust Date: Mon Jun 26 10:32:48 2006 New Revision: 417246 URL: http://svn.apache.org/viewvc?rev=417246&view=rev Log: support for WTP 1.5 configuration (small changes in .component naming and format)
Added: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java (with props) maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/classpath maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.component maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml (with props) maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml (with props) maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/project maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt (with props) Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/AbstractEclipsePluginTestCase.java maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-19/ (props changed) Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java?rev=417246&r1=417245&r2=417246&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipseCleanMojo.java Mon Jun 26 10:32:48 2006 @@ -53,11 +53,16 @@ private static final String DIR_DOT_SETTINGS = ".settings"; //$NON-NLS-1$ /** - * File name where the WTP component settings will be stored for our Eclipse Project. + * File name where the WTP component settings will be stored - WTP 1.0 name. */ private static final String FILE_DOT_COMPONENT = ".settings/.component"; //$NON-NLS-1$ /** + * File name where the WTP component settings will be stored - WTP 1.5 name. + */ + private static final String FILE_DOT_COMPONENT_15 = ".settings/org.eclipse.wst.common.component"; //$NON-NLS-1$ + + /** * File name where Eclipse Project's Facet configuration will be stored. */ private static final String FILE_FACET_CORE_XML = ".settings/org.eclipse.wst.common.project.facet.core.xml"; //$NON-NLS-1$ @@ -94,6 +99,7 @@ delete( new File( basedir, FILE_DOT_WTPMODULES ) ); delete( new File( basedir, FILE_DOT_COMPONENT ) ); + delete( new File( basedir, FILE_DOT_COMPONENT_15 ) ); delete( new File( basedir, FILE_FACET_CORE_XML ) ); File settingsDir = new File( basedir, DIR_DOT_SETTINGS ); Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?rev=417246&r1=417245&r2=417246&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java Mon Jun 26 10:32:48 2006 @@ -30,6 +30,7 @@ import org.apache.maven.plugin.eclipse.writers.EclipseClasspathWriter; import org.apache.maven.plugin.eclipse.writers.EclipseProjectWriter; import org.apache.maven.plugin.eclipse.writers.EclipseSettingsWriter; +import org.apache.maven.plugin.eclipse.writers.EclipseWtpComponent15Writer; import org.apache.maven.plugin.eclipse.writers.EclipseWtpComponentWriter; import org.apache.maven.plugin.eclipse.writers.EclipseWtpFacetsWriter; import org.apache.maven.plugin.eclipse.writers.EclipseWtpmodulesWriter; @@ -79,7 +80,7 @@ private static final String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER = "org.eclipse.jdt.launching.JRE_CONTAINER"; //$NON-NLS-1$ // warning, order is important for binary search - public static final String[] WTP_SUPPORTED_VERSIONS = new String[] { "1.0", "R7", "none" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + public static final String[] WTP_SUPPORTED_VERSIONS = new String[] { "1.0", "1.5", "R7", "none" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ /** * Constant for 'artifactId' element in POM.xml. @@ -214,6 +215,11 @@ private boolean wtp10; /** + * Not a plugin parameter. Are we working with wtp 1.5? + */ + private boolean wtp15; + + /** * Not a plugin parameter. Is this a java project? */ private boolean isJavaProject; @@ -411,6 +417,10 @@ { wtp10 = true; } + else if ( "1.5".equalsIgnoreCase( wtpversion ) ) //$NON-NLS-1$ + { + wtp15 = true; + } if ( !"none".equalsIgnoreCase( wtpversion ) ) { getLog().info( Messages.getString( "EclipsePlugin.wtpversion", wtpversion ) ); @@ -506,14 +516,25 @@ localRepository, buildOutputDirectory ); } - else if ( wtp10 ) + + if ( wtp10 || wtp15 ) { new EclipseWtpFacetsWriter( getLog(), eclipseProjectDir, project, deps ).write( sourceDirs, localRepository, buildOutputDirectory ); + } + if ( wtp10 ) + { + new EclipseWtpComponentWriter( getLog(), eclipseProjectDir, project, deps ).write( sourceDirs, localRepository, buildOutputDirectory ); + } + if ( wtp15 ) + { + new EclipseWtpComponent15Writer( getLog(), eclipseProjectDir, project, deps ).write( sourceDirs, + localRepository, + buildOutputDirectory ); } new EclipseProjectWriter( getLog(), eclipseProjectDir, project, deps ).write( projectBaseDir, executedProject, Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java?rev=417246&r1=417245&r2=417246&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java Mon Jun 26 10:32:48 2006 @@ -55,6 +55,8 @@ protected static final String ATTR_MODULE_ID = "id"; //$NON-NLS-1$ + protected static final String ATTR_PROJECT_VERSION = "project-version"; //$NON-NLS-1$ + protected static final String ELT_PROJECT_MODULES = "project-modules"; //$NON-NLS-1$ protected static final String ARTIFACT_MAVEN_WAR_PLUGIN = "maven-war-plugin"; //$NON-NLS-1$ Added: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java Mon Jun 26 10:32:48 2006 @@ -0,0 +1,64 @@ +/* + * Copyright 2001-2005 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. + */ + +package org.apache.maven.plugin.eclipse.writers; + +import java.io.File; + +import org.apache.maven.plugin.ide.IdeDependency; +import org.apache.maven.plugin.logging.Log; +import org.apache.maven.project.MavenProject; + +/** + * Component writer for WTP 1.5. File name has changed in WTP 1.5rc2 and the <code>project-version</code> attribute has + * been added. These ones are the only differences + * @author Fabrizio Giustina + * @version $Id$ + */ +public class EclipseWtpComponent15Writer + extends EclipseWtpComponentWriter +{ + + /** + * @param log + * @param eclipseProjectDir + * @param project + * @param deps + */ + public EclipseWtpComponent15Writer( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps ) + { + super( log, eclipseProjectDir, project, deps ); + } + + /** + * File name where the WTP component settings will be stored for our Eclipse Project. + * @return <code>org.eclipse.wst.common.component</code> + */ + protected String getComponentFileName() + { + return "org.eclipse.wst.common.component"; //$NON-NLS-1$ + } + + /** + * Version number added to component configuration. + * @return <code>1.0</code> + */ + protected String getProjectVersion() + { + return "1.5.0"; //$NON-NLS-1$ + } + +} Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponent15Writer.java ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java?rev=417246&r1=417245&r2=417246&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java Mon Jun 26 10:32:48 2006 @@ -1,5 +1,3 @@ -package org.apache.maven.plugin.eclipse.writers; - /* * Copyright 2001-2005 The Apache Software Foundation. * @@ -16,6 +14,8 @@ * limitations under the License. */ +package org.apache.maven.plugin.eclipse.writers; + import java.io.File; import java.io.FileWriter; import java.io.IOException; @@ -43,6 +43,9 @@ extends AbstractWtpResourceWriter { + /** + * Context root attribute. + */ private static final String ATTR_CONTEXT_ROOT = "context-root"; //$NON-NLS-1$ /** @@ -52,8 +55,21 @@ /** * File name where the WTP component settings will be stored for our Eclipse Project. + * @return <code>.component</code> */ - private static final String FILE_DOT_COMPONENT = ".component"; //$NON-NLS-1$ + protected String getComponentFileName() + { + return ".component"; //$NON-NLS-1$ + } + + /** + * Version number added to component configuration. + * @return <code>1.0</code> + */ + protected String getProjectVersion() + { + return null; + } public EclipseWtpComponentWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps ) { @@ -71,7 +87,7 @@ FileWriter w; try { - w = new FileWriter( new File( settingsDir, FILE_DOT_COMPONENT ) ); + w = new FileWriter( new File( settingsDir, getComponentFileName() ) ); } catch ( IOException ex ) { @@ -87,12 +103,12 @@ } /** - * Writes out the module type settings for a Web Tools Project to a [EMAIL PROTECTED] #FILE_DOT_COMPONENT}. + * Writes out the module type settings for a Web Tools Project to a component file. * * @param writer * @param packaging * @param buildOutputDirectory - * @param referencedReactorArtifacts + * @param sourceDirs * @param localRepository * @throws MojoExecutionException */ @@ -102,6 +118,10 @@ { writer.startElement( ELT_PROJECT_MODULES ); writer.addAttribute( ATTR_MODULE_ID, "moduleCoreId" ); //$NON-NLS-1$ + if ( getProjectVersion() != null ) + { + writer.addAttribute( ATTR_PROJECT_VERSION, getProjectVersion() ); + } writer.startElement( ELT_WB_MODULE ); writer.addAttribute( ATTR_DEPLOY_NAME, getProject().getArtifactId() ); Modified: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/AbstractEclipsePluginTestCase.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/AbstractEclipsePluginTestCase.java?rev=417246&r1=417245&r2=417246&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/AbstractEclipsePluginTestCase.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/AbstractEclipsePluginTestCase.java Mon Jun 26 10:32:48 2006 @@ -160,6 +160,14 @@ new File( projectOutputDir, ".settings/.component" ) ); } + // WTP15 + File component15ExpectedFile = new File( basedir, "org.eclipse.wst.common.component" ); + if ( component15ExpectedFile.exists() ) + { + assertFileEquals( localRepositoryDir.getCanonicalPath(), component15ExpectedFile, + new File( projectOutputDir, ".settings/org.eclipse.wst.common.component" ) ); + } + } protected void assertFileEquals( String mavenRepo, File expectedFile, File actualFile ) Modified: maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java?rev=417246&r1=417245&r2=417246&view=diff ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java (original) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/java/org/apache/maven/plugin/eclipse/EclipsePluginTest.java Mon Jun 26 10:32:48 2006 @@ -183,4 +183,14 @@ testProject( "project-19" ); } + /** + * WTP 1.5 changes in wtpmodules. + * @throws Exception any exception thrown during test + */ + public void testProject20() + throws Exception + { + testProject( "project-20" ); + } + } Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-19/ ------------------------------------------------------------------------------ --- svn:ignore (original) +++ svn:ignore Mon Jun 26 10:32:48 2006 @@ -1,3 +1,5 @@ + .project .classpath target +resourceoutput Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/classpath URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/classpath?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/classpath (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/classpath Mon Jun 26 10:32:48 2006 @@ -0,0 +1,5 @@ +<classpath> + <classpathentry kind="src" path="src/main/java"/> + <classpathentry kind="output" path="target/classes"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> +</classpath> \ No newline at end of file Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.component URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.component?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.component (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.component Mon Jun 26 10:32:48 2006 @@ -0,0 +1,5 @@ +<project-modules id="moduleCoreId" project-version="1.5.0"> + <wb-module deploy-name="maven-eclipse-plugin-test-project-20"> + <wb-resource deploy-path="/" source-path="src/main/java"/> + </wb-module> +</project-modules> \ No newline at end of file Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml Mon Jun 26 10:32:48 2006 @@ -0,0 +1,6 @@ +<faceted-project> + <fixed facet="jst.java"/> + <fixed facet="jst.utility"/> + <installed facet="jst.utility" version="1.0"/> + <installed facet="jst.java" version="1.4"/> +</faceted-project> \ No newline at end of file Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/org.eclipse.wst.common.project.facet.core.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml Mon Jun 26 10:32:48 2006 @@ -0,0 +1,19 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>eclipse</groupId> + <artifactId>maven-eclipse-plugin-test-project-20</artifactId> + <version>20</version> + <name>maven-eclipse-plugin-test-project-20</name> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-eclipse-plugin</artifactId> + <configuration> + <wtpversion>1.5</wtpversion> + </configuration> + </plugin> + </plugins> + </build> +</project> Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/pom.xml ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/project URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/project?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/project (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/project Mon Jun 26 10:32:48 2006 @@ -0,0 +1,14 @@ +<projectDescription> + <name>maven-eclipse-plugin-test-project-20</name> + <comment/> + <projects/> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments/> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> \ No newline at end of file Added: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt?rev=417246&view=auto ============================================================================== --- maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt (added) +++ maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt Mon Jun 26 10:32:48 2006 @@ -0,0 +1,7 @@ +/** + * @author <a href="mailto:[EMAIL PROTECTED]">Trygve Laugstøl</a> + * @version $Id$ + */ +public class DummyClass +{ +} Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/plugins/trunk/maven-eclipse-plugin/src/test/projects/project-20/src/main/java/DummyClass.txt ------------------------------------------------------------------------------ svn:keywords = Author Date Id Revision