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

svn commit: r472172 - in /maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers: EclipseAntExternalLaunchConfigurationWriter.java EclipseLaunchConfigurationWriter.java EclipseProjectWriter.java

Author: kenney
Date: Tue Nov  7 09:09:41 2006
New Revision: 472172

URL: http://svn.apache.org/viewvc?view=rev&rev=472172
Log:
Cleanup; add license; add portions of patch from MECLIPSE-139 submitted by Jochen Kuhnle

Modified:
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseAntExternalLaunchConfigurationWriter.java
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseLaunchConfigurationWriter.java
    maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseAntExternalLaunchConfigurationWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseAntExternalLaunchConfigurationWriter.java?view=diff&rev=472172&r1=472171&r2=472172
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseAntExternalLaunchConfigurationWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseAntExternalLaunchConfigurationWriter.java Tue Nov  7 09:09:41 2006
@@ -1,3 +1,15 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
 package org.apache.maven.plugin.eclipse.writers;
 
 import java.util.List;
@@ -16,16 +28,6 @@
 {
     private String buildfilePath;
 
-    protected String getLaunchConfigurationType()
-    {
-        return "org.eclipse.ant.AntBuilderLaunchConfigurationType";
-    }
-
-    protected String getBuilderLocation()
-    {
-        return "${build_project}/" + buildfilePath;
-    }
-
     /**
      *
      * @param launcherName Name of the launch file, for instance 'AntBuilder.launch'
@@ -43,13 +45,10 @@
     {
         // ant specific
         writeAttribute( writer, "process_factory_id", "org.eclipse.ant.ui.remoteAntProcessFactory" );
+
         writeAttribute( writer, "org.eclipse.ant.ui.DEFAULT_VM_INSTALL", false );
-        writeAttribute( writer, "org.eclipse.jdt.launching.DEFAULT_CLASSPATH", true );
-        writeAttribute( writer, "org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", false );
 
-        writer.startElement( "listAttribute" );
-        writer.addAttribute( "key", "org.eclipse.debug.core.MAPPED_RESOURCE_TYPES" );
-        writer.endElement();
+        writeAttribute( writer, "org.eclipse.debug.ui.ATTR_CONSOLE_OUTPUT_ON", false );
 
         writeAttribute( writer, "org.eclipse.ant.ui.ATTR_TARGETS_UPDATED", true );
 
@@ -58,12 +57,20 @@
             "org.eclipse.jdt.launching.CLASSPATH_PROVIDER",
             "org.eclipse.ant.ui.AntClasspathProvider" );
 
-        // writeAttribute( writer, "org.eclipse.jdt.launching.PROJECT_ATTR", "" );
+        writeAttribute( writer, "org.eclipse.debug.core.MAPPED_RESOURCE_TYPES", new String[] { "1" } );
 
-        // writer.startElement( "listAttribute" );
-        // writer.addAttribute( "key", "org.eclipse.debug.core.MAPPED_RESOURCE_PATHS" );
-        // writer.endElement();
+        writeAttribute( writer, "org.eclipse.debug.core.MAPPED_RESOURCE_PATHS", new String[] { "/"
+            + config.getEclipseProjectName() + "/" + buildfilePath } );
+    }
 
+    protected String getLaunchConfigurationType()
+    {
+        return "org.eclipse.ant.AntBuilderLaunchConfigurationType";
+    }
+
+    protected String getBuilderLocation()
+    {
+        return "${build_project}/" + buildfilePath;
     }
 
     protected List getMonitoredResources()

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseLaunchConfigurationWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseLaunchConfigurationWriter.java?view=diff&rev=472172&r1=472171&r2=472172
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseLaunchConfigurationWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseLaunchConfigurationWriter.java Tue Nov  7 09:09:41 2006
@@ -1,8 +1,22 @@
+/*
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
+ * in compliance with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software distributed under the License
+ * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
 package org.apache.maven.plugin.eclipse.writers;
 
 import java.io.File;
-import java.io.FileWriter;
+import java.io.FileOutputStream;
 import java.io.IOException;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -50,7 +64,7 @@
             throw new MojoExecutionException( "Not initialized" );
         }
 
-        FileWriter w;
+        Writer w;
 
         try
         {
@@ -59,7 +73,7 @@
             {
                 throw new MojoExecutionException( "Error creating directory " + extToolsDir );
             }
-            w = new FileWriter( new File( extToolsDir, filename ) );
+            w = new OutputStreamWriter( new FileOutputStream( new File( extToolsDir, filename ) ), "UTF-8" );
         }
         catch ( IOException ex )
         {
@@ -82,6 +96,10 @@
 
         writeAttribute( writer, "org.eclipse.debug.core.appendEnvironmentVariables", isAppendEnvironmentVariables() );
 
+        writeAttribute( writer, "org.eclipse.jdt.launching.PROJECT_ATTR", config.getEclipseProjectName() );
+
+        writeAttribute( writer, "org.eclipse.jdt.launching.DEFAULT_CLASSPATH", true );
+
         writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_LOCATION", getBuilderLocation() );
 
         if ( getWorkingDirectory() != null )
@@ -106,17 +124,12 @@
         {
             MonitoredResource monitoredResource = (MonitoredResource) it.next();
 
-            workingSet+=monitoredResource.print();
+            workingSet += monitoredResource.print();
         }
 
-        workingSet+="</launchConfigurationWorkingSet>";
+        workingSet += "</launchConfigurationWorkingSet>";
 
-
-        writeAttribute(
-            writer,
-            "org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE",
-            "${working_set:" + workingSet
-                + "}" );
+        writeAttribute( writer, "org.eclipse.ui.externaltools.ATTR_BUILD_SCOPE", "${working_set:" + workingSet + "}" );
 
         addAttributes( writer );
 
@@ -127,7 +140,9 @@
 
     protected List getMonitoredResources()
     {
-        return Collections.singletonList( new MonitoredResource( config.getEclipseProjectName(), MonitoredResource.PROJECT ) );
+        return Collections.singletonList( new MonitoredResource(
+            config.getEclipseProjectName(),
+            MonitoredResource.PROJECT ) );
     }
 
     protected abstract void addAttributes( XMLWriter writer );
@@ -182,6 +197,22 @@
         writer.startElement( "booleanAttribute" );
         writer.addAttribute( "key", key );
         writer.addAttribute( "value", "" + value );
+        writer.endElement();
+    }
+
+    protected static void writeAttribute( XMLWriter writer, String key, String[] values )
+    {
+        writer.startElement( "listAttribute" );
+        writer.addAttribute( "key", key );
+
+        for ( int i = 0; i < values.length; i++ )
+        {
+            String value = values[i];
+            writer.startElement( "listEntry" );
+            writer.addAttribute( "value", value );
+            writer.endElement();
+        }
+
         writer.endElement();
     }
 

Modified: maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java?view=diff&rev=472172&r1=472171&r2=472172
==============================================================================
--- maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java (original)
+++ maven/plugins/trunk/maven-eclipse-plugin/src/main/java/org/apache/maven/plugin/eclipse/writers/EclipseProjectWriter.java Tue Nov  7 09:09:41 2006
@@ -1,8 +1,4 @@
-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
@@ -16,6 +12,8 @@
  * limitations under the License.
  */
 
+package org.apache.maven.plugin.eclipse.writers;
+
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.FileReader;
@@ -52,7 +50,6 @@
 public class EclipseProjectWriter
     extends AbstractEclipseWriter
 {
-
     private static final String ELT_NAME = "name"; //$NON-NLS-1$
 
     private static final String ELT_BUILD_COMMAND = "buildCommand"; //$NON-NLS-1$
@@ -119,7 +116,7 @@
                         Xpp3Dom buildCommandName = existingBuildCommands[j].getChild( ELT_NAME );
                         if ( buildCommandName != null )
                         {
-                            buildCommands.add( new BuildCommand( buildCommandName.getValue(), null ) );
+                            buildCommands.add( new BuildCommand( existingBuildCommands[j] ) );
                         }
                     }
                 }
@@ -203,7 +200,7 @@
 
         for ( Iterator it = buildCommands.iterator(); it.hasNext(); )
         {
-            ((BuildCommand) it.next() ).print( writer );
+            ( (BuildCommand) it.next() ).print( writer );
         }
 
         writer.endElement(); // buildSpec