Return-Path: Delivered-To: apmail-directory-commits-archive@www.apache.org Received: (qmail 10351 invoked from network); 9 Dec 2007 17:05:39 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Dec 2007 17:05:39 -0000 Received: (qmail 87271 invoked by uid 500); 9 Dec 2007 17:05:27 -0000 Delivered-To: apmail-directory-commits-archive@directory.apache.org Received: (qmail 87225 invoked by uid 500); 9 Dec 2007 17:05:27 -0000 Mailing-List: contact commits-help@directory.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@directory.apache.org Delivered-To: mailing list commits@directory.apache.org Received: (qmail 87214 invoked by uid 99); 9 Dec 2007 17:05:27 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Dec 2007 09:05:27 -0800 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Dec 2007 17:05:15 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 13C4F1A9832; Sun, 9 Dec 2007 09:05:18 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r602697 - /directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java Date: Sun, 09 Dec 2007 17:05:17 -0000 To: commits@directory.apache.org From: felixk@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20071209170518.13C4F1A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: felixk Date: Sun Dec 9 09:05:15 2007 New Revision: 602697 URL: http://svn.apache.org/viewvc?rev=602697&view=rev Log: Some changes to fix classpath. 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=602697&r1=602696&r2=602697&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 09:05:15 2007 @@ -114,7 +114,8 @@ */ private List createArtifactList() { List list = new ArrayList(); - for (Iterator artifactItem = project.getArtifacts().iterator(); artifactItem.hasNext();) { + for (Iterator artifactItem = project.getArtifacts() + .iterator(); artifactItem.hasNext();) { Artifact artifact = (Artifact) artifactItem.next(); if (!artifact.getScope().equalsIgnoreCase("provided")) { list.add(artifact); @@ -138,9 +139,11 @@ copyDir.mkdirs(); for (Artifact artifact : list) { - final File destFile = new File(copyDir, artifact.getFile().getName()); + final File destFile = new File(copyDir, artifact.getFile() + .getName()); FileUtils.copyFile(artifact.getFile(), destFile); - getLog().info("Copying " + artifact.getFile() + " to " + destFile); + getLog().info( + "Copying " + artifact.getFile() + " to " + destFile); } } } @@ -152,14 +155,17 @@ * @throws FileNotFoundException * @throws IOException */ - private void updateManifest(final List list) throws FileNotFoundException, IOException { - final File manifestFile = new File(project.getBasedir(), "META-INF/MANIFEST.MF"); + private void updateManifest(final List list) + throws FileNotFoundException, IOException { + final File manifestFile = new File(project.getBasedir(), + "META-INF/MANIFEST.MF"); getLog().info("Update Bundle-Classpath in " + manifestFile); // Build Bundle-ClassPath entry final StringBuilder bundleClasspath = new StringBuilder(" ."); for (Artifact artifact : list) { - bundleClasspath.append(",").append(NEWLINE).append(" ").append(libraryPath).append(File.separator).append( + bundleClasspath.append(",").append(NEWLINE).append(" ").append( + libraryPath).append(File.separator).append( artifact.getFile().getName()); } @@ -168,7 +174,8 @@ // Read existing MANIFEST.MF and add existing entries // to StringBuilder exept Bundle-ClassPath entry StringBuilder manifestSb = new StringBuilder(); - BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(manifestFile), "UTF-8")); + BufferedReader in = new BufferedReader(new InputStreamReader( + new FileInputStream(manifestFile), "UTF-8")); String line; while ((line = in.readLine()) != null) { if (inBundleClasspathEntry && line.indexOf(":") > -1) { @@ -187,10 +194,12 @@ } // Add Bundle-ClassPath entry - manifestSb.append(ENTRY_BUNDLE_CLASSPATH).append(bundleClasspath).append(NEWLINE); + manifestSb.append(ENTRY_BUNDLE_CLASSPATH).append(bundleClasspath) + .append(NEWLINE); // Write MANIFEST.MF - Writer out = new OutputStreamWriter(new FileOutputStream(manifestFile), "UTF-8"); + Writer out = new OutputStreamWriter(new FileOutputStream(manifestFile), + "UTF-8"); out.write(manifestSb.toString()); out.flush(); out.close(); @@ -201,26 +210,36 @@ * * @param list */ - private void updateDotClasspath(final List list) throws IOException, XmlPullParserException { + private void updateDotClasspath(List list) throws IOException, + XmlPullParserException { getLog().info("Update .classpath in " + project.getBasedir()); - InputStream is = new FileInputStream(new File(project.getBasedir(), ".classpath")); + final InputStream is = new FileInputStream(new File(project + .getBasedir(), ".classpath")); Xpp3Dom dom = Xpp3DomBuilder.build(is, "UTF-8"); + int cnt = 0; for (Xpp3Dom cpEntry : dom.getChildren("classpathentry")) { - final String pathValue = cpEntry.getAttribute("path"); - for (Artifact artifact : list) { - if (pathValue.indexOf(artifact.getFile().getName()) > -1) { - cpEntry.setAttribute("exported", "true"); - cpEntry.setAttribute("kind", "lib"); - cpEntry.setAttribute("path", libraryPath + File.separator + artifact.getFile().getName()); - } + if (cpEntry.getAttribute("kind").equals("lib")) { + dom.removeChild(cnt); + cnt--; } + cnt++; } - is.close(); - Writer w; - w = new OutputStreamWriter(new FileOutputStream(new File(project.getBasedir(), ".classpath")), "UTF-8"); + for (Artifact artifact : list) { + final Xpp3Dom entry = new Xpp3Dom("classpathentry"); + entry.setAttribute("exported", "true"); + entry.setAttribute("kind", "lib"); + entry.setAttribute("path", (new StringBuilder()) + .append(libraryPath).append(File.separator).append( + artifact.getFile().getName()).toString()); + dom.addChild(entry); + } - XMLWriter writer = new PrettyPrintXMLWriter(w); + is.close(); + Writer w = new OutputStreamWriter(new FileOutputStream(new File(project + .getBasedir(), ".classpath")), "UTF-8"); + org.codehaus.plexus.util.xml.XMLWriter writer = new PrettyPrintXMLWriter( + w); Xpp3DomWriter.write(writer, dom); w.flush(); w.close(); @@ -232,12 +251,15 @@ * @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")); + getLog().info("Update .project in " + project.getBasedir()); + 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")) { + 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--; } @@ -248,8 +270,10 @@ 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); + 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();