You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by re...@apache.org on 2006/04/24 12:25:33 UTC

svn commit: r396502 [2/6] - in /cocoon/trunk/tools/cocoon-maven-eclipse-plugin: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/plugin/ src/main/java/org/apach...

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/Messages.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/Messages.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/Messages.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/Messages.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,66 @@
+package org.apache.maven.plugin.eclipse;
+
+/*
+ * 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.
+ */
+
+import java.text.MessageFormat;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
+ * @version $Id: Messages.java 359477 2005-12-28 10:51:19Z fgiust $
+ */
+public class Messages
+{
+
+    private static final String BUNDLE_NAME = "org.apache.maven.plugin.eclipse.messages"; //$NON-NLS-1$
+
+    private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle( BUNDLE_NAME );
+
+    private Messages()
+    {
+    }
+
+    public static String getString( String key )
+    {
+        try
+        {
+            return RESOURCE_BUNDLE.getString( key );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+
+    public static String getString( String key, Object[] params )
+    {
+        try
+        {
+            return MessageFormat.format( RESOURCE_BUNDLE.getString( key ), params );
+        }
+        catch ( MissingResourceException e )
+        {
+            return '!' + key + '!';
+        }
+    }
+
+    public static String getString( String key, Object param )
+    {
+        return getString( key, new Object[] { param } );
+    }
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/Messages.java
------------------------------------------------------------------------------
    eol:style = 'native'

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractEclipseResourceWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractEclipseResourceWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractEclipseResourceWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractEclipseResourceWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,66 @@
+/**
+ * 
+ */
+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;
+
+/**
+ * Common base class for all Eclipse Writers.
+ * 
+ * @author <a href="mailto:rahul.thakur.xdev@gmail.com">Rahul Thakur</a>
+ * @version $Id: AbstractEclipseResourceWriter.java 390686 2006-04-01 15:39:33Z fgiust $
+ */
+public abstract class AbstractEclipseResourceWriter
+{
+
+    private Log log;
+
+    private File eclipseProjectDir;
+
+    private MavenProject project;
+
+    protected IdeDependency[] deps;
+
+    /**
+     * @param log
+     * @param eclipseProjectDir
+     * @param project
+     */
+    public AbstractEclipseResourceWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        this.log = log;
+        this.eclipseProjectDir = eclipseProjectDir;
+        this.project = project;
+        this.deps = deps;
+    }
+
+    /**
+     * @return the eclipseProjectDir
+     */
+    public File getEclipseProjectDirectory()
+    {
+        return eclipseProjectDir;
+    }
+
+    /**
+     * @return the log
+     */
+    public Log getLog()
+    {
+        return log;
+    }
+
+    /**
+     * @return the project
+     */
+    public MavenProject getProject()
+    {
+        return project;
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractEclipseResourceWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,295 @@
+/**
+ * 
+ */
+package org.apache.maven.plugin.eclipse.writers;
+
+import java.io.File;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.EclipseSourceDir;
+import org.apache.maven.plugin.eclipse.Messages;
+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;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Base class to hold common constants used by extending classes.
+ * @author <a href="mailto:rahul.thakur.xdev@gmail.com">Rahul Thakur</a>
+ * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
+ */
+public abstract class AbstractWtpResourceWriter
+    extends AbstractEclipseResourceWriter
+{
+
+    private static final String ELT_DEPENDENCY_TYPE = "dependency-type"; //$NON-NLS-1$
+
+    private static final String ATTR_HANDLE = "handle"; //$NON-NLS-1$
+
+    private static final String ELT_DEPENDENT_MODULE = "dependent-module"; //$NON-NLS-1$
+
+    protected static final String ATTR_VALUE = "value"; //$NON-NLS-1$
+
+    protected static final String ATTR_NAME = "name"; //$NON-NLS-1$
+
+    protected static final String ELT_PROPERTY = "property"; //$NON-NLS-1$
+
+    protected static final String ELT_VERSION = "version"; //$NON-NLS-1$
+
+    protected static final String ATTR_MODULE_TYPE_ID = "module-type-id"; //$NON-NLS-1$
+
+    protected static final String ATTR_SOURCE_PATH = "source-path"; //$NON-NLS-1$
+
+    protected static final String ATTR_DEPLOY_PATH = "deploy-path"; //$NON-NLS-1$
+
+    protected static final String ELT_WB_RESOURCE = "wb-resource"; //$NON-NLS-1$
+
+    protected static final String ELT_MODULE_TYPE = "module-type"; //$NON-NLS-1$
+
+    protected static final String ATTR_DEPLOY_NAME = "deploy-name"; //$NON-NLS-1$
+
+    protected static final String ELT_WB_MODULE = "wb-module"; //$NON-NLS-1$
+
+    protected static final String ATTR_MODULE_ID = "id"; //$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$
+
+    public AbstractWtpResourceWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    /**
+     * Returns Dependent artifacts for our project.
+     * 
+     * @return
+     */
+    protected IdeDependency[] getDependencies()
+    {
+        return this.deps;
+    }
+
+    /**
+     * Common elements of configuration are handled here.
+     * 
+     * @param sourceDirs
+     * @param localRepository
+     * @param buildOutputDirectory
+     * @throws MojoExecutionException
+     */
+    public abstract void write( EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository,
+                                File buildOutputDirectory )
+        throws MojoExecutionException;
+
+    /**
+     * @param project
+     * @param writer
+     * @param packaging
+     * @throws MojoExecutionException
+     */
+    protected void writeModuleTypeAccordingToPackaging( MavenProject project, XMLWriter writer, String packaging,
+                                                        File buildOutputDirectory )
+        throws MojoExecutionException
+    {
+        if ( "war".equals( packaging ) ) //$NON-NLS-1$
+        {
+            writer.addAttribute( ATTR_MODULE_TYPE_ID, "jst.web" ); //$NON-NLS-1$ 
+
+            writer.startElement( ELT_VERSION );
+
+            writer.writeText( resolveServletVersion() );
+            writer.endElement();
+
+            // use finalName as context root only if it has been explicitely set
+            String contextRoot = project.getArtifactId();
+            String finalName = project.getBuild().getFinalName();
+            if ( !finalName.equals( project.getArtifactId() + "-" + project.getVersion() ) ) //$NON-NLS-1$
+            {
+                contextRoot = finalName;
+            }
+
+            writer.startElement( ELT_PROPERTY );
+            writer.addAttribute( ATTR_NAME, "context-root" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_VALUE, contextRoot );
+            writer.endElement();
+        }
+        else if ( "ejb".equals( packaging ) ) //$NON-NLS-1$
+        {
+            writer.addAttribute( ATTR_MODULE_TYPE_ID, "jst.ejb" ); //$NON-NLS-1$ 
+
+            writer.startElement( ELT_VERSION );
+            writer.writeText( resolveEjbVersion() );
+
+            writer.endElement();
+
+            writer.startElement( ELT_PROPERTY );
+            writer.addAttribute( ATTR_NAME, "java-output-path" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_VALUE, "/" + //$NON-NLS-1$ 
+                IdeUtils.toRelativeAndFixSeparator( getProject().getBasedir(), buildOutputDirectory, false ) );
+            writer.endElement();
+
+        }
+        else if ( "ear".equals( packaging ) ) //$NON-NLS-1$
+        {
+            writer.addAttribute( ATTR_MODULE_TYPE_ID, "jst.ear" ); //$NON-NLS-1$ 
+
+            writer.startElement( ELT_VERSION );
+            writer.writeText( resolveJ2eeVersion() );
+            writer.endElement();
+        }
+        else
+        {
+            // jar
+            writer.addAttribute( ATTR_MODULE_TYPE_ID, "jst.utility" ); //$NON-NLS-1$ 
+
+            writer.startElement( ELT_PROPERTY );
+            writer.addAttribute( ATTR_NAME, "java-output-path" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_VALUE, "/" + //$NON-NLS-1$ 
+                IdeUtils.toRelativeAndFixSeparator( getProject().getBasedir(), buildOutputDirectory, false ) );
+            writer.endElement();
+        }
+    }
+
+    /**
+     * Adds dependency for Eclipse WTP project.
+     * 
+     * @param writer
+     * @param artifact
+     * @param localRepository
+     * @param basedir
+     * @throws MojoExecutionException
+     */
+    protected void addDependency( XMLWriter writer, IdeDependency dep, ArtifactRepository localRepository, File basedir )
+        throws MojoExecutionException
+    {
+        String handle;
+
+        if ( dep.isReferencedProject() )
+        {
+            // <dependent-module deploy-path="/WEB-INF/lib"
+            // handle="module:/resource/artifactid/artifactid">
+            // <dependency-type>uses</dependency-type>
+            // </dependent-module>
+
+            handle = "module:/resource/" + dep.getArtifactId() + "/" + dep.getArtifactId(); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+        else
+        {
+            // <dependent-module deploy-path="/WEB-INF/lib"
+            // handle="module:/classpath/var/M2_REPO/cl/cl/2.1/cl-2.1.jar">
+            // <dependency-type>uses</dependency-type>
+            // </dependent-module>
+
+            File artifactPath = dep.getFile();
+
+            if ( artifactPath == null )
+            {
+                getLog().error( Messages.getString( "EclipsePlugin.artifactpathisnull", dep.getId() ) ); //$NON-NLS-1$
+                return;
+            }
+
+            String fullPath = artifactPath.getPath();
+            File repoFile = new File( fullPath );
+
+            if ( dep.isSystemScoped() )
+            {
+                handle = "module:/classpath/lib/" //$NON-NLS-1$
+                    + IdeUtils.toRelativeAndFixSeparator( getEclipseProjectDirectory(), repoFile, false );
+            }
+            else
+            {
+                File localRepositoryFile = new File( localRepository.getBasedir() );
+
+                handle = "module:/classpath/var/M2_REPO/" //$NON-NLS-1$
+                    + IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, repoFile, false );
+            }
+        }
+
+        writer.startElement( ELT_DEPENDENT_MODULE );
+
+        writer.addAttribute( ATTR_DEPLOY_PATH, "/WEB-INF/lib" ); //$NON-NLS-1$ 
+        writer.addAttribute( ATTR_HANDLE, handle );
+
+        writer.startElement( ELT_DEPENDENCY_TYPE );
+        writer.writeText( "uses" ); //$NON-NLS-1$
+        writer.endElement();
+
+        writer.endElement();
+    }
+
+    protected void writeWarOrEarResources( XMLWriter writer, MavenProject project, ArtifactRepository localRepository )
+        throws MojoExecutionException
+    {
+
+        // dependencies
+        for ( int j = 0; j < deps.length; j++ )
+        {
+            IdeDependency dep = deps[j];
+            String type = dep.getType();
+
+            // NB war is needed for ear projects, we suppose nobody adds a war dependency to a war/jar project
+            // exclude test and provided deps
+            if ( ( !dep.isTestDependency() && !dep.isProvided() )
+                && ( "jar".equals( type ) || "ejb".equals( type ) || "ejb-client".equals( type ) || "war".equals( type ) ) ) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+            {
+                addDependency( writer, dep, localRepository, getProject().getBasedir() );
+            }
+        }
+    }
+
+    protected String resolveServletVersion()
+    {
+        String[] artifactNames = new String[] { "servlet-api", "servletapi", "geronimo-spec-servlet" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+        String version = IdeUtils.getDependencyVersion( artifactNames, getProject().getArtifacts(), 3 );
+        if ( version == null )
+        {
+            // none of the above specified matched, try geronimo-spec-j2ee
+            artifactNames = new String[] { "geronimo-spec-j2ee" }; //$NON-NLS-1$
+            version = IdeUtils.getDependencyVersion( artifactNames, getProject().getArtifacts(), 3 );
+            if ( version != null )
+            {
+                String j2eeMinorVersion = StringUtils.substring( version, 2, 3 );
+                version = "2." + j2eeMinorVersion; //$NON-NLS-1$
+            }
+        }
+        return version == null ? "2.4" : version; //$NON-NLS-1$
+    }
+
+    protected String resolveEjbVersion()
+    {
+        String version = null;
+        // @todo this is the default, find real ejb version from dependencies
+
+        return version == null ? "2.1" : version; //$NON-NLS-1$
+    }
+
+    protected String resolveJ2eeVersion()
+    {
+        String version = null;
+        // @todo this is the default, find real j2ee version from dependencies
+        return version == null ? "1.3" : version; //$NON-NLS-1$
+    }
+
+    protected String resolveJavaVersion()
+    {
+        String version = IdeUtils.getPluginSetting( getProject(), "maven-compiler-plugin", "target", null ); //$NON-NLS-1$ //$NON-NLS-2$
+        if ( version == null )
+        {
+            IdeUtils.getPluginSetting( getProject(), "maven-compiler-plugin", "source", null ); //$NON-NLS-1$ //$NON-NLS-2$
+        }
+
+        if ( "1.5".equals( version ) || "5".equals( version ) ) //$NON-NLS-1$ //$NON-NLS-2$
+        {
+            version = "5.0";// see MECLIPSE-47 eclipse only accept 5.0 as a valid version //$NON-NLS-1$
+        }
+
+        return version == null ? "1.4" : version; //$NON-NLS-1$
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/AbstractWtpResourceWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,300 @@
+package org.apache.maven.plugin.eclipse.writers;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.EclipseSourceDir;
+import org.apache.maven.plugin.eclipse.Messages;
+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;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Writes eclipse .classpath file.
+ *
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
+ * @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
+ * @version $Id: EclipseClasspathWriter.java 391954 2006-04-06 10:21:29Z fgiust $
+ */
+public class EclipseClasspathWriter
+    extends AbstractEclipseResourceWriter
+{
+
+    /**
+     * Eclipse build path variable M2_REPO
+     */
+    private static final String M2_REPO = "M2_REPO"; //$NON-NLS-1$
+
+    private File eclipseProjectDir;
+
+    /**
+     * Attribute for sourcepath.
+     */
+    private static final String ATTR_SOURCEPATH = "sourcepath"; //$NON-NLS-1$
+
+    private MavenProject project;
+
+    /**
+     * Attribute for output.
+     */
+    private static final String ATTR_OUTPUT = "output"; //$NON-NLS-1$
+
+    /**
+     * Attribute for path.
+     */
+    private static final String ATTR_PATH = "path"; //$NON-NLS-1$
+
+    /**
+     * Attribute for kind - Container (con), Variable (var)..etc.
+     */
+    private static final String ATTR_KIND = "kind"; //$NON-NLS-1$
+
+    /**
+     * Element for classpathentry.
+     */
+    private static final String ELT_CLASSPATHENTRY = "classpathentry"; //$NON-NLS-1$
+
+    /**
+     * Element for classpath.
+     */
+    private static final String ELT_CLASSPATH = "classpath"; //$NON-NLS-1$
+
+    /**
+     * File name that stores project classpath settings.
+     */
+    private static final String FILE_DOT_CLASSPATH = ".classpath"; //$NON-NLS-1$
+
+    public EclipseClasspathWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    public void write( File projectBaseDir, EclipseSourceDir[] sourceDirs, List classpathContainers,
+                       ArtifactRepository localRepository, File buildOutputDirectory, boolean rcp )
+        throws MojoExecutionException
+    {
+
+        FileWriter w;
+
+        try
+        {
+            w = new FileWriter( new File( getEclipseProjectDirectory(), FILE_DOT_CLASSPATH ) );
+        }
+        catch ( IOException ex )
+        {
+            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+        }
+
+        XMLWriter writer = new PrettyPrintXMLWriter( w );
+
+        writer.startElement( ELT_CLASSPATH );
+
+        String defaultOutput = IdeUtils.toRelativeAndFixSeparator( projectBaseDir, buildOutputDirectory, false );
+
+        // ----------------------------------------------------------------------
+        // Source roots and resources
+        // ----------------------------------------------------------------------
+
+        for ( int j = 0; j < sourceDirs.length; j++ )
+        {
+            EclipseSourceDir dir = sourceDirs[j];
+
+            writer.startElement( ELT_CLASSPATHENTRY );
+
+            writer.addAttribute( ATTR_KIND, "src" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_PATH, dir.getPath() );
+            if ( dir.getOutput() != null && !defaultOutput.equals( dir.getOutput() ) )
+            {
+                writer.addAttribute( ATTR_OUTPUT, dir.getOutput() );
+            }
+
+            writer.endElement();
+
+        }
+
+        // ----------------------------------------------------------------------
+        // The default output
+        // ----------------------------------------------------------------------
+
+        writer.startElement( ELT_CLASSPATHENTRY );
+        writer.addAttribute( ATTR_KIND, ATTR_OUTPUT );
+        writer.addAttribute( ATTR_PATH, defaultOutput );
+        writer.endElement();
+
+        // ----------------------------------------------------------------------
+        // Container classpath entries
+        // ----------------------------------------------------------------------
+
+        for ( Iterator it = classpathContainers.iterator(); it.hasNext(); )
+        {
+            writer.startElement( ELT_CLASSPATHENTRY );
+            writer.addAttribute( ATTR_KIND, "con" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_PATH, (String) it.next() );
+            writer.endElement(); // name
+        }
+
+        // ----------------------------------------------------------------------
+        // The dependencies
+        // ----------------------------------------------------------------------
+
+        for ( int j = 0; j < deps.length; j++ )
+        {
+            IdeDependency dep = deps[j];
+
+            if ( dep.isAddedToClasspath() )
+            {
+                addDependency( writer, dep, localRepository, rcp );
+            }
+        }
+
+        writer.endElement();
+
+        IOUtil.close( w );
+
+    }
+
+    private void addDependency( XMLWriter writer, IdeDependency dep, ArtifactRepository localRepository, boolean rcp )
+        throws MojoExecutionException
+    {
+
+        String path;
+        String kind;
+        String sourcepath = null;
+        String javadocpath = null;
+
+        if ( dep.isReferencedProject() )
+        {
+            path = "/" + dep.getArtifactId(); //$NON-NLS-1$
+            kind = "src"; //$NON-NLS-1$
+        }
+        else
+        {
+            File artifactPath = dep.getFile();
+
+            if ( artifactPath == null )
+            {
+                getLog().error( Messages.getString( "EclipsePlugin.artifactpathisnull", dep.getId() ) ); //$NON-NLS-1$
+                return;
+            }
+
+            if ( dep.isSystemScoped() )
+            {
+                path = IdeUtils.toRelativeAndFixSeparator( getEclipseProjectDirectory(), artifactPath, false );
+
+                if ( getLog().isDebugEnabled() )
+                {
+                    getLog().debug( Messages.getString( "EclipsePlugin.artifactissystemscoped", //$NON-NLS-1$
+                                                        new Object[] { dep.getArtifactId(), path } ) );
+                }
+
+                kind = "lib"; //$NON-NLS-1$
+            }
+            else
+            {
+                File localRepositoryFile = new File( localRepository.getBasedir() );
+                
+                if ( dep.isOSGiBundle() && rcp )
+                {
+                	// do nothing as required bundles need to be added to the Eclipse target platform
+                	return;
+                }                
+                else if ( !dep.isOSGiBundle() && rcp ) // && !dep.isTestDependency() && !dep.isProvided() )
+                {
+	                String libs = "target/osgi/lib";
+	                try {
+	                	File libsDir = new File(libs);
+	                	if(!libsDir.exists()) {
+	                		libsDir.mkdirs();
+	                	}
+						FileUtils.copyFileToDirectory(dep.getFile(), libsDir);
+						
+					} 
+	                catch (IOException e) 
+	                {
+						throw new MojoExecutionException("Can't copy artifact '" + dep.getArtifactId() + "'");
+					}
+	                path = libs + "/" + dep.getFile().getName();
+	                kind = "lib";
+                } 
+                else 
+                {           	
+
+	
+	                String fullPath = artifactPath.getPath();
+	
+	                path = "M2_REPO/" //$NON-NLS-1$
+	                    + IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, new File( fullPath ), false );
+	
+	                kind = "var"; //$NON-NLS-1$
+                }
+                if ( dep.getSourceAttachment() != null )
+                {
+                    sourcepath = "M2_REPO/" //$NON-NLS-1$
+                        + IdeUtils.toRelativeAndFixSeparator( localRepositoryFile, dep.getSourceAttachment(), false );
+                }
+
+                if ( dep.getJavadocAttachment() != null )
+                {
+                    //                  NB eclipse (3.1) doesn't support variables in javadoc paths, so we need to add the
+                    // full path for the maven repo
+                    javadocpath = StringUtils.replace( IdeUtils.getCanonicalPath( dep.getJavadocAttachment() ),
+                                                       "\\", "/" ); //$NON-NLS-1$ //$NON-NLS-2$
+                }
+
+            }
+
+        }
+
+        writer.startElement( "classpathentry" ); //$NON-NLS-1$
+        writer.addAttribute( "kind", kind ); //$NON-NLS-1$
+        writer.addAttribute( "path", path ); //$NON-NLS-1$
+
+        if ( sourcepath != null )
+        {
+            writer.addAttribute( "sourcepath", sourcepath ); //$NON-NLS-1$
+        }
+        else if ( javadocpath != null )
+        {
+            writer.startElement( "attributes" ); //$NON-NLS-1$
+
+            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();
+
+            writer.endElement();
+        }
+
+        writer.endElement();
+
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseClasspathWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,331 @@
+package org.apache.maven.plugin.eclipse.writers;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
+import java.util.Iterator;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.Messages;
+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;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+import org.codehaus.plexus.util.xml.Xpp3Dom;
+import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
+
+/**
+ * Writes eclipse .project file.
+ *
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
+ * @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
+ * @version $Id: EclipseProjectWriter.java 391639 2006-04-05 15:33:13Z fgiust $
+ */
+public class EclipseProjectWriter
+    extends AbstractEclipseResourceWriter
+{
+
+    private static final String ELT_NAME = "name"; //$NON-NLS-1$
+
+    private static final String ELT_BUILD_COMMAND = "buildCommand"; //$NON-NLS-1$
+
+    private static final String ELT_BUILD_SPEC = "buildSpec"; //$NON-NLS-1$
+
+    private static final String ELT_NATURE = "nature"; //$NON-NLS-1$
+
+    private static final String ELT_NATURES = "natures"; //$NON-NLS-1$
+
+    private static final String FILE_DOT_PROJECT = ".project"; //$NON-NLS-1$
+
+    public EclipseProjectWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    public void write( File projectBaseDir, MavenProject executedProject, List addedProjectnatures,
+                       List addedBuildCommands )
+        throws MojoExecutionException
+    {
+
+        Set projectnatures = new LinkedHashSet();
+        Set buildCommands = new LinkedHashSet();
+
+        File dotProject = new File( getEclipseProjectDirectory(), FILE_DOT_PROJECT );
+
+        if ( dotProject.exists() )
+        {
+
+            getLog().info( Messages.getString( "EclipsePlugin.keepexisting", dotProject.getAbsolutePath() ) ); //$NON-NLS-1$
+
+            // parse existing file in order to keep manually-added entries
+            FileReader reader = null;
+            try
+            {
+                reader = new FileReader( dotProject );
+                Xpp3Dom dom = Xpp3DomBuilder.build( reader );
+
+                Xpp3Dom naturesElement = dom.getChild( ELT_NATURES );
+                if ( naturesElement != null )
+                {
+                    Xpp3Dom[] existingNatures = naturesElement.getChildren( ELT_NATURE );
+                    for ( int j = 0; j < existingNatures.length; j++ )
+                    {
+                        // adds all the existing natures
+                        projectnatures.add( existingNatures[j].getValue() );
+                    }
+                }
+
+                Xpp3Dom buildSpec = dom.getChild( ELT_BUILD_SPEC );
+                if ( buildSpec != null )
+                {
+                    Xpp3Dom[] existingBuildCommands = buildSpec.getChildren( ELT_BUILD_COMMAND );
+                    for ( int j = 0; j < existingBuildCommands.length; j++ )
+                    {
+                        Xpp3Dom buildCommandName = existingBuildCommands[j].getChild( ELT_NAME );
+                        if ( buildCommandName != null )
+                        {
+                            buildCommands.add( buildCommandName.getValue() );
+                        }
+                    }
+                }
+            }
+            catch ( XmlPullParserException e )
+            {
+                getLog().warn( Messages.getString( "EclipsePlugin.cantparseexisting", dotProject.getAbsolutePath() ) ); //$NON-NLS-1$
+            }
+            catch ( IOException e )
+            {
+                getLog().warn( Messages.getString( "EclipsePlugin.cantparseexisting", dotProject.getAbsolutePath() ) ); //$NON-NLS-1$
+            }
+            finally
+            {
+                IOUtil.close( reader );
+            }
+        }
+
+        // adds new entries after the existing ones
+        for ( Iterator iter = addedProjectnatures.iterator(); iter.hasNext(); )
+        {
+            projectnatures.add( iter.next() );
+        }
+        for ( Iterator iter = addedBuildCommands.iterator(); iter.hasNext(); )
+        {
+            buildCommands.add( iter.next() );
+        }
+
+        Writer w;
+
+        try
+        {
+            w = new OutputStreamWriter( new FileOutputStream( dotProject ), "UTF-8" );
+        }
+        catch ( IOException ex )
+        {
+            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+        }
+
+        XMLWriter writer = new PrettyPrintXMLWriter( w );
+
+        writer.startElement( "projectDescription" ); //$NON-NLS-1$
+
+        writer.startElement( ELT_NAME );
+        writer.writeText( getProject().getArtifactId() );
+        writer.endElement();
+
+        // TODO: this entire element might be dropped if the comment is null.
+        // but as the maven1 eclipse plugin does it, it's better to be safe than sorry
+        // A eclipse developer might want to look at this.
+        writer.startElement( "comment" ); //$NON-NLS-1$
+
+        if ( getProject().getDescription() != null )
+        {
+            writer.writeText( getProject().getDescription() );
+        }
+
+        writer.endElement();
+
+        writer.startElement( "projects" ); //$NON-NLS-1$
+
+        for ( int j = 0; j < deps.length; j++ )
+        {
+            IdeDependency dep = deps[j];
+            if ( dep.isReferencedProject() )
+            {
+                writer.startElement( "project" ); //$NON-NLS-1$
+                writer.writeText( dep.getArtifactId() );
+                writer.endElement();
+            }
+        }
+
+        writer.endElement(); // projects
+
+        writer.startElement( ELT_BUILD_SPEC );
+
+        for ( Iterator it = buildCommands.iterator(); it.hasNext(); )
+        {
+            writer.startElement( ELT_BUILD_COMMAND );
+            writer.startElement( ELT_NAME );
+            writer.writeText( (String) it.next() );
+            writer.endElement(); // name
+            writer.startElement( "arguments" ); //$NON-NLS-1$
+            writer.endElement(); // arguments
+            writer.endElement(); // buildCommand
+        }
+
+        writer.endElement(); // buildSpec
+
+        writer.startElement( ELT_NATURES );
+
+        for ( Iterator it = projectnatures.iterator(); it.hasNext(); )
+        {
+            writer.startElement( ELT_NATURE );
+            writer.writeText( (String) it.next() );
+            writer.endElement(); // name
+        }
+
+        writer.endElement(); // natures
+
+        if ( !projectBaseDir.equals( getEclipseProjectDirectory() ) )
+        {
+            writer.startElement( "linkedResources" ); //$NON-NLS-1$
+
+            addFileLink( writer, projectBaseDir, getEclipseProjectDirectory(), getProject().getFile() );
+
+            addSourceLinks( writer, projectBaseDir, getEclipseProjectDirectory(), executedProject
+                .getCompileSourceRoots() );
+            addResourceLinks( writer, projectBaseDir, getEclipseProjectDirectory(), executedProject.getBuild()
+                .getResources() );
+
+            addSourceLinks( writer, projectBaseDir, getEclipseProjectDirectory(), executedProject
+                .getTestCompileSourceRoots() );
+            addResourceLinks( writer, projectBaseDir, getEclipseProjectDirectory(), executedProject.getBuild()
+                .getTestResources() );
+
+            writer.endElement(); // linedResources
+        }
+
+        writer.endElement(); // projectDescription
+
+        IOUtil.close( w );
+    }
+
+    private void addFileLink( XMLWriter writer, File projectBaseDir, File basedir, File file )
+        throws MojoExecutionException
+    {
+        if ( file.isFile() )
+        {
+            writer.startElement( "link" ); //$NON-NLS-1$
+
+            writer.startElement( ELT_NAME );
+            writer.writeText( IdeUtils.toRelativeAndFixSeparator( projectBaseDir, file, true ) );
+            writer.endElement(); // name
+
+            writer.startElement( "type" ); //$NON-NLS-1$
+            writer.writeText( "1" ); //$NON-NLS-1$
+            writer.endElement(); // type
+
+            writer.startElement( "location" ); //$NON-NLS-1$
+
+            writer.writeText( IdeUtils.getCanonicalPath( file ).replaceAll( "\\\\", "/" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+            writer.endElement(); // location
+
+            writer.endElement(); // link
+        }
+        else
+        {
+            getLog().warn( Messages.getString( "EclipseProjectWriter.notafile", file ) ); //$NON-NLS-1$
+        }
+    }
+
+    private void addSourceLinks( XMLWriter writer, File projectBaseDir, File basedir, List sourceRoots )
+        throws MojoExecutionException
+    {
+        for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
+        {
+            String sourceRootString = (String) it.next();
+            File sourceRoot = new File( sourceRootString );
+
+            if ( sourceRoot.isDirectory() )
+            {
+                writer.startElement( "link" ); //$NON-NLS-1$
+
+                writer.startElement( ELT_NAME );
+                writer.writeText( IdeUtils.toRelativeAndFixSeparator( projectBaseDir, sourceRoot, true ) );
+                writer.endElement(); // name
+
+                writer.startElement( "type" ); //$NON-NLS-1$
+                writer.writeText( "2" ); //$NON-NLS-1$
+                writer.endElement(); // type
+
+                writer.startElement( "location" ); //$NON-NLS-1$
+
+                writer.writeText( IdeUtils.getCanonicalPath( sourceRoot ).replaceAll( "\\\\", "/" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+                writer.endElement(); // location
+
+                writer.endElement(); // link
+            }
+        }
+    }
+
+    private void addResourceLinks( XMLWriter writer, File projectBaseDir, File basedir, List sourceRoots )
+        throws MojoExecutionException
+    {
+        for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
+        {
+            String resourceDirString = ( (Resource) it.next() ).getDirectory();
+            File resourceDir = new File( resourceDirString );
+
+            if ( resourceDir.isDirectory() )
+            {
+                writer.startElement( "link" ); //$NON-NLS-1$
+
+                writer.startElement( ELT_NAME );
+                writer.writeText( IdeUtils.toRelativeAndFixSeparator( projectBaseDir, resourceDir, true ) );
+                writer.endElement(); // name
+
+                writer.startElement( "type" ); //$NON-NLS-1$
+                writer.writeText( "2" ); //$NON-NLS-1$
+                writer.endElement(); // type
+
+                writer.startElement( "location" ); //$NON-NLS-1$
+
+                writer.writeText( IdeUtils.getCanonicalPath( resourceDir ).replaceAll( "\\\\", "/" ) ); //$NON-NLS-1$ //$NON-NLS-2$
+
+                writer.endElement(); // location
+
+                writer.endElement(); // link
+            }
+        }
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseSettingsWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseSettingsWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseSettingsWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseSettingsWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,145 @@
+package org.apache.maven.plugin.eclipse.writers;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Properties;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.Messages;
+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;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @author <a href="mailto:kenney@neonics.com">Kenney Westerhof</a>
+ * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
+ * @version $Id: EclipseSettingsWriter.java 390686 2006-04-01 15:39:33Z fgiust $
+ */
+public class EclipseSettingsWriter
+    extends AbstractEclipseResourceWriter
+{
+
+    /**
+     * 'target' property for maven-compiler-plugin.
+     */
+    private static final String PROPERTY_TARGET = "target"; //$NON-NLS-1$
+
+    /**
+     * 'source' property for maven-compiler-plugin.
+     */
+    private static final String PROPERTY_SOURCE = "source"; //$NON-NLS-1$
+
+    private static final String JDK_1_2_SOURCES = "1.2"; //$NON-NLS-1$
+
+    private static final String FILE_ECLIPSE_JDT_CORE_PREFS = "org.eclipse.jdt.core.prefs"; //$NON-NLS-1$
+
+    private static final String PROP_ECLIPSE_PREFERENCES_VERSION = "eclipse.preferences.version"; //$NON-NLS-1$
+
+    private static final String DIR_DOT_SETTINGS = ".settings"; //$NON-NLS-1$
+
+    private static final String PROP_JDT_CORE_COMPILER_COMPLIANCE = "org.eclipse.jdt.core.compiler.compliance"; //$NON-NLS-1$
+
+    private static final String PROP_JDT_CORE_COMPILER_SOURCE = "org.eclipse.jdt.core.compiler.source"; //$NON-NLS-1$
+
+    private static final String ARTIFACT_MAVEN_COMPILER_PLUGIN = "maven-compiler-plugin"; //$NON-NLS-1$
+
+    public EclipseSettingsWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    public void write()
+        throws MojoExecutionException
+    {
+
+        // check if it's necessary to create project specific settings
+        Properties coreSettings = new Properties();
+
+        String source = IdeUtils.getPluginSetting( getProject(), ARTIFACT_MAVEN_COMPILER_PLUGIN, PROPERTY_SOURCE, null );
+        String target = IdeUtils.getPluginSetting( getProject(), ARTIFACT_MAVEN_COMPILER_PLUGIN, PROPERTY_TARGET, null );
+
+        if ( source != null )
+        {
+            coreSettings.put( PROP_JDT_CORE_COMPILER_SOURCE, source );
+            coreSettings.put( PROP_JDT_CORE_COMPILER_COMPLIANCE, source );
+        }
+
+        if ( target != null && !JDK_1_2_SOURCES.equals( target ) )
+        {
+            coreSettings.put( "org.eclipse.jdt.core.compiler.codegen.targetPlatform", target ); //$NON-NLS-1$
+        }
+
+        // write the settings, if needed
+        if ( !coreSettings.isEmpty() )
+        {
+            File settingsDir = new File( getEclipseProjectDirectory(), DIR_DOT_SETTINGS ); //$NON-NLS-1$
+
+            settingsDir.mkdirs();
+
+            coreSettings.put( PROP_ECLIPSE_PREFERENCES_VERSION, "1" ); //$NON-NLS-1$ 
+
+            try
+            {
+                File oldCoreSettingsFile;
+
+                File coreSettingsFile = new File( settingsDir, FILE_ECLIPSE_JDT_CORE_PREFS );
+
+                if ( coreSettingsFile.exists() )
+                {
+                    oldCoreSettingsFile = coreSettingsFile;
+
+                    Properties oldsettings = new Properties();
+                    oldsettings.load( new FileInputStream( oldCoreSettingsFile ) );
+
+                    Properties newsettings = (Properties) oldsettings.clone();
+                    newsettings.putAll( coreSettings );
+
+                    if ( !oldsettings.equals( newsettings ) )
+                    {
+                        newsettings.store( new FileOutputStream( coreSettingsFile ), null );
+                    }
+                }
+                else
+                {
+                    coreSettings.store( new FileOutputStream( coreSettingsFile ), null );
+
+                    getLog().info( Messages.getString( "EclipseSettingsWriter.wrotesettings", //$NON-NLS-1$
+                                                       coreSettingsFile.getCanonicalPath() ) );
+                }
+            }
+            catch ( FileNotFoundException e )
+            {
+                throw new MojoExecutionException( Messages.getString( "EclipseSettingsWriter.cannotcreatesettings" ), e ); //$NON-NLS-1$
+            }
+            catch ( IOException e )
+            {
+                throw new MojoExecutionException( Messages.getString( "EclipseSettingsWriter.errorwritingsettings" ), e ); //$NON-NLS-1$
+            }
+        }
+        else
+        {
+            getLog().info( Messages.getString( "EclipseSettingsWriter.usingdefaults" ) ); //$NON-NLS-1$
+        }
+    }
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseSettingsWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,172 @@
+package org.apache.maven.plugin.eclipse.writers;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.EclipseSourceDir;
+import org.apache.maven.plugin.eclipse.Messages;
+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;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Creates a .settings folder for Eclipse WTP 1.x release and writes out the configuration under it.
+ * 
+ * @author <a href="mailto:rahul.thakur.xdev@gmail.com">Rahul Thakur</a>
+ * @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
+ * @version $Id: EclipseWtpComponentWriter.java 390686 2006-04-01 15:39:33Z fgiust $
+ */
+public class EclipseWtpComponentWriter
+    extends AbstractWtpResourceWriter
+{
+
+    private static final String ATTR_CONTEXT_ROOT = "context-root"; //$NON-NLS-1$
+
+    /**
+     * The .settings folder for Web Tools Project 1.x release.
+     */
+    private static final String DIR_WTP_SETTINGS = ".settings"; //$NON-NLS-1$
+
+    /**
+     * File name where the WTP component settings will be stored for our Eclipse Project.
+     */
+    private static final String FILE_DOT_COMPONENT = ".component"; //$NON-NLS-1$
+
+    public EclipseWtpComponentWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    public void write( EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository, File buildOutputDirectory )
+        throws MojoExecutionException
+    {
+
+        // create a .settings directory (if not existing)
+        File settingsDir = new File( getEclipseProjectDirectory(), DIR_WTP_SETTINGS );
+        settingsDir.mkdirs();
+
+        FileWriter w;
+        try
+        {
+            w = new FileWriter( new File( settingsDir, FILE_DOT_COMPONENT ) );
+        }
+        catch ( IOException ex )
+        {
+            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+        }
+
+        // create a .component file and write out to it
+        XMLWriter writer = new PrettyPrintXMLWriter( w );
+        String packaging = getProject().getPackaging();
+        writeModuleTypeComponent( writer, packaging, buildOutputDirectory, sourceDirs, localRepository );
+        IOUtil.close( w );
+
+    }
+
+    /**
+     * Writes out the module type settings for a Web Tools Project to a {@link #FILE_DOT_COMPONENT}.
+     * 
+     * @param writer
+     * @param packaging
+     * @param buildOutputDirectory
+     * @param referencedReactorArtifacts
+     * @param localRepository
+     * @throws MojoExecutionException
+     */
+    private void writeModuleTypeComponent( XMLWriter writer, String packaging, File buildOutputDirectory,
+                                           EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository )
+        throws MojoExecutionException
+    {
+        writer.startElement( ELT_PROJECT_MODULES );
+        writer.addAttribute( ATTR_MODULE_ID, "moduleCoreId" ); //$NON-NLS-1$
+        writer.startElement( ELT_WB_MODULE );
+
+        writer.addAttribute( ATTR_DEPLOY_NAME, getProject().getArtifactId() );
+
+        // deploy-path is "/" for utility and ejb projects, "/WEB-INF/classes" for webapps
+        String target = "/"; //$NON-NLS-1$
+
+        if ( "war".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
+        {
+            target = "/WEB-INF/classes"; //$NON-NLS-1$
+
+            String warSourceDirectory = IdeUtils.getPluginSetting( getProject(), ARTIFACT_MAVEN_WAR_PLUGIN,
+                                                                   "warSourceDirectory", //$NON-NLS-1$
+                                                                   "/src/main/webapp" ); //$NON-NLS-1$
+
+            writer.startElement( ELT_PROPERTY );
+            writer.addAttribute( ATTR_CONTEXT_ROOT, getProject().getArtifactId() );
+            writer.endElement(); // property
+
+            writer.startElement( ELT_WB_RESOURCE );
+            writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$
+            writer.addAttribute( ATTR_SOURCE_PATH, IdeUtils
+                .toRelativeAndFixSeparator( getProject().getBasedir(), new File( getEclipseProjectDirectory(),
+                                                                                 warSourceDirectory ), false ) );
+            writer.endElement();
+
+            // @todo is this really needed?
+            writer.startElement( ELT_PROPERTY );
+            writer.addAttribute( ATTR_NAME, "java-output-path" ); //$NON-NLS-1$
+            writer.addAttribute( ATTR_VALUE, "/" //$NON-NLS-1$
+                + IdeUtils.toRelativeAndFixSeparator( getProject().getBasedir(), buildOutputDirectory, false ) );
+            writer.endElement(); // property
+
+        }
+        else if ( "ear".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
+        {
+            writer.startElement( ELT_WB_RESOURCE );
+            writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_SOURCE_PATH, "/" ); //$NON-NLS-1$ 
+            writer.endElement();
+        }
+
+        if ( "war".equalsIgnoreCase( packaging ) || "ear".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$ //$NON-NLS-2$
+        {
+            // write out the dependencies.
+            writeWarOrEarResources( writer, getProject(), localRepository );
+
+        }
+
+        for ( int j = 0; j < sourceDirs.length; j++ )
+        {
+            EclipseSourceDir dir = sourceDirs[j];
+            // test src/resources are not added to wtpmodules
+            if ( !dir.isTest() )
+            {
+                // <wb-resource deploy-path="/" source-path="/src/java" />
+                writer.startElement( ELT_WB_RESOURCE );
+                writer.addAttribute( ATTR_DEPLOY_PATH, target );
+                writer.addAttribute( ATTR_SOURCE_PATH, dir.getPath() );
+                writer.endElement();
+            }
+        }
+
+        writer.endElement(); // wb-module
+        writer.endElement(); // project-modules
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpComponentWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,168 @@
+package org.apache.maven.plugin.eclipse.writers;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.EclipseSourceDir;
+import org.apache.maven.plugin.eclipse.Messages;
+import org.apache.maven.plugin.ide.IdeDependency;
+import org.apache.maven.plugin.logging.Log;
+import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Creates a .settings folder for Eclipse WTP 1.x release and writes out the configuration under it.
+ * 
+ * @author <a href="mailto:rahul.thakur.xdev@gmail.com">Rahul Thakur</a>
+ * @author <a href="mailto:fgiust@apache.org">Fabrizio Giustina</a>
+ * @version $Id: EclipseWtpFacetsWriter.java 390686 2006-04-01 15:39:33Z fgiust $
+ */
+public class EclipseWtpFacetsWriter
+    extends AbstractWtpResourceWriter
+{
+
+    private static final String FACET_JST_EAR = "jst.ear"; //$NON-NLS-1$
+
+    private static final String FACET_JST_UTILITY = "jst.utility"; //$NON-NLS-1$
+
+    private static final String FACET_JST_EJB = "jst.ejb"; //$NON-NLS-1$
+
+    private static final String FACET_JST_WEB = "jst.web"; //$NON-NLS-1$
+
+    private static final String FACET_JST_JAVA = "jst.java"; //$NON-NLS-1$
+
+    private static final String ATTR_VERSION = "version"; //$NON-NLS-1$
+
+    private static final String ELT_INSTALLED = "installed"; //$NON-NLS-1$
+
+    private static final String ATTR_FACET = "facet"; //$NON-NLS-1$
+
+    private static final String ELT_FIXED = "fixed"; //$NON-NLS-1$
+
+    private static final String ELT_FACETED_PROJECT = "faceted-project"; //$NON-NLS-1$
+
+    /**
+     * The .settings folder for Web Tools Project 1.x release.
+     */
+    private static final String DIR_WTP_SETTINGS = ".settings"; //$NON-NLS-1$
+
+    /**
+     * File name where Eclipse Project's Facet configuration will be stored.
+     */
+    private static final String FILE_FACET_CORE_XML = "org.eclipse.wst.common.project.facet.core.xml"; //$NON-NLS-1$
+
+    public EclipseWtpFacetsWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    public void write( EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository, File buildOutputDirectory )
+        throws MojoExecutionException
+    {
+
+        // create a .settings directory (if not existing)
+        File settingsDir = new File( getEclipseProjectDirectory(), DIR_WTP_SETTINGS );
+        settingsDir.mkdirs();
+
+        FileWriter w;
+
+        String packaging = getProject().getPackaging();
+
+        // Write out facet core xml
+        try
+        {
+            w = new FileWriter( new File( settingsDir, FILE_FACET_CORE_XML ) );
+        }
+        catch ( IOException ex )
+        {
+            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+        }
+        XMLWriter writer = new PrettyPrintXMLWriter( w );
+        writeModuleTypeFacetCore( writer, packaging );
+        IOUtil.close( w );
+    }
+
+    /**
+     * Writes out the facet info for a faceted-project based on the packaging.
+     * 
+     * @param writer
+     * @param packaging
+     */
+    private void writeModuleTypeFacetCore( XMLWriter writer, String packaging )
+    {
+        writer.startElement( ELT_FACETED_PROJECT );
+        // common facet
+        writer.startElement( ELT_FIXED );
+        writer.addAttribute( ATTR_FACET, FACET_JST_JAVA );
+        writer.endElement(); // element fixed
+        if ( "war".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
+        {
+            writer.startElement( ELT_FIXED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_WEB );
+            writer.endElement(); // fixed
+            writer.startElement( ELT_INSTALLED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_WEB );
+            writer.addAttribute( ATTR_VERSION, resolveServletVersion() );
+            writer.endElement(); // installed
+        }
+        else if ( "ejb".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
+        {
+            writer.startElement( ELT_FIXED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_EJB );
+            writer.endElement(); // fixed
+            writer.startElement( ELT_INSTALLED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_EJB );
+            writer.addAttribute( ATTR_VERSION, resolveEjbVersion() );
+            writer.endElement(); // installed
+        }
+        else if ( "ear".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
+        {
+            writer.startElement( ELT_FIXED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_EAR );
+            writer.endElement(); // fixed
+            writer.startElement( ELT_INSTALLED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_EAR );
+            writer.addAttribute( ATTR_VERSION, resolveJ2eeVersion() );
+            writer.endElement(); // installed
+        }
+        else if ( "jar".equalsIgnoreCase( packaging ) ) //$NON-NLS-1$
+        {
+            writer.startElement( ELT_FIXED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_UTILITY );
+            writer.endElement(); // fixed
+            writer.startElement( ELT_INSTALLED );
+            writer.addAttribute( ATTR_FACET, FACET_JST_UTILITY );
+            writer.addAttribute( ATTR_VERSION, "1.0" ); //$NON-NLS-1$
+            writer.endElement(); // installed
+        }
+
+        // common installed element
+        writer.startElement( ELT_INSTALLED );
+        writer.addAttribute( ATTR_FACET, FACET_JST_JAVA );
+        writer.addAttribute( ATTR_VERSION, resolveJavaVersion() );
+        writer.endElement(); // installed
+        writer.endElement(); // faceted-project
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpFacetsWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Added: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpmodulesWriter.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpmodulesWriter.java?rev=396502&view=auto
==============================================================================
--- cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpmodulesWriter.java (added)
+++ cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpmodulesWriter.java Mon Apr 24 03:24:53 2006
@@ -0,0 +1,131 @@
+package org.apache.maven.plugin.eclipse.writers;
+
+/*
+ * 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.
+ */
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.eclipse.EclipseSourceDir;
+import org.apache.maven.plugin.eclipse.Messages;
+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;
+import org.codehaus.plexus.util.IOUtil;
+import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
+import org.codehaus.plexus.util.xml.XMLWriter;
+
+/**
+ * Writes eclipse .wtpmodules file.
+ *
+ * @author <a href="mailto:fgiust@users.sourceforge.net">Fabrizio Giustina</a>
+ * @version $Id: EclipseWtpmodulesWriter.java 390686 2006-04-01 15:39:33Z fgiust $
+ */
+public class EclipseWtpmodulesWriter
+    extends AbstractWtpResourceWriter
+{
+
+    protected static final String FILE_DOT_WTPMODULES = ".wtpmodules"; //$NON-NLS-1$
+
+    public EclipseWtpmodulesWriter( Log log, File eclipseProjectDir, MavenProject project, IdeDependency[] deps )
+    {
+        super( log, eclipseProjectDir, project, deps );
+    }
+
+    public void write( EclipseSourceDir[] sourceDirs, ArtifactRepository localRepository, File buildOutputDirectory )
+        throws MojoExecutionException
+    {
+        FileWriter w;
+
+        try
+        {
+            w = new FileWriter( new File( getEclipseProjectDirectory(), FILE_DOT_WTPMODULES ) );
+        }
+        catch ( IOException ex )
+        {
+            throw new MojoExecutionException( Messages.getString( "EclipsePlugin.erroropeningfile" ), ex ); //$NON-NLS-1$
+        }
+
+        XMLWriter writer = new PrettyPrintXMLWriter( w );
+        writer.startElement( ELT_PROJECT_MODULES );
+        writer.addAttribute( ATTR_MODULE_ID, "moduleCoreId" ); //$NON-NLS-1$ 
+
+        writer.startElement( ELT_WB_MODULE );
+        writer.addAttribute( ATTR_DEPLOY_NAME, getProject().getArtifactId() );
+
+        String packaging = getProject().getPackaging();
+
+        writer.startElement( ELT_MODULE_TYPE );
+        writeModuleTypeAccordingToPackaging( getProject(), writer, packaging, buildOutputDirectory );
+        writer.endElement(); // module-type
+
+        // source and resource paths.
+        // deploy-path is "/" for utility and ejb projects, "/WEB-INF/classes" for webapps
+
+        String target = "/"; //$NON-NLS-1$
+        if ( "war".equals( getProject().getPackaging() ) ) //$NON-NLS-1$
+        {
+            String warSourceDirectory = IdeUtils.getPluginSetting( getProject(), ARTIFACT_MAVEN_WAR_PLUGIN,
+                                                                   "warSourceDirectory", //$NON-NLS-1$
+                                                                   "/src/main/webapp" ); //$NON-NLS-1$
+
+            writer.startElement( ELT_WB_RESOURCE );
+            writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_SOURCE_PATH, "/" //$NON-NLS-1$
+                + IdeUtils.toRelativeAndFixSeparator( getEclipseProjectDirectory(),
+                                                      new File( getEclipseProjectDirectory(), warSourceDirectory ),
+                                                      false ) );
+            writer.endElement();
+
+            writeWarOrEarResources( writer, getProject(), localRepository );
+
+            target = "/WEB-INF/classes"; //$NON-NLS-1$
+        }
+        else if ( "ear".equals( getProject().getPackaging() ) ) //$NON-NLS-1$
+        {
+            writer.startElement( ELT_WB_RESOURCE );
+            writer.addAttribute( ATTR_DEPLOY_PATH, "/" ); //$NON-NLS-1$ 
+            writer.addAttribute( ATTR_SOURCE_PATH, "/" ); //$NON-NLS-1$ 
+            writer.endElement();
+
+            writeWarOrEarResources( writer, getProject(), localRepository );
+        }
+
+        for ( int j = 0; j < sourceDirs.length; j++ )
+        {
+            EclipseSourceDir dir = sourceDirs[j];
+            // test src/resources are not added to wtpmodules
+            if ( !dir.isTest() )
+            {
+                // <wb-resource deploy-path="/" source-path="/src/java" />
+                writer.startElement( ELT_WB_RESOURCE );
+                writer.addAttribute( ATTR_DEPLOY_PATH, target );
+                writer.addAttribute( ATTR_SOURCE_PATH, dir.getPath() );
+                writer.endElement();
+            }
+        }
+
+        writer.endElement(); // wb-module
+        writer.endElement(); // project-modules
+
+        IOUtil.close( w );
+    }
+
+}

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseWtpmodulesWriter.java
------------------------------------------------------------------------------
    eol:style = 'native'

Propchange: cocoon/trunk/tools/cocoon-maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/ide/
------------------------------------------------------------------------------
    eol:style = 'native'