directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fel...@apache.org
Subject svn commit: r601329 - /directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/
Date Wed, 05 Dec 2007 13:30:03 GMT
Author: felixk
Date: Wed Dec  5 05:29:58 2007
New Revision: 601329

URL: http://svn.apache.org/viewvc?rev=601329&view=rev
Log:
- Add skip flag
- Some refactoring to make AbstractStudioMojo usable for all Mojos

Modified:
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCleanMojo.java
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioEclipseMojo.java
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
    directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java

Modified: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java?rev=601329&r1=601328&r2=601329&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
(original)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/AbstractStudioMojo.java
Wed Dec  5 05:29:58 2007
@@ -23,7 +23,6 @@
 import java.io.FileInputStream;
 import java.io.FileOutputStream;
 import java.io.InputStream;
-import java.util.ArrayList;
 import java.util.Enumeration;
 import java.util.Iterator;
 import java.util.List;
@@ -81,14 +80,13 @@
     protected org.apache.maven.artifact.resolver.ArtifactResolver resolver;
 
     /**
-     * Collection of ArtifactItems to work on. (ArtifactItem contains groupId,
-     * artifactId, version, type, classifier, location, destFile, markerFile and
-     * overwrite.) See "Usage" and "Javadoc" for details.
+     * Flag if execution shall be skipped. Defaults to true.
      * 
-     * @parameter
+     * @parameter expression="true"
      * @required
+     * @readonly
      */
-    protected ArrayList<ArtifactItem> artifactItems;
+    protected boolean skip;
 
     /**
      * Artifact collector, needed to resolve dependencies.
@@ -340,7 +338,7 @@
      * 
      * @throws MojoExecutionException
      */
-    protected void completeArtifactItems() throws MojoExecutionException {
+    protected void completeArtifactItems(List<ArtifactItem> artifactItems) throws MojoExecutionException
{
         try {
             // Get and complete artifacts
             for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
@@ -354,14 +352,6 @@
         } catch (Exception e) {
             throw new MojoExecutionException("", e);
         }
-    }
-
-    /**
-     * @param artifactItems
-     *            the artifactItems to set
-     */
-    public void setArtifactItems(ArrayList<ArtifactItem> artifactItems) {
-        this.artifactItems = artifactItems;
     }
 
     /**

Modified: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCleanMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCleanMojo.java?rev=601329&r1=601328&r2=601329&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCleanMojo.java
(original)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCleanMojo.java
Wed Dec  5 05:29:58 2007
@@ -21,7 +21,6 @@
 
 import java.io.File;
 
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 
@@ -36,49 +35,51 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Id: StudioReplaceFileInJarMojo.java 350 2007-10-28 12:01:17Z felix $
  */
-public class StudioCleanMojo extends AbstractMojo {
+public class StudioCleanMojo extends AbstractStudioMojo {
 
-	/**
-	 * POM
-	 * 
-	 * @parameter expression="${project}"
-	 * @readonly
-	 * @required
-	 */
-	protected MavenProject project;
+    /**
+     * POM
+     * 
+     * @parameter expression="${project}"
+     * @readonly
+     * @required
+     */
+    protected MavenProject project;
 
-	public void execute() throws MojoExecutionException {
-		try {
-			File file = new File(project.getBasedir(), "maven-eclipse.xml");
-			getLog().info("Deleting " + file);
-			file.delete();
-			file = new File(project.getBasedir(), ".externalToolBuilder");
-			getLog().info("Deleting " + file);
-			deleteDirectory(file);
-			file = new File(project.getBasedir(), "lib");
-			getLog().info("Deleting " + file);
-			deleteDirectory(file);
-		} catch (Exception e) {
-			getLog().error(e);
-		}
-	}
+    public void execute() throws MojoExecutionException {
+        if (!skip) {
+            try {
+                File file = new File(project.getBasedir(), "maven-eclipse.xml");
+                getLog().info("Deleting " + file);
+                file.delete();
+                file = new File(project.getBasedir(), ".externalToolBuilder");
+                getLog().info("Deleting " + file);
+                deleteDirectory(file);
+                file = new File(project.getBasedir(), "lib");
+                getLog().info("Deleting " + file);
+                deleteDirectory(file);
+            } catch (Exception e) {
+                getLog().error(e);
+            }
+        }
+    }
 
-	/**
-	 * Delete a directory
-	 * 
-	 * @param path
-	 * @return
-	 */
-	private static boolean deleteDirectory(File path) {
-		if (path.exists()) {
-			for (File file : path.listFiles()) {
-				if (file.isDirectory()) {
-					deleteDirectory(file);
-				} else {
-					file.delete();
-				}
-			}
-		}
-		return (path.delete());
-	}
+    /**
+     * Delete a directory
+     * 
+     * @param path
+     * @return
+     */
+    private static boolean deleteDirectory(File path) {
+        if (path.exists()) {
+            for (File file : path.listFiles()) {
+                if (file.isDirectory()) {
+                    deleteDirectory(file);
+                } else {
+                    file.delete();
+                }
+            }
+        }
+        return (path.delete());
+    }
 }

Modified: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java?rev=601329&r1=601328&r2=601329&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
(original)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioCopyEclipseDependencyMojo.java
Wed Dec  5 05:29:58 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.maven.plugins;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Iterator;
 
 import org.apache.commons.io.FileUtils;
@@ -42,6 +43,16 @@
 public class StudioCopyEclipseDependencyMojo extends AbstractStudioMojo {
 
     /**
+     * Collection of ArtifactItems to work on. (ArtifactItem contains groupId,
+     * artifactId, version, type, classifier, location, destFile, markerFile and
+     * overwrite.) See "Usage" and "Javadoc" for details.
+     * 
+     * @parameter
+     * @required
+     */
+    protected ArrayList<ArtifactItem> artifactItems;
+
+    /**
      * Location of the file.
      * 
      * @parameter expression="${project.build.directory}"
@@ -58,26 +69,35 @@
     }
 
     public void execute() throws MojoExecutionException {
+        if (!skip) {
+            completeArtifactItems(artifactItems);
 
-        completeArtifactItems();
+            for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
+                ArtifactItem item = artifactItem.next();
+                try {
 
-        for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
-            ArtifactItem item = artifactItem.next();
-            try {
+                    final File destFile = new File(destinationDirectory.getAbsoluteFile()
+ File.separator
+                            + item.getArtifactId() + "_" + item.getVersion() + "." + item.getType());
 
-                final File destFile = new File(destinationDirectory.getAbsoluteFile() + File.separator
-                        + item.getArtifactId() + "_" + item.getVersion() + "." + item.getType());
+                    getLog().info("Copying " + item.getArtifactId() + " to " + destFile.getAbsolutePath());
 
-                getLog().info("Copying " + item.getArtifactId() + " to " + destFile.getAbsolutePath());
+                    if (!destinationDirectory.exists()) {
+                        destinationDirectory.mkdirs();
+                    }
+                    FileUtils.copyFile(item.getArtifact().getFile(), destFile);
 
-                if (!destinationDirectory.exists()) {
-                    destinationDirectory.mkdirs();
+                } catch (Exception e) {
+                    throw new MojoExecutionException("", e);
                 }
-                FileUtils.copyFile(item.getArtifact().getFile(), destFile);
-
-            } catch (Exception e) {
-                throw new MojoExecutionException("", e);
             }
         }
+    }
+
+    /**
+     * @param artifactItems
+     *            the artifactItems to set
+     */
+    public void setArtifactItems(ArrayList<ArtifactItem> artifactItems) {
+        this.artifactItems = artifactItems;
     }
 }

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=601329&r1=601328&r2=601329&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
Wed Dec  5 05:29:58 2007
@@ -35,7 +35,6 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.apache.maven.project.MavenProject;
 import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
@@ -46,15 +45,14 @@
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 /**
- * Prepares for eclipse:
- * Copy artifacts nonscoped "provided" to ${basedir}/lib
- * Add artifacts nonscoped "provided" to Bundle-ClassPath ind MANIFEST.MF
- * Adapt ${basedir}/.classpath for artifacts nonscoped "provided"
+ * Prepares for eclipse: Copy artifacts nonscoped "provided" to ${basedir}/lib
+ * Add artifacts nonscoped "provided" to Bundle-ClassPath ind MANIFEST.MF Adapt
+ * ${basedir}/.classpath for artifacts nonscoped "provided"
  * 
  * @goal eclipse
  * @execute phase="generate-resources"
- * @description Copy artifacts nonscoped "provided" to ${basedir}/lib,
- *              Add artifacts nonscoped "provided" to Bundle-ClassPath ind MANIFEST.MF,
+ * @description Copy artifacts nonscoped "provided" to ${basedir}/lib, 
+ *              Add artifacts nonscoped "provided" to Bundle-ClassPath and MANIFEST.MF, 
  *              Adapt ${basedir}/.classpath for artifacts nonscoped "provided"
  * @requiresProject
  * @requiresDependencyResolution runtime
@@ -62,185 +60,178 @@
  * @author <a href="mailto:dev@directory.apache.org">Apache Directory Project</a>
  * @version $Id: StudioReplaceFileInJarMojo.java 350 2007-10-28 12:01:17Z felix $
  */
-public class StudioEclipseMojo extends AbstractMojo {
+public class StudioEclipseMojo extends AbstractStudioMojo {
 
-	/**
-	 * POM
-	 * 
-	 * @parameter expression="${project}"
-	 * @readonly
-	 * @required
-	 */
-	protected MavenProject project;
-
-	/**
-	 * Constant used for newline.
-	 */
-	private static final String NEWLINE = "\n";
-
-	/**
-	 * Bundle-ClassPath: updated with the list of dependencies.
-	 */
-	public final static String ENTRY_BUNDLE_CLASSPATH = "Bundle-ClassPath:";
-
-	/**
-	 * classpathPrefix
-	 * 
-	 * @parameter expression="."
-	 */
-	private String classpathPrefix;
-
-	public void execute() throws MojoExecutionException {
-		try {
-			// Create list of used artifacts
-			final List<Artifact> artifactList = createArtifactList();
-
-			// copy Artifacts
-			copyArtifacts(artifactList);
-
-			// Update Bundle-Classpath in MANIFEST.MF
-			updateManifest(artifactList);
-
-			// Update .classpath
-			updateDotClasspath(artifactList);
-
-		} catch (Exception e) {
-			getLog().error(e);
-		}
-	}
-
-	/**
-	 * Return a list of artifacts nonscoped "provided"
-	 * @return
-	 */
-	private List<Artifact> createArtifactList() {
-		List<Artifact> list = new ArrayList<Artifact>();
-		for (Iterator<Artifact> artifactItem = project.getArtifacts()
-				.iterator(); artifactItem.hasNext();) {
-			Artifact artifact = (Artifact) artifactItem.next();
-			if (!artifact.getScope().equalsIgnoreCase("provided")) {
-				list.add(artifact);
-			}
-		}
-		return list;
-	}
-
-	/**
-	 * Copy artifacts to ${basedir}/lib
-	 * @param list
-	 * @throws IOException
-	 */
-	private void copyArtifacts(final List<Artifact> list) throws IOException {
-		// Only proceed when we have artifacts to process
-		if (!list.isEmpty()) {
-			final File copyDir = new File(project.getBasedir(), classpathPrefix);
-
-			if (!copyDir.exists())
-				copyDir.mkdirs();
-
-			for (Artifact artifact : list) {
-				final File destFile = new File(copyDir, artifact.getFile()
-						.getName());
-				FileUtils.copyFile(artifact.getFile(), destFile);
-				getLog().info(
-						"Copying " + artifact.getFile() + " to " + destFile);
-			}
-		}
-	}
-
-	/**
-	 * Updates the Bundle-ClassPath entry in the manifest file
-	 * @param list
-	 * @throws FileNotFoundException
-	 * @throws IOException
-	 */
-	private void updateManifest(final List<Artifact> 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(
-					classpathPrefix).append(File.separator).append(
-					artifact.getFile().getName());
-		}
-
-		boolean inBundleClasspathEntry = false;
-
-		// 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"));
-		String line;
-		while ((line = in.readLine()) != null) {
-			if (inBundleClasspathEntry && line.indexOf(":") > -1) {
-				inBundleClasspathEntry = false;
-			} else if (inBundleClasspathEntry) {
-				continue;
-			}
-
-			String name = line.substring(0, line.indexOf(":") + 1);
-
-			if (!name.equalsIgnoreCase(ENTRY_BUNDLE_CLASSPATH)) {
-				manifestSb.append(line).append(NEWLINE);
-			} else {
-				inBundleClasspathEntry = true;
-			}
-		}
-
-		// Add Bundle-ClassPath entry
-		manifestSb.append(ENTRY_BUNDLE_CLASSPATH).append(bundleClasspath)
-				.append(NEWLINE);
-
-		// Write MANIFEST.MF
-		Writer out = new OutputStreamWriter(new FileOutputStream(manifestFile),
-				"UTF-8");
-		out.write(manifestSb.toString());
-		out.flush();
-		out.close();
-	}
-
-	/**
-	 * Adapt the $äbasedir}/.classpath
-	 * @param list
-	 */
-	private void updateDotClasspath(final List<Artifact> list)
-			throws IOException, XmlPullParserException {
-		getLog().info("Update .classpath in " + project.getBasedir());
-		InputStream is = new FileInputStream(new File(project.getBasedir(),
-				".classpath"));
-		Xpp3Dom dom = Xpp3DomBuilder.build(is, "UTF-8");
-		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", classpathPrefix
-							+ File.separator + artifact.getFile().getName());
-				}
-			}
-		}
-		is.close();
-		Writer w;
-
-		w = new OutputStreamWriter(new FileOutputStream(new File(project
-				.getBasedir(), ".classpath")), "UTF-8");
-
-		XMLWriter writer = new PrettyPrintXMLWriter(w);
-		Xpp3DomWriter.write(writer, dom);
-		w.flush();
-		w.close();
-	}
-
-	/**
-	 * @param classpathPrefix
-	 */
-	public void setClasspathPrefix(String classpathPrefix) {
-		this.classpathPrefix = classpathPrefix;
-	}
+    /**
+     * POM
+     * 
+     * @parameter expression="${project}"
+     * @readonly
+     * @required
+     */
+    protected MavenProject project;
+
+    /**
+     * Constant used for newline.
+     */
+    private static final String NEWLINE = "\n";
+
+    /**
+     * Bundle-ClassPath: updated with the list of dependencies.
+     */
+    public final static String ENTRY_BUNDLE_CLASSPATH = "Bundle-ClassPath:";
+
+    /**
+     * classpathPrefix
+     * 
+     * @parameter expression="."
+     */
+    private String classpathPrefix;
+
+    public void execute() throws MojoExecutionException {
+        if (!skip) {
+            try {
+                // Create list of used artifacts
+                final List<Artifact> artifactList = createArtifactList();
+
+                // copy Artifacts
+                copyArtifacts(artifactList);
+
+                // Update Bundle-Classpath in MANIFEST.MF
+                updateManifest(artifactList);
+
+                // Update .classpath
+                updateDotClasspath(artifactList);
+
+            } catch (Exception e) {
+                getLog().error(e);
+            }
+        }
+    }
+
+    /**
+     * Return a list of artifacts nonscoped "provided"
+     * 
+     * @return
+     */
+    private List<Artifact> createArtifactList() {
+        List<Artifact> list = new ArrayList<Artifact>();
+        for (Iterator<Artifact> artifactItem = project.getArtifacts().iterator(); artifactItem.hasNext();)
{
+            Artifact artifact = (Artifact) artifactItem.next();
+            if (!artifact.getScope().equalsIgnoreCase("provided")) {
+                list.add(artifact);
+            }
+        }
+        return list;
+    }
+
+    /**
+     * Copy artifacts to ${basedir}/lib
+     * 
+     * @param list
+     * @throws IOException
+     */
+    private void copyArtifacts(final List<Artifact> list) throws IOException {
+        // Only proceed when we have artifacts to process
+        if (!list.isEmpty()) {
+            final File copyDir = new File(project.getBasedir(), classpathPrefix);
+
+            if (!copyDir.exists())
+                copyDir.mkdirs();
+
+            for (Artifact artifact : list) {
+                final File destFile = new File(copyDir, artifact.getFile().getName());
+                FileUtils.copyFile(artifact.getFile(), destFile);
+                getLog().info("Copying " + artifact.getFile() + " to " + destFile);
+            }
+        }
+    }
+
+    /**
+     * Updates the Bundle-ClassPath entry in the manifest file
+     * 
+     * @param list
+     * @throws FileNotFoundException
+     * @throws IOException
+     */
+    private void updateManifest(final List<Artifact> 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(classpathPrefix).append(File.separator)
+                    .append(artifact.getFile().getName());
+        }
+
+        boolean inBundleClasspathEntry = false;
+
+        // 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"));
+        String line;
+        while ((line = in.readLine()) != null) {
+            if (inBundleClasspathEntry && line.indexOf(":") > -1) {
+                inBundleClasspathEntry = false;
+            } else if (inBundleClasspathEntry) {
+                continue;
+            }
+
+            String name = line.substring(0, line.indexOf(":") + 1);
+
+            if (!name.equalsIgnoreCase(ENTRY_BUNDLE_CLASSPATH)) {
+                manifestSb.append(line).append(NEWLINE);
+            } else {
+                inBundleClasspathEntry = true;
+            }
+        }
+
+        // Add Bundle-ClassPath entry
+        manifestSb.append(ENTRY_BUNDLE_CLASSPATH).append(bundleClasspath).append(NEWLINE);
+
+        // Write MANIFEST.MF
+        Writer out = new OutputStreamWriter(new FileOutputStream(manifestFile), "UTF-8");
+        out.write(manifestSb.toString());
+        out.flush();
+        out.close();
+    }
+
+    /**
+     * Adapt the $äbasedir}/.classpath
+     * 
+     * @param list
+     */
+    private void updateDotClasspath(final List<Artifact> list) throws IOException,
XmlPullParserException {
+        getLog().info("Update .classpath in " + project.getBasedir());
+        InputStream is = new FileInputStream(new File(project.getBasedir(), ".classpath"));
+        Xpp3Dom dom = Xpp3DomBuilder.build(is, "UTF-8");
+        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", classpathPrefix + File.separator + artifact.getFile().getName());
+                }
+            }
+        }
+        is.close();
+        Writer w;
+
+        w = new OutputStreamWriter(new FileOutputStream(new File(project.getBasedir(), ".classpath")),
"UTF-8");
+
+        XMLWriter writer = new PrettyPrintXMLWriter(w);
+        Xpp3DomWriter.write(writer, dom);
+        w.flush();
+        w.close();
+    }
+
+    /**
+     * @param classpathPrefix
+     */
+    public void setClasspathPrefix(String classpathPrefix) {
+        this.classpathPrefix = classpathPrefix;
+    }
 }

Modified: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java?rev=601329&r1=601328&r2=601329&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
(original)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioReplaceFileInJarMojo.java
Wed Dec  5 05:29:58 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.maven.plugins;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Iterator;
 
 import org.apache.commons.io.FileUtils;
@@ -41,6 +42,16 @@
 public class StudioReplaceFileInJarMojo extends AbstractStudioMojo {
 
     /**
+     * Collection of ArtifactItems to work on. (ArtifactItem contains groupId,
+     * artifactId, version, type, classifier, location, destFile, markerFile and
+     * overwrite.) See "Usage" and "Javadoc" for details.
+     * 
+     * @parameter
+     * @required
+     */
+    protected ArrayList<ArtifactItem> artifactItems;
+
+    /**
      * FinalName of the jar file
      * 
      * @parameter
@@ -82,34 +93,44 @@
     }
 
     public void execute() throws MojoExecutionException {
+        if (!skip) {
 
-        completeArtifactItems();
+            completeArtifactItems(artifactItems);
 
-        // Add file to dest jar
-        for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
-            ArtifactItem item = artifactItem.next();
-            try {
-                final File zipFile = new File(destinationDirectory.getAbsolutePath() + File.separator
-                        + item.getArtifactId() + "_" + item.getVersion() + "." + item.getType());
-                final File tmpDir = new File(pluginWorkDir + item.getArtifact().getArtifactId());
-
-                getLog().info("Adding " + inputFile + " to " + zipFile);
-
-                if (getLog().isDebugEnabled())
-                    getLog().debug("Unzipping " + zipFile + " into " + tmpDir);
-                unzipToDir(tmpDir, zipFile);
-
-                if (getLog().isDebugEnabled())
-                    getLog().debug("Copying " + inputFile + " into " + tmpDir);
-                FileUtils.copyFileToDirectory(inputFile, tmpDir);
-
-                if (getLog().isDebugEnabled())
-                    getLog().debug("Zipping " + tmpDir + " into " + zipFile);
-                zipFromDir(tmpDir, zipFile);
-
-            } catch (Exception e) {
-                throw new MojoExecutionException("", e);
+            // Add file to dest jar
+            for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
+                ArtifactItem item = artifactItem.next();
+                try {
+                    final File zipFile = new File(destinationDirectory.getAbsolutePath()
+ File.separator
+                            + item.getArtifactId() + "_" + item.getVersion() + "." + item.getType());
+                    final File tmpDir = new File(pluginWorkDir + item.getArtifact().getArtifactId());
+
+                    getLog().info("Adding " + inputFile + " to " + zipFile);
+
+                    if (getLog().isDebugEnabled())
+                        getLog().debug("Unzipping " + zipFile + " into " + tmpDir);
+                    unzipToDir(tmpDir, zipFile);
+
+                    if (getLog().isDebugEnabled())
+                        getLog().debug("Copying " + inputFile + " into " + tmpDir);
+                    FileUtils.copyFileToDirectory(inputFile, tmpDir);
+
+                    if (getLog().isDebugEnabled())
+                        getLog().debug("Zipping " + tmpDir + " into " + zipFile);
+                    zipFromDir(tmpDir, zipFile);
+
+                } catch (Exception e) {
+                    throw new MojoExecutionException("", e);
+                }
             }
         }
+    }
+
+    /**
+     * @param artifactItems
+     *            the artifactItems to set
+     */
+    public void setArtifactItems(ArrayList<ArtifactItem> artifactItems) {
+        this.artifactItems = artifactItems;
     }
 }

Modified: directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
URL: http://svn.apache.org/viewvc/directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java?rev=601329&r1=601328&r2=601329&view=diff
==============================================================================
--- directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
(original)
+++ directory/sandbox/felixk/studio-plugin/src/main/java/org/apache/directory/studio/maven/plugins/StudioUnpackPrefixedMojo.java
Wed Dec  5 05:29:58 2007
@@ -20,6 +20,7 @@
 package org.apache.directory.studio.maven.plugins;
 
 import java.io.File;
+import java.util.ArrayList;
 import java.util.Iterator;
 
 import org.apache.maven.plugin.MojoExecutionException;
@@ -41,6 +42,16 @@
 public class StudioUnpackPrefixedMojo extends AbstractStudioMojo {
 
     /**
+     * Collection of ArtifactItems to work on. (ArtifactItem contains groupId,
+     * artifactId, version, type, classifier, location, destFile, markerFile and
+     * overwrite.) See "Usage" and "Javadoc" for details.
+     * 
+     * @parameter
+     * @required
+     */
+    protected ArrayList<ArtifactItem> artifactItems;
+
+    /**
      * Location of the file.
      * 
      * @parameter expression="${project.build.directory}"
@@ -57,23 +68,33 @@
     }
 
     public void execute() throws MojoExecutionException {
+        if (!skip) {
+            completeArtifactItems(artifactItems);
 
-        completeArtifactItems();
-
-        // unzip it
-        for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
-            ArtifactItem item = artifactItem.next();
-            try {
-                final File tmpDir = new File(outputDirectory.getAbsoluteFile() + File.separator
+ item.getArtifactId()
-                        + "_" + item.getVersion());
-
-                if (getLog().isDebugEnabled())
-                    getLog().debug("Unzipping " + item.getArtifact().getFile() + " into "
+ tmpDir);
-                unzipToDir(tmpDir, item.getArtifact().getFile());
-
-            } catch (Exception e) {
-                throw new MojoExecutionException("", e);
+            // unzip it
+            for (Iterator<ArtifactItem> artifactItem = artifactItems.iterator(); artifactItem.hasNext();)
{
+                ArtifactItem item = artifactItem.next();
+                try {
+                    final File tmpDir = new File(outputDirectory.getAbsoluteFile() + File.separator
+                            + item.getArtifactId() + "_" + item.getVersion());
+
+                    if (getLog().isDebugEnabled())
+                        getLog().debug("Unzipping " + item.getArtifact().getFile() + " into
" + tmpDir);
+                    unzipToDir(tmpDir, item.getArtifact().getFile());
+
+                } catch (Exception e) {
+                    throw new MojoExecutionException("", e);
+                }
             }
         }
     }
+
+    /**
+     * @param artifactItems
+     *            the artifactItems to set
+     */
+    public void setArtifactItems(ArrayList<ArtifactItem> artifactItems) {
+        this.artifactItems = artifactItems;
+    }
+
 }



Mime
View raw message