directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r602680 - /directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java
Date Sun, 09 Dec 2007 14:57:09 GMT
Author: felixk
Date: Sun Dec  9 06:57:08 2007
New Revision: 602680

URL: http://svn.apache.org/viewvc?rev=602680&view=rev
Log:
Do some cleanups after eclipse:eclipse

Modified:
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java

Modified: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java?rev=602680&r1=602679&r2=602680&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java
(original)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java
Sun Dec  9 06:57:08 2007
@@ -51,9 +51,10 @@
  * 
  * @goal eclipse
  * @execute phase="generate-resources"
- * @description Copy artifacts nonscoped "provided" to libraryPath,
- *              Add artifacts nonscoped "provided" to Bundle-ClassPath and MANIFEST.MF, 
- *              Adapt ${basedir}/.classpath for artifacts nonscoped "provided"
+ * @description Copy artifacts nonscoped "provided" to libraryPath, Add
+ *              artifacts nonscoped "provided" to Bundle-ClassPath and
+ *              MANIFEST.MF, Adapt ${basedir}/.classpath for artifacts nonscoped
+ *              "provided"
  * @requiresProject
  * @requiresDependencyResolution runtime
  * 
@@ -96,6 +97,10 @@
                 // Update .classpath
                 updateDotClasspath(artifactList);
 
+                updateDotProject();
+                removeMavenEclipseXml();
+                removeDotExternalToolBuilders();
+
             } catch (Exception e) {
                 getLog().error(e);
             }
@@ -154,8 +159,8 @@
         // Build Bundle-ClassPath entry
         final StringBuilder bundleClasspath = new StringBuilder(" .");
         for (Artifact artifact : list) {
-            bundleClasspath.append(",").append(NEWLINE).append(" ").append(libraryPath).append(File.separator)
-                    .append(artifact.getFile().getName());
+            bundleClasspath.append(",").append(NEWLINE).append(" ").append(libraryPath).append(File.separator).append(
+                    artifact.getFile().getName());
         }
 
         boolean inBundleClasspathEntry = false;
@@ -192,7 +197,7 @@
     }
 
     /**
-     * Adapt the $äbasedir}/.classpath
+     * Adapt the ${basedir}/.classpath
      * 
      * @param list
      */
@@ -221,4 +226,61 @@
         w.close();
     }
 
+    /**
+     * Adapt the ${basedir}/.project
+     * 
+     * @param list
+     */
+    private void updateDotProject() throws IOException, XmlPullParserException {
+        getLog().info((new StringBuilder()).append("Update .project in ").append(project.getBasedir()).toString());
+        InputStream is = new FileInputStream(new File(project.getBasedir(), ".project"));
+        Xpp3Dom dom = Xpp3DomBuilder.build(is, "UTF-8");
+        int cnt = 0;
+        for (Xpp3Dom cpEntry : dom.getChild("buildSpec").getChildren("buildCommand")) {
+            if (cpEntry.getChild("name").getValue().equals("org.eclipse.ui.externaltools.ExternalToolBuilder"))
{
+                dom.getChild("buildSpec").removeChild(cnt);
+                cnt--;
+            }
+            cnt++;
+        }
+
+        removeChildFromDom(dom, "linkedResources");
+        removeChildFromDom(dom, "projects");
+
+        is.close();
+        Writer w = new OutputStreamWriter(new FileOutputStream(new File(project.getBasedir(),
".project")), "UTF-8");
+        org.codehaus.plexus.util.xml.XMLWriter writer = new PrettyPrintXMLWriter(w);
+        Xpp3DomWriter.write(writer, dom);
+        w.flush();
+        w.close();
+    }
+
+    /**
+     * remove ${basedir}/maven-eclipse.xml
+     */
+    void removeMavenEclipseXml() {
+        File file = new File(project.getBasedir(), "maven-eclipse.xml");
+        if (file.exists())
+            file.delete();
+    }
+
+    /**
+     * Adapt the ${basedir}/.externalToolBuilders
+     */
+    void removeDotExternalToolBuilders() {
+        File file = new File(project.getBasedir(), ".externalToolBuilders");
+        if (file.exists())
+            deleteDirectory(file);
+    }
+
+    private void removeChildFromDom(Xpp3Dom dom, String childName) {
+        int cnt = 0;
+        for (Xpp3Dom child : dom.getChildren()) {
+            if (child.getName().equals(childName)) {
+                dom.removeChild(cnt);
+                cnt -= 1;
+            }
+            cnt += 1;
+        }
+    }
 }



Mime
View raw message