You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jd...@apache.org on 2006/11/07 22:50:58 UTC

svn commit: r472290 - in /maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse: EclipsePlugin.java writers/rad/RadManifestWriter.java

Author: jdcasey
Date: Tue Nov  7 13:50:57 2006
New Revision: 472290

URL: http://svn.apache.org/viewvc?view=rev&rev=472290
Log:
rolling back merge from trunk@r472172 so I can re-apply it more selectively.

Modified:
    maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
    maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java

Modified: maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java?view=diff&rev=472290&r1=472289&r2=472290
==============================================================================
--- maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java (original)
+++ maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/EclipsePlugin.java Tue Nov  7 13:50:57 2006
@@ -22,7 +22,6 @@
 import java.util.Arrays;
 import java.util.Iterator;
 import java.util.List;
-import java.util.ListIterator;
 import java.util.Set;
 import java.util.TreeSet;
 
@@ -92,7 +91,7 @@
 
     private static final String COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER = "org.eclipse.jdt.launching.JRE_CONTAINER"; //$NON-NLS-1$
 
-    private static final String REQUIRED_PLUGINS_CONTAINER = "org.eclipse.pde.core.requiredPlugins"; //$NON-NLS-1$
+    private static final String REQUIRED_PLUGINS_CONTAINER = "org.eclipse.pde.core.requiredPlugins"; //$NON-NLS-1$  
 
     //  warning, order is important for binary search
     public static final String[] WTP_SUPPORTED_VERSIONS = new String[] { "1.0", "1.5", "R7", "none" }; //$NON-NLS-1$ //$NON-NLS-2$  //$NON-NLS-3$
@@ -111,27 +110,27 @@
      * List of eclipse project natures. By default the
      * <code>org.eclipse.jdt.core.javanature</code> nature plus the needed WTP
      * natures are added. Natures added using this property <strong>replace</strong> the default list.
-     *
+     * 
      * <pre>
      * &lt;projectnatures&gt;
      *    &lt;projectnature&gt;org.eclipse.jdt.core.javanature&lt;/projectnature&gt;
      *    &lt;projectnature&gt;org.eclipse.wst.common.modulecore.ModuleCoreNature&lt;/projectnature&gt;
      * &lt;/projectnatures&gt;
      * </pre>
-     *
+     * 
      * @parameter
      */
     private List projectnatures;
 
     /**
      * List of eclipse project natures to be added to the default ones.
-     *
+     * 
      * <pre>
      * &lt;additionalProjectnatures&gt;
      *    &lt;projectnature&gt;org.springframework.ide.eclipse.core.springnature&lt;/projectnature&gt;
      * &lt;/additionalProjectnatures&gt;
      * </pre>
-     *
+     * 
      * @parameter
      */
     private List additionalProjectnatures;
@@ -139,7 +138,7 @@
     /**
      * List of eclipse build commands. By default the <code>org.eclipse.jdt.core.javabuilder</code> builder plus the needed
      * WTP builders are added. Configuration example:
-     *
+     * 
      * <pre>
      * &lt;buildcommands&gt;
      *    &lt;buildcommand&gt;org.eclipse.wst.common.modulecore.ComponentStructuralBuilder&lt;/buildcommand&gt;
@@ -147,27 +146,27 @@
      *    &lt;buildcommand&gt;org.eclipse.wst.common.modulecore.ComponentStructuralBuilderDependencyResolver&lt;/buildcommand&gt;
      * &lt;/buildcommands&gt;
      * </pre>
-     *
+     * 
      * @parameter
      */
     private List buildcommands;
 
     /**
      * List of eclipse build commands to be added to the default ones.
-     *
+     * 
      * <pre>
      * &lt;additionalBuildcommands&gt;
      *    &lt;buildcommand&gt;org.springframework.ide.eclipse.core.springbuilder&lt;/buildcommand&gt;
      * &lt;/additionalBuildcommands&gt;
      * </pre>
-     *
+     * 
      * @parameter
      */
     private List additionalBuildcommands;
 
     /**
      * List of container classpath entries. By default the <code>org.eclipse.jdt.launching.JRE_CONTAINER</code> classpath
-     * container is added. Configuration example:
+     * container is added. Configuration example: 
      * <pre>
      * &lt;classpathContainers&gt;
      *    &lt;classpathContainer&gt;org.eclipse.jdt.launching.JRE_CONTAINER&lt;/classpathContainer&gt;
@@ -175,7 +174,7 @@
      *    &lt;classpathContainer&gt;org.eclipse.jst.j2ee.internal.web.container/artifact&lt;/classpathContainer&gt;
      * &lt;/classpathContainers&gt;
      * </pre>
-     *
+     * 
      * @parameter
      */
     private List classpathContainers;
@@ -190,7 +189,7 @@
 
     /**
      * Eclipse workspace directory.
-     *
+     * 
      * @parameter expression="${eclipse.workspace}" alias="outputDir"
      */
     private File eclipseProjectDir;
@@ -199,7 +198,7 @@
      * When set to false, the plugin will not create sub-projects and instead
      * reference those sub-projects using the installed package in the local
      * repository
-     *
+     * 
      * @parameter expression="${eclipse.useProjectReferences}" default-value="true"
      * @required
      */
@@ -207,7 +206,7 @@
 
     /**
      * The default output directory
-     *
+     * 
      * @parameter expression="${outputDirectory}" alias="outputDirectory" default-value="${project.build.outputDirectory}"
      * @required
      */
@@ -216,7 +215,7 @@
     /**
      * The version of WTP for which configuration files will be generated.
      * The default value is "none" (don't generate WTP configuration), supported versions are "R7" and "1.0"
-     *
+     * 
      * @parameter expression="${wtpversion}" default-value="none"
      */
     private String wtpversion;
@@ -226,22 +225,22 @@
      * the .project file. Additionally it copies all libraries to a project local directory and
      * references them instead of referencing the files in the local Maven repository. It also
      * ensured that the "Bundle-Classpath" in META-INF/MANIFEST.MF is synchronized.
-     *
+     * 
      * @parameter expression="${eclipse.pde}" default-value="false"
      */
     private boolean pde;
 
     /**
      * The relative path of the manifest file
-     *
+     * 
      * @parameter expression="${eclipse.manifest}" default-value="${basedir}/META-INF/MANIFEST.MF"
      */
     private File manifest;
 
     /**
      * Allow to configure additional generic configuration files for eclipse that will be written out to disk when
-     * running eclipse:eclipse. For each file you can specify the name and the text content.
-     *
+     * running eclipse:eclipse. FOr each file you can specify the name and the text content.
+     * 
      * <pre>
      * &lt;additionalConfig&gt;
      *    &lt;file&gt;
@@ -257,7 +256,7 @@
      *    &lt;/file&gt;
      * &lt;/additionalConfig&gt;
      * </pre>
-     *
+     * 
      * @parameter
      */
     private EclipseConfigFile[] additionalConfig;
@@ -440,23 +439,61 @@
     public boolean setup()
         throws MojoExecutionException
     {
+        boolean ready = true;
 
-        if ( eclipseDownloadSources )
+        checkDeprecations();
+
+        ready = validate();
+        
+        String packaging = executedProject.getPackaging();
+
+        // TODO: Why are we using project in some places, and executedProject in others??
+        ArtifactHandler artifactHandler = this.project.getArtifact().getArtifactHandler();
+
+        // ear projects don't contain java sources
+        isJavaProject = Constants.LANGUAGE_JAVA.equals( artifactHandler.getLanguage() )
+            && !Constants.PROJECT_PACKAGING_EAR.equals( packaging );
+
+        setupExtras();
+
+        parseConfigurationOptions();
+        
+        // defaults
+        if ( projectnatures == null )
         {
-            // deprecated warning
-            getLog().warn( Messages.getString( "EclipsePlugin.deprecatedpar", new Object[] { //$NON-NLS-1$
-                                               "eclipse.downloadSources", //$NON-NLS-1$
-                                                   "downloadSources" } ) ); //$NON-NLS-1$
-            downloadSources = true;
+            fillDefaultNatures( packaging );
         }
 
-        if ( Arrays.binarySearch( WTP_SUPPORTED_VERSIONS, wtpversion ) < 0 )
+        if ( additionalProjectnatures != null )
         {
-            throw new MojoExecutionException( Messages
-                .getString( "EclipsePlugin.unsupportedwtp", new Object[] { //$NON-NLS-1$
-                            wtpversion, StringUtils.join( WTP_SUPPORTED_VERSIONS, " " ) } ) ); //$NON-NLS-1$
+            projectnatures.addAll( additionalProjectnatures );
+        }
+
+        if ( buildcommands == null )
+        {
+            fillDefaultBuilders( packaging );
+        }
+
+        if ( additionalBuildcommands != null )
+        {
+            buildcommands.addAll( additionalBuildcommands );
+        }
+
+        if ( classpathContainers == null )
+        {
+            fillDefaultClasspathContainers( packaging );
+        }
+        else
+        {
+            verifyClasspathContainerListIsComplete();
         }
 
+        // ready to start
+        return ready;
+    }
+
+    private void parseConfigurationOptions()
+    {
         if ( "R7".equalsIgnoreCase( wtpversion ) ) //$NON-NLS-1$
         {
             wtpVersionFloat = 0.7f;
@@ -473,10 +510,36 @@
         {
             getLog().info( Messages.getString( "EclipsePlugin.wtpversion", wtpversion ) );
         }
+    }
 
-        String packaging = executedProject.getPackaging();
+    protected void setupExtras()
+    {
+        // extension point.
+    }
 
+    protected void verifyClasspathContainerListIsComplete()
+    {
+        // this is an extension point.
+        if ( !classpathContainers.contains( COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER ) ) //$NON-NLS-1$
+        {
+            getLog().warn( Messages.getString( "EclipsePlugin.missingjrecontainer" ) ); //$NON-NLS-1$
+            classpathContainers.add( 0, COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER );
+        }
+    }
+
+    private boolean validate()
+        throws MojoExecutionException
+    {
         // validate sanity of the current m2 project
+        if ( Arrays.binarySearch( WTP_SUPPORTED_VERSIONS, wtpversion ) < 0 )
+        {
+            throw new MojoExecutionException( Messages
+                .getString( "EclipsePlugin.unsupportedwtp", new Object[] { //$NON-NLS-1$
+                            wtpversion, StringUtils.join( WTP_SUPPORTED_VERSIONS, " " ) } ) ); //$NON-NLS-1$
+        }
+
+        String packaging = executedProject.getPackaging();
+
         assertNotEmpty( executedProject.getGroupId(), POM_ELT_GROUP_ID ); //$NON-NLS-1$
         assertNotEmpty( executedProject.getArtifactId(), POM_ELT_ARTIFACT_ID ); //$NON-NLS-1$
 
@@ -513,67 +576,33 @@
             }
         }
 
-        // end validate
-
-        ArtifactHandler artifactHandler = this.project.getArtifact().getArtifactHandler();
-        // ear projects don't contain java sources
-        isJavaProject = "java".equals( artifactHandler.getLanguage() ) && !"ear".equals( packaging );
-
-        // defaults
-        if ( projectnatures == null )
-        {
-            fillDefaultNatures( packaging );
-        }
-
-        if ( additionalProjectnatures != null )
-        {
-            projectnatures.addAll( additionalProjectnatures );
-        }
+        validateExtras();
 
-        if ( buildcommands == null )
-        {
-            fillDefaultBuilders( packaging );
-        }
-        else
-        {
-            convertBuildCommandList( buildcommands );
-        }
+        return true;
+    }
 
-        if ( additionalBuildcommands != null )
-        {
-            convertBuildCommandList( additionalBuildcommands );
-            buildcommands.addAll( additionalBuildcommands );
-        }
+    protected void validateExtras()
+    {
+        // provided for extension.
+    }
 
-        if ( classpathContainers == null )
-        {
-            fillDefaultClasspathContainers( packaging );
-        }
-        else if ( !classpathContainers.contains( COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER ) ) //$NON-NLS-1$
+    private void checkDeprecations()
+    {
+        if ( eclipseDownloadSources )
         {
-            getLog().warn( Messages.getString( "EclipsePlugin.missingjrecontainer" ) ); //$NON-NLS-1$
-            classpathContainers.add( 0, COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER );
+            // deprecated warning
+            getLog().warn( Messages.getString( "EclipsePlugin.deprecatedpar", new Object[] { //$NON-NLS-1$
+                                               "eclipse.downloadSources", //$NON-NLS-1$
+                                                   "downloadSources" } ) ); //$NON-NLS-1$
+            downloadSources = true;
         }
 
-        // ready to start
-        return true;
+        checkExtraDeprecations();
     }
 
-    protected void convertBuildCommandList( List commands )
+    protected void checkExtraDeprecations()
     {
-        if ( commands != null )
-        {
-            for ( ListIterator i = commands.listIterator(); i.hasNext(); )
-            {
-                Object command = i.next();
-
-                if ( command instanceof String )
-                {
-                    command = new BuildCommand( (String) command );
-                    i.set( command );
-                }
-            }
-        }
+        // provided for extension.
     }
 
     public void writeConfiguration( IdeDependency[] deps )
@@ -586,19 +615,6 @@
         EclipseSourceDir[] sourceDirs = buildDirectoryList( executedProject, eclipseProjectDir, buildOutputDirectory );
 
         EclipseWriterConfig config = new EclipseWriterConfig();
-
-        // TODO: add mojo param 'addVersionToProjectName' and if set append
-        // -version to the project name.
-        config.setEclipseProjectName( project.getArtifactId() );
-
-        // XXX TODO: change the buildCommands param to match
-        // <buildCommands>
-        //   <buildCommand>
-        //     <name>....</name>
-        //     <arguments>
-        //       <somekey>somevalue</somekey>
-        //     </arguments>
-
         config.setBuildCommands( buildcommands );
         config.setBuildOutputDirectory( buildOutputDirectory );
         config.setClasspathContainers( classpathContainers );
@@ -612,6 +628,9 @@
         config.setProjectnatures( projectnatures );
         config.setSourceDirs( sourceDirs );
 
+        // NOTE: This could change the config!
+        writeExtraConfiguration( config );
+        
         if ( wtpVersionFloat == 0.7f )
         {
             new EclipseWtpmodulesWriter().init( getLog(), config ).write();
@@ -621,17 +640,18 @@
         {
             new EclipseWtpFacetsWriter().init( getLog(), config ).write();
         }
-
         if ( wtpVersionFloat == 1.0f )
         {
+
             new EclipseWtpComponentWriter().init( getLog(), config ).write();
         }
-
         if ( wtpVersionFloat >= 1.5 )
         {
             new EclipseWtpComponent15Writer().init( getLog(), config ).write();
         }
 
+        new EclipseProjectWriter().init( getLog(), config ).write();
+
         new EclipseSettingsWriter().init( getLog(), config ).write();
 
         if ( isJavaProject )
@@ -639,8 +659,6 @@
             new EclipseClasspathWriter().init( getLog(), config ).write();
         }
 
-        new EclipseProjectWriter().init( getLog(), config ).write();
-
         if ( pde )
         {
             this.getLog().info( "The Maven Eclipse plugin runs in 'pde'-mode." );
@@ -676,6 +694,23 @@
                                            project.getArtifactId(), eclipseProjectDir.getAbsolutePath() } ) );
     }
 
+    /**
+     * Write any extra configuration information for the Eclipse project. This is an extension
+     * point, called before the main configurations are written.
+     * <br/>
+     * <b>
+     * NOTE: This could change the config!
+     * </b>
+     * 
+     * @param config
+     * @throws MojoExecutionException
+     */
+    protected void writeExtraConfiguration( EclipseWriterConfig config )
+        throws MojoExecutionException
+    {
+        // extension point.
+    }
+
     private void assertNotEmpty( String string, String elementName )
         throws MojoExecutionException
     {
@@ -685,7 +720,7 @@
         }
     }
 
-    private void fillDefaultNatures( String packaging )
+    protected void fillDefaultNatures( String packaging )
     {
         projectnatures = new ArrayList();
 
@@ -716,7 +751,7 @@
 
     }
 
-    private void fillDefaultClasspathContainers( String packaging )
+    protected void fillDefaultClasspathContainers( String packaging )
     {
         classpathContainers = new ArrayList();
         classpathContainers.add( COMMON_PATH_JDT_LAUNCHING_JRE_CONTAINER );
@@ -727,39 +762,39 @@
         }
     }
 
-    private void fillDefaultBuilders( String packaging )
+    protected void fillDefaultBuilders( String packaging )
     {
         buildcommands = new ArrayList();
 
         if ( wtpVersionFloat == 0.7f )
         {
-            buildcommands.add( new BuildCommand( BUILDER_WST_COMPONENT_STRUCTURAL ) ); // WTP 0.7 builder
+            buildcommands.add( BUILDER_WST_COMPONENT_STRUCTURAL ); // WTP 0.7 builder
         }
 
         if ( isJavaProject )
         {
-            buildcommands.add( new BuildCommand( BUILDER_JDT_CORE_JAVA ) );
+            buildcommands.add( BUILDER_JDT_CORE_JAVA );
         }
 
         if ( wtpVersionFloat >= 1.5f )
         {
-            buildcommands.add( new BuildCommand( BUILDER_WST_FACET ) ); // WTP 1.5 builder
+            buildcommands.add( BUILDER_WST_FACET ); // WTP 1.5 builder
         }
 
         if ( wtpVersionFloat >= 0.7f )
         {
-            buildcommands.add( new BuildCommand( BUILDER_WST_VALIDATION ) ); // WTP 0.7/1.0 builder
+            buildcommands.add( BUILDER_WST_VALIDATION ); // WTP 0.7/1.0 builder
         }
 
         if ( wtpVersionFloat == 0.7f )
         {
-            buildcommands.add( new BuildCommand( BUILDER_WST_COMPONENT_STRUCTURAL_DEPENDENCY_RESOLVER ) ); // WTP 0.7 builder
+            buildcommands.add( BUILDER_WST_COMPONENT_STRUCTURAL_DEPENDENCY_RESOLVER ); // WTP 0.7 builder
         }
 
         if ( pde )
         {
-            buildcommands.add( new BuildCommand( BUILDER_PDE_MANIFEST ) );
-            buildcommands.add( new BuildCommand( BUILDER_PDE_SCHEMA ) );
+            buildcommands.add( BUILDER_PDE_MANIFEST );
+            buildcommands.add( BUILDER_PDE_SCHEMA );
         }
     }
 
@@ -801,6 +836,7 @@
     {
         for ( Iterator it = sourceRoots.iterator(); it.hasNext(); )
         {
+
             File sourceRootFile = new File( (String) it.next() );
 
             if ( sourceRootFile.isDirectory() )
@@ -808,10 +844,7 @@
                 String sourceRoot = IdeUtils.toRelativeAndFixSeparator( projectBaseDir, sourceRootFile, !projectBaseDir
                     .equals( basedir ) );
 
-                if ( !directories.add( new EclipseSourceDir( sourceRoot, output, false, test, null, null, false ) ) )
-                {
-                    getLog().warn( "Not adding source dir " + sourceRoot + "; path already present");
-                }
+                directories.add( new EclipseSourceDir( sourceRoot, output, false, test, null, null ) );
             }
         }
     }
@@ -823,6 +856,9 @@
         for ( Iterator it = resources.iterator(); it.hasNext(); )
         {
             Resource resource = (Resource) it.next();
+            
+            System.out.println( "Processing resource dir: " + resource.getDirectory() );
+            
             String includePattern = null;
             String excludePattern = null;
 
@@ -843,6 +879,7 @@
 
             if ( !resourceDirectory.exists() || !resourceDirectory.isDirectory() )
             {
+                System.out.println( "Resource dir: " + resourceDirectory + " either missing or not a directory." );
                 continue;
             }
 
@@ -865,10 +902,9 @@
                 output = IdeUtils.toRelativeAndFixSeparator( projectBaseDir, outputFile, false );
             }
 
-            if ( !directories.add( new EclipseSourceDir( resourceDir, output, true, test, includePattern, excludePattern, resource.isFiltering() ) ) )
-            {
-                getLog().warn( "Not adding resource dir " + resourceDir + "; path already present");
-            }
+            System.out.println( "Adding eclipse source dir: { " + resourceDir + ", " + output + ", true, " + test + ", " + includePattern + ", " + excludePattern + " }." );
+            
+            directories.add( new EclipseSourceDir( resourceDir, output, true, test, includePattern, excludePattern ) );
         }
     }
 

Modified: maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java?view=diff&rev=472290&r1=472289&r2=472290
==============================================================================
--- maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java (original)
+++ maven/plugins/branches/MECLIPSE-137/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/rad/RadManifestWriter.java Tue Nov  7 13:50:57 2006
@@ -151,7 +151,7 @@
             
             if ( !foundMetaInfBaseDirectory )
             {
-                EclipseSourceDir dir = new EclipseSourceDir( metaInfBaseDirectory, null, true, false, null, null );
+                EclipseSourceDir dir = new EclipseSourceDir( metaInfBaseDirectory, null, true, false, null, null, false );
                 
                 EclipseSourceDir[] newSourceDirs = new EclipseSourceDir[ sourceDirs.length + 1 ];
                 newSourceDirs[ sourceDirs.length ] = dir;