[jboss-cvs] JBossAS SVN: r72359 - in projects/maven/plugins/deployer/trunk: src and 11 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Apr 17 10:20:01 EDT 2008


Author: thomas.diesler at jboss.com
Date: 2008-04-17 10:20:00 -0400 (Thu, 17 Apr 2008)
New Revision: 72359

Added:
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeployerMojo.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DependenciesHandler.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DeploymentsHandler.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/UndeploymentsHandler.java
   projects/maven/plugins/deployer/trunk/src/test/
   projects/maven/plugins/deployer/trunk/src/test/java/
   projects/maven/plugins/deployer/trunk/src/test/java/org/
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/DeployerMojoTestCase.java
   projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/UndeployerMojoTestCase.java
   projects/maven/plugins/deployer/trunk/src/test/resources/
   projects/maven/plugins/deployer/trunk/src/test/resources/deploy-jboss-pom.xml
   projects/maven/plugins/deployer/trunk/src/test/resources/undeploy-jboss-pom.xml
Removed:
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DependenciesHandler.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeploymentsHandler.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeploymentsHandler.java
Modified:
   projects/maven/plugins/deployer/trunk/.classpath
   projects/maven/plugins/deployer/trunk/pom.xml
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/AbstractDeployerMojo.java
   projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeployerMojo.java
Log:
deploy/undeploy, ok

Modified: projects/maven/plugins/deployer/trunk/.classpath
===================================================================
--- projects/maven/plugins/deployer/trunk/.classpath	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/.classpath	2008-04-17 14:20:00 UTC (rev 72359)
@@ -1,6 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <classpath>
 	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/test/java"/>
 	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
 	<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-plugin-api/2.0.9/maven-plugin-api-2.0.9.jar" sourcepath="/M2_REPO/org/apache/maven/maven-plugin-api/2.0.9/maven-plugin-api-2.0.9-sources.jar">
 		<attributes>
@@ -18,8 +19,12 @@
 		</attributes>
 	</classpathentry>
 	<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-utils/1.4.6/plexus-utils-1.4.6.jar"/>
-	<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9.jar" sourcepath="/M2_REPO/org/apache/maven/maven-project/2.0.9/maven-project-2.0.9-sources.jar"/>
 	<classpathentry kind="var" path="M2_REPO/org/apache/maven/shared/maven-common-artifact-filters/1.0/maven-common-artifact-filters-1.0.jar"/>
 	<classpathentry kind="var" path="M2_REPO/org/apache/maven/maven-artifact/2.0.9/maven-artifact-2.0.9.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-archiver/1.0-alpha-6/plexus-archiver-1.0-alpha-6.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/apache/maven/shared/maven-plugin-testing-harness/1.1/maven-plugin-testing-harness-1.1.jar"/>
+	<classpathentry kind="var" path="JUNIT_HOME/junit.jar"/>
+	<classpathentry kind="var" path="M2_REPO/org/codehaus/plexus/plexus-container-default/1.0-alpha-9-stable-1/plexus-container-default-1.0-alpha-9-stable-1.jar"/>
 	<classpathentry kind="output" path="target/eclipse"/>
 </classpath>

Modified: projects/maven/plugins/deployer/trunk/pom.xml
===================================================================
--- projects/maven/plugins/deployer/trunk/pom.xml	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/pom.xml	2008-04-17 14:20:00 UTC (rev 72359)
@@ -9,15 +9,18 @@
   <url>http://maven.apache.org</url>
   
   <version>1.0-SNAPSHOT</version>
-	
+  
   <properties>
     <maven.artifact>2.0.9</maven.artifact>
     <maven.assembly.plugin>2.1</maven.assembly.plugin>
     <maven.dependency.plugin>2.0</maven.dependency.plugin>
     <maven.plugin.api>2.0.9</maven.plugin.api>
+    <maven.plugin.testing.harness>1.1</maven.plugin.testing.harness>
     <maven.project>2.0.9</maven.project>
+    
+    <surefire.jvm.args>-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005</surefire.jvm.args>
   </properties>
-	
+  
   <dependencies>
     <!-- maven-artifact -->
     <dependency>
@@ -109,6 +112,14 @@
       <version>${maven.dependency.plugin}</version>
       <classifier>javadoc</classifier>
     </dependency>
+    
+    <!-- test dependencies -->
+    <dependency>
+      <groupId>org.apache.maven.shared</groupId>
+      <artifactId>maven-plugin-testing-harness</artifactId>
+      <version>${maven.plugin.testing.harness}</version>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
   
   <build>
@@ -122,36 +133,10 @@
         </configuration>
       </plugin>
       <plugin>
-        <groupId>org.jboss.maven.plugin</groupId>
-        <artifactId>maven-deployer-plugin</artifactId>
-        <version>${version}</version>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
         <configuration>
-          <!--jbossHome>/home/tdiesler/svn/jbossas/tags/JBoss_5_0_0_Beta4/build/output/jboss-5.0.0.Beta4</jbossHome-->
-          <jbossHome>target</jbossHome>
-          <deployStructure>target/deploy-structure</deployStructure>
-          <keepDeployStructure>true</keepDeployStructure>
-          <undeployments>
-            <include>./classes/META-INF/maven/plugin.xml</include>
-            <include>./classes/bogus</include>
-            <include>./classes</include>
-          </undeployments>
-          <deployments>
-            <deployment>
-              <targetDir>bin</targetDir>
-              <sourceDir>src/main/java</sourceDir>
-              <includes>
-                <include>**/*.java</include>
-              </includes>
-            </deployment>
-          </deployments>
-          <dependencies>
-            <deployment>
-              <targetDir>libs</targetDir>
-              <includes>
-                <include>**/*.java</include>
-              </includes>
-            </deployment>
-          </dependencies>
+          <!--argLine>${surefire.jvm.args}</argLine-->
         </configuration>
       </plugin>
     </plugins>

Modified: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/AbstractDeployerMojo.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/AbstractDeployerMojo.java	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/AbstractDeployerMojo.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -23,10 +23,17 @@
 
 // $Id$
 
+import java.io.File;
 import java.util.List;
 
+import org.apache.maven.artifact.factory.ArtifactFactory;
+import org.apache.maven.artifact.metadata.ArtifactMetadataSource;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactCollector;
+import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.plugin.AbstractMojo;
 import org.apache.maven.project.MavenProject;
+import org.codehaus.plexus.archiver.manager.ArchiverManager;
 
 /**
  * 
@@ -43,7 +50,7 @@
     * @required
     * @readonly
     */
-   private org.apache.maven.artifact.factory.ArtifactFactory factory;
+   protected ArtifactFactory factory;
 
    /**
     * Used to look up Artifacts in the remote repository.
@@ -52,7 +59,7 @@
     * @required
     * @readonly
     */
-   private org.apache.maven.artifact.resolver.ArtifactResolver resolver;
+   protected ArtifactResolver resolver;
 
    /**
     * Artifact collector, needed to resolve dependencies.
@@ -61,7 +68,7 @@
     * @required
     * @readonly
     */
-   private org.apache.maven.artifact.resolver.ArtifactCollector artifactCollector;
+   protected ArtifactCollector artifactCollector;
 
    /**
     * @component role="org.apache.maven.artifact.metadata.ArtifactMetadataSource"
@@ -69,7 +76,7 @@
     * @required
     * @readonly
     */
-   private org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource;
+   protected ArtifactMetadataSource artifactMetadataSource;
 
    /**
     * Location of the local repository.
@@ -78,7 +85,7 @@
     * @readonly
     * @required
     */
-   private org.apache.maven.artifact.repository.ArtifactRepository local;
+   protected ArtifactRepository localRepository;
 
    /**
     * List of Remote Repositories used by the resolver
@@ -87,7 +94,7 @@
     * @readonly
     * @required
     */
-   private java.util.List remoteRepos;
+   protected List remoteRepos;
 
    /**
     * To look up Archiver/UnArchiver implementations
@@ -96,7 +103,7 @@
     * @required
     * @readonly
     */
-   private org.codehaus.plexus.archiver.manager.ArchiverManager archiverManager;
+   protected ArchiverManager archiverManager;
 
    /**
     * POM
@@ -105,7 +112,7 @@
     * @readonly
     * @required
     */
-   private MavenProject project;
+   protected MavenProject project;
 
    /**
     * Contains the full list of projects in the reactor.
@@ -114,31 +121,77 @@
     * @required
     * @readonly
     */
-   private List reactorProjects;
+   protected List reactorProjects;
 
-   public org.codehaus.plexus.archiver.manager.ArchiverManager getArchiverManager()
+   /** 
+    * The required jboss home location.
+    * i.e. ~/svn/jbossas/tags/JBoss_5_0_0_Beta4/build/output/jboss-5.0.0.Beta4
+    * 
+    * @required
+    * @parameter 
+    */
+   protected File jbossHome;
+
+   /** 
+    * An optional list of files to undeploy
+    * @parameter  
+    */
+   protected List<String> undeploy;
+
+   /** 
+    * The optional temporary deployment directory
+    * @parameter 
+    */
+   protected File layoutDirectory;
+
+   /** 
+    * The optional list of dependencies
+    * @parameter 
+    */
+   private List<Deployment> dependencies;
+
+   /** 
+    * The optional layout result file
+    * This file can be used by the @see{UndeployerMojo} 
+    * @parameter 
+    */
+   protected File layoutResult;
+
+   /** 
+    * An optional falg to temporary deploy structure
+    * @parameter default-value="false" 
+    */
+   protected boolean keepLayout;
+
+   /** 
+    * The optional list of deployments
+    * @parameter 
+    */
+   private List<Deployment> deployments;
+
+   public ArchiverManager getArchiverManager()
    {
       return archiverManager;
    }
 
-   public org.apache.maven.artifact.resolver.ArtifactCollector getArtifactCollector()
+   public ArtifactCollector getArtifactCollector()
    {
       return artifactCollector;
    }
 
-   public org.apache.maven.artifact.metadata.ArtifactMetadataSource getArtifactMetadataSource()
+   public ArtifactMetadataSource getArtifactMetadataSource()
    {
       return artifactMetadataSource;
    }
 
-   public org.apache.maven.artifact.factory.ArtifactFactory getFactory()
+   public ArtifactFactory getFactory()
    {
       return factory;
    }
 
-   public org.apache.maven.artifact.repository.ArtifactRepository getLocal()
+   public ArtifactRepository getLocal()
    {
-      return local;
+      return localRepository;
    }
 
    public MavenProject getProject()
@@ -151,14 +204,49 @@
       return reactorProjects;
    }
 
-   public java.util.List getRemoteRepos()
+   public List getRemoteRepos()
    {
       return remoteRepos;
    }
 
-   public org.apache.maven.artifact.resolver.ArtifactResolver getResolver()
+   public ArtifactResolver getResolver()
    {
       return resolver;
    }
 
+   public File getJBossHome()
+   {
+      return jbossHome;
+   }
+
+   public List<String> getUndeploy()
+   {
+      return undeploy;
+   }
+
+   public File getLayoutDirectory()
+   {
+      return layoutDirectory;
+   }
+
+   public List<Deployment> getDependencies()
+   {
+      return dependencies;
+   }
+
+   public List<Deployment> getDeployments()
+   {
+      return deployments;
+   }
+
+   public File getLayoutResult()
+   {
+      return layoutResult;
+   }
+
+   public boolean isKeepLayout()
+   {
+      return keepLayout;
+   }
+
 }

Deleted: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DependenciesHandler.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DependenciesHandler.java	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DependenciesHandler.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -1,88 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.maven.plugin.deployer;
-
-//$Id$
-
-import java.io.File;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
-
-public class DependenciesHandler
-{
-   private DeployerMojo mojo;
-
-   private DependenciesHandler(DeployerMojo mojo)
-   {
-      this.mojo = mojo;
-   }
-
-   public static void process(DeployerMojo mojo) throws MojoExecutionException
-   {
-      new DependenciesHandler(mojo).process();
-   }
-
-   private void process() throws MojoExecutionException
-   {
-      List<Deployment> dependencies = mojo.getDependencies();
-      if (dependencies != null)
-      {
-         mojo.getLog().info("Dependencies");
-         for (Deployment dep : dependencies)
-         {
-            dep.validateConfiguration(mojo, false);
-            processDeployment(dep);
-         }
-      }
-   }
-
-   private void processDeployment(Deployment dep) throws MojoExecutionException
-   {
-      /*
-      boolean stripVersion = true;
-      
-      File outputDirectory = new File(mojo.getDeployStructure() + "/" + dep.getTargetDir());
-      mojo.setOutputDirectory(outputDirectory);
-      mojo.setStripVersion(stripVersion);
-
-      DependencyStatusSets dss = mojo.getDependencySets(true);
-      Set artifacts = dss.getResolvedDependencies();
-
-      for (Iterator i = artifacts.iterator(); i.hasNext();)
-      {
-         mojo.copyArtifact((Artifact)i.next(), stripVersion);
-      }
-
-      artifacts = dss.getSkippedDependencies();
-      for (Iterator i = artifacts.iterator(); i.hasNext();)
-      {
-         Artifact artifact = (Artifact)i.next();
-         mojo.getLog().info(artifact.getFile().getName() + " already exists in destination.");
-      }
-      */
-   }
-}

Modified: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeployerMojo.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeployerMojo.java	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeployerMojo.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -24,11 +24,20 @@
 // $Id$
 
 import java.io.File;
+import java.io.FileWriter;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.text.SimpleDateFormat;
+import java.util.Date;
 import java.util.List;
+import java.util.Map;
 
+import org.apache.maven.artifact.Artifact;
 import org.apache.maven.plugin.MojoExecutionException;
 import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.deployer.handlers.DependenciesHandler;
+import org.jboss.maven.plugin.deployer.handlers.DeploymentsHandler;
+import org.jboss.maven.plugin.deployer.handlers.UndeploymentsHandler;
 
 /**
  * Goal which copies files and dependencies to jboss
@@ -41,61 +50,29 @@
  */
 public class DeployerMojo extends AbstractDeployerMojo
 {
-   /** 
-    * The required jboss home location.
-    * i.e. ~/svn/jbossas/tags/JBoss_5_0_0_Beta4/build/output/jboss-5.0.0.Beta4
-    * 
-    * @required
-    * @parameter 
-    */
-   private File jbossHome;
+   public static final String PLUGIN_GROUPID = "org.jboss.maven.plugin";
+   public static final String PLUGIN_ARTIFACTID = "maven-deployer-plugin";
+   public static final String PLUGIN_ID = PLUGIN_GROUPID + ":" + PLUGIN_ARTIFACTID;
 
-   /** 
-    * The optional temporary deploy structure
-    * @parameter 
-    */
-   private File deployStructure;
-
-   /** 
-    * An optional falg to temporary deploy structure
-    * @parameter default-value="false" 
-    */
-   private boolean keepDeployStructure;
-
-   /** 
-    * The optional list of deployments
-    * @parameter 
-    */
-   private List<Deployment> deployments;
-
-   /** 
-    * The optional list of dependencies
-    * @parameter 
-    */
-   private List<Deployment> dependencies;
-
-   /** 
-    * An optional list of files to undeploy
-    * @parameter  
-    */
-   private List<String> undeployments;
-
    public void execute() throws MojoExecutionException
    {
       try
       {
          validateConfiguration();
 
-         getLog().info("project: " + project);
-         getLog().info("jbossHome: " + jbossHome);
+         getLog().info("jbossHome=" + jbossHome);
+         getLog().info("layoutDirectory=" + layoutDirectory);
 
          // recreate deploy structure
-         FileUtils.deleteDirectory(deployStructure);
-         deployStructure.mkdirs();
+         FileUtils.deleteDirectory(layoutDirectory);
+         layoutDirectory.mkdirs();
 
          UndeploymentsHandler.process(this);
          DeploymentsHandler.process(this);
-         //DependenciesHandler.process(this);
+         DependenciesHandler.process(this);
+
+         writeLayoutResult();
+         copyLayout();
       }
       catch (IOException ex)
       {
@@ -103,64 +80,64 @@
       }
       finally
       {
-         if (keepDeployStructure == false && deployStructure != null)
-            deployStructure.delete();
+         if (keepLayout == false && layoutDirectory != null)
+            layoutDirectory.delete();
       }
    }
 
-   /*
-    // public access to protected method
-    public DependencyStatusSets getDependencySets(boolean stopOnFailure) throws MojoExecutionException
-    {
-    return super.getDependencySets(stopOnFailure);
-    }
-
-    // public access to protected method
-    public void copyArtifact(Artifact artifact, boolean stripVersion) throws MojoExecutionException
-    {
-    super.copyArtifact(artifact, stripVersion);
-    }
-    */
-
-   public List<Deployment> getDependencies()
+   private void writeLayoutResult() throws IOException
    {
-      return dependencies;
-   }
+      if (layoutResult != null)
+      {
+         PrintWriter out = new PrintWriter(new FileWriter(layoutResult));
+         if (project != null)
+         {
+            out.println("# ProjectName:    " + project.getName());
+            out.println("# ProjectVersion: " + project.getVersion());
+            out.println("#");
+            Map pluginMap = project.getPluginArtifactMap();
+            Artifact plugin = (Artifact)pluginMap.get(PLUGIN_ID);
+            out.println("# PluginId:      " + PLUGIN_ID);
+            out.println("# PluginVersion: " + plugin.getVersion());
+            out.println("#");
+         }
+         SimpleDateFormat dateFormat = new SimpleDateFormat("E, dd MMM yyyy HH:mm:ss");
+         out.println("# Date: " + dateFormat.format(new Date()));
+         out.println("# User: " + System.getProperty("user.name"));
+         out.println("#");
 
-   public List<Deployment> getDeployments()
-   {
-      return deployments;
+         List<File> files = FileUtils.getFiles(layoutDirectory, null, null);
+         String layoutPath = layoutDirectory.getCanonicalPath();
+         for (File file : files)
+         {
+            String filePath = file.getCanonicalPath();
+            out.println(filePath.substring(layoutPath.length() + 1));
+         }
+         out.close();
+      }
    }
 
-   public File getDeployStructure()
+   private void copyLayout() throws IOException
    {
-      return deployStructure;
+      List<File> files = FileUtils.getFiles(layoutDirectory, null, null);
+      DeploymentsHandler.copyFiles(files, layoutDirectory, jbossHome);
    }
 
-   public File getJbossHome()
-   {
-      return jbossHome;
-   }
-
-   public boolean isKeepDeployStructure()
-   {
-      return keepDeployStructure;
-   }
-
-   public List<String> getUndeployments()
-   {
-      return undeployments;
-   }
-
    private void validateConfiguration() throws MojoExecutionException, IOException
    {
       if (jbossHome.exists() == false)
-         throw new MojoExecutionException("jbossHome does not exist: " + jbossHome);
+      {
+         jbossHome.mkdirs();
+         getLog().warn("Creating non existant jbossHome: " + jbossHome);
+      }
 
-      if (deployStructure == null)
+      if (layoutDirectory == null)
       {
-         deployStructure = File.createTempFile("maven-deploy", ".tmp").getParentFile();
-         getLog().debug("deployStructure: " + deployStructure);
+         File tmpFile = File.createTempFile(PLUGIN_ARTIFACTID, "");
+         getLog().debug("layoutDirectory: " + tmpFile);
+         tmpFile.delete();
+         tmpFile.mkdirs();
+         layoutDirectory = tmpFile;
       }
    }
 }

Deleted: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -1,108 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.maven.plugin.deployer;
-
-//$Id$
-
-import java.io.File;
-import java.util.List;
-
-import org.apache.maven.plugin.AbstractMojo;
-import org.apache.maven.plugin.MojoExecutionException;
-
-/**
- * A deployment config structure
- *
- * @author Thomas.Diesler at jboss.com
- * @since 16-Apr-2008
- */
-public class Deployment
-{
-   /**
-    * The target directory relative to 'jbossHome'
-    *  
-    * @required
-    * @parameter 
-    */
-   private String targetDir;
-   
-   /**
-    * The source directory
-    * @parameter 
-    */
-   private File sourceDir;
-   
-   /**
-    * The optional list of includes
-    * @parameter 
-    */
-   private List<String> includes;
-
-   /**
-    * The optional list of excludes
-    * @parameter 
-    */
-   private List<String> excludes;
-
-   public File getSourceDir()
-   {
-      return sourceDir;
-   }
-
-   public String getTargetDir()
-   {
-      return targetDir;
-   }
-
-   public List<String> getIncludes()
-   {
-      return includes;
-   }
-
-   public List<String> getExcludes()
-   {
-      return excludes;
-   }
-
-   public void validateConfiguration(DeployerMojo mojo, boolean sourceRequired) throws MojoExecutionException
-   {
-      String artifactId = mojo.getProject().getArtifactId();
-      
-      if (targetDir == null)
-      {
-         mojo.getLog().info("<deployment>");
-         mojo.getLog().info("  <targetDir>VALUE</targetDir>");
-         mojo.getLog().info("  ...");
-         mojo.getLog().info("</deployment>");
-         throw new MojoExecutionException("Inside the definition for plugin '" + artifactId + "' specify the following");
-      }
-      
-      if (sourceRequired == true && sourceDir == null)
-      {
-         mojo.getLog().info("<deployment>");
-         mojo.getLog().info("  <sourceDir>VALUE</sourceDir>");
-         mojo.getLog().info("  ...");
-         mojo.getLog().info("</deployment>");
-         throw new MojoExecutionException("Inside the definition for plugin '" + artifactId + "' specify the following");
-      }
-   }
-}

Added: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/Deployment.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,107 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.maven.plugin.deployer;
+
+//$Id$
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+
+/**
+ * A deployment config structure
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2008
+ */
+public class Deployment
+{
+   /**
+    * The target directory relative to 'jbossHome'
+    *  
+    * @required
+    * @parameter 
+    */
+   private String targetDir;
+
+   /**
+    * The source directory
+    * @parameter 
+    */
+   private File sourceDir;
+
+   /**
+    * The optional list of includes
+    * @parameter 
+    */
+   private List<String> includes;
+
+   /**
+    * The optional list of excludes
+    * @parameter 
+    */
+   private List<String> excludes;
+
+   public File getSourceDir()
+   {
+      return sourceDir;
+   }
+
+   public String getTargetDir()
+   {
+      return targetDir;
+   }
+
+   public List<String> getIncludes()
+   {
+      return includes;
+   }
+
+   public List<String> getExcludes()
+   {
+      return excludes;
+   }
+
+   public void validateConfiguration(AbstractDeployerMojo mojo, boolean sourceRequired) throws MojoExecutionException
+   {
+      String artifactId = DeployerMojo.PLUGIN_ARTIFACTID;
+
+      if (targetDir == null)
+      {
+         mojo.getLog().info("<deployment>");
+         mojo.getLog().info("  <targetDir>VALUE</targetDir>");
+         mojo.getLog().info("  ...");
+         mojo.getLog().info("</deployment>");
+         throw new MojoExecutionException("Inside the definition for plugin '" + artifactId + "' specify the following");
+      }
+
+      if (sourceRequired == true && sourceDir == null)
+      {
+         mojo.getLog().info("<deployment>");
+         mojo.getLog().info("  <sourceDir>VALUE</sourceDir>");
+         mojo.getLog().info("  ...");
+         mojo.getLog().info("</deployment>");
+         throw new MojoExecutionException("Inside the definition for plugin '" + artifactId + "' specify the following");
+      }
+   }
+}

Deleted: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeploymentsHandler.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeploymentsHandler.java	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeploymentsHandler.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.maven.plugin.deployer;
-
-// $Id$
-
-import java.io.File;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.maven.plugin.MojoExecutionException;
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Handles deployment of artifacts.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 16-Apr-2008
- */
-public class DeploymentsHandler
-{
-   private DeployerMojo mojo;
-
-   private DeploymentsHandler(DeployerMojo mojo)
-   {
-      this.mojo = mojo;
-   }
-
-   public static void process(DeployerMojo mojo) throws MojoExecutionException, IOException
-   {
-      new DeploymentsHandler(mojo).process();
-   }
-
-   private void process() throws MojoExecutionException, IOException
-   {
-      List<Deployment> deployments = mojo.getDeployments();
-      if (deployments != null)
-      {
-         mojo.getLog().info("Deploy");
-         for (Deployment dep : deployments)
-         {
-            dep.validateConfiguration(mojo, true);
-            processDeployment(dep);
-         }
-      }
-   }
-
-   private void processDeployment(Deployment dep) throws MojoExecutionException, IOException
-   {
-      String targetDir = dep.getTargetDir();
-      File sourceDir = dep.getSourceDir();
-
-      mojo.getLog().info(" +- " + targetDir);
-
-      List<String> includes = dep.getIncludes();
-      int offset = sourceDir.getCanonicalPath().length() + 1;
-
-      List<File> effectiveFiles = new ArrayList<File>();
-
-      // includes
-      if (includes != null)
-      {
-         for (String include : includes)
-         {
-            List<File> files = FileUtils.getFiles(sourceDir, include, null);
-            for (File file : files)
-            {
-               mojo.getLog().debug("Include: " + file.getCanonicalPath().substring(offset));
-               effectiveFiles.add(file);
-            }
-         }
-      }
-      else
-      {
-         List<File> files = FileUtils.getFiles(sourceDir, "**", null);
-         for (File file : files)
-         {
-            mojo.getLog().debug("Include: " + file.getCanonicalPath().substring(offset));
-            effectiveFiles.add(file);
-         }
-      }
-
-      // excludes
-      List<String> excludes = dep.getExcludes();
-      if (excludes != null)
-      {
-         for (String exclude : excludes)
-         {
-            List<File> files = FileUtils.getFiles(sourceDir, exclude, null);
-            for (File file : files)
-            {
-               mojo.getLog().debug("Exclude: " + file.getCanonicalPath().substring(offset));
-               effectiveFiles.remove(file);
-            }
-         }
-      }
-
-      File destRoot = new File(mojo.getDeployStructure() + "/" + targetDir);
-      copyFiles(effectiveFiles, sourceDir, destRoot);
-
-      for (File file : effectiveFiles)
-      {
-         mojo.getLog().info("  +- " + file.getCanonicalPath().substring(offset));
-      }
-   }
-
-   private void copyFiles(List<File> files, File sourceDir, File destRoot) throws IOException
-   {
-      int offset = sourceDir.getCanonicalPath().length() + 1;
-      for (File file : files)
-      {
-         if (file.getCanonicalPath().startsWith(sourceDir.getCanonicalPath()) == false)
-            throw new IOException("File is not from sourceDir: " + file);
-
-         String relFile = file.getCanonicalPath().substring(offset);
-         String relPath = new File(relFile).getParent();
-         File destDir = new File(destRoot + "/" + relPath);
-         FileUtils.copyFileToDirectory(file, destDir);
-      }
-   }
-}

Added: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeployerMojo.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeployerMojo.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeployerMojo.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.maven.plugin.deployer;
+
+// $Id$
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileReader;
+import java.io.IOException;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.deployer.handlers.UndeploymentsHandler;
+
+/**
+ * Goal which deletes files from jboss
+ *
+ * @goal undeploy-jboss
+ * 
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2008
+ */
+public class UndeployerMojo extends AbstractDeployerMojo
+{
+   public void execute() throws MojoExecutionException
+   {
+      try
+      {
+         validateConfiguration();
+
+         getLog().info("jbossHome: " + jbossHome);
+
+         UndeploymentsHandler.process(this);
+         processLayoutResult();
+      }
+      catch (IOException ex)
+      {
+         throw new MojoExecutionException("Cannot process goal 'deploy-jboss'", ex);
+      }
+   }
+
+   private void processLayoutResult() throws IOException
+   {
+      if (layoutResult != null)
+      {
+         getLog().info("Undeploy");
+         BufferedReader reader = new BufferedReader(new FileReader(layoutResult));
+         String line = reader.readLine();
+         while (line != null)
+         {
+            if (line.startsWith("#") == false)
+            {
+               File file = new File(jbossHome + "/" + line);
+               if (file.isDirectory())
+               {
+                  FileUtils.deleteDirectory(file.getCanonicalPath());
+                  getLog().info(" +- " + line + " (directory)");
+               }
+               else if (file.exists())
+               {
+                  file.delete();
+                  getLog().info(" +- " + line + " (file)");
+               }
+               else
+               {
+                  getLog().info(" +- " + line + " (not found)");
+               }
+            }
+            line = reader.readLine();
+         }
+         reader.close();
+      }
+   }
+
+   private void validateConfiguration() throws MojoExecutionException, IOException
+   {
+      if (jbossHome.exists() == false)
+         throw new MojoExecutionException("jbossHome does not exist: " + jbossHome);
+   }
+}


Property changes on: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeployerMojo.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Deleted: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeploymentsHandler.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeploymentsHandler.java	2008-04-17 14:17:52 UTC (rev 72358)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeploymentsHandler.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2005, JBoss Inc., and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.maven.plugin.deployer;
-
-// $Id$
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.codehaus.plexus.util.FileUtils;
-
-/**
- * Handles undeployment of artifacts.
- *
- * @author Thomas.Diesler at jboss.com
- * @since 16-Apr-2008
- */
-public class UndeploymentsHandler
-{
-   private DeployerMojo mojo;
-
-   private UndeploymentsHandler(DeployerMojo mojo)
-   {
-      this.mojo = mojo;
-   }
-
-   public static void process(DeployerMojo mojo) throws IOException
-   {
-      new UndeploymentsHandler(mojo).process();
-   }
-
-   private void process() throws IOException
-   {
-      List<String> undeployments = mojo.getUndeployments();
-      if (undeployments != null)
-      {
-         mojo.getLog().info("Undeploy");
-         for (String relFile : undeployments)
-         {
-            File file = new File(mojo.getJbossHome() + "/" + relFile);
-            if (file.isDirectory())
-            {
-               mojo.getLog().info(" +- " + relFile + " (directory)");
-               FileUtils.deleteDirectory(file);
-            }
-            else if (file.exists())
-            {
-               mojo.getLog().info(" +- " + relFile + " (file)");
-               file.delete();
-            }
-            else
-            {
-               mojo.getLog().info(" +- " + relFile + " (not found)");
-            }
-         }
-      }
-   }
-}

Copied: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DependenciesHandler.java (from rev 72328, projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DependenciesHandler.java)
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DependenciesHandler.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DependenciesHandler.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.maven.plugin.deployer.handlers;
+
+//$Id$
+
+import java.io.File;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.dependency.CopyDependenciesMojo;
+import org.apache.maven.plugin.dependency.utils.DependencyStatusSets;
+import org.apache.maven.project.MavenProject;
+import org.jboss.maven.plugin.deployer.AbstractDeployerMojo;
+import org.jboss.maven.plugin.deployer.Deployment;
+
+public class DependenciesHandler
+{
+   private AbstractDeployerMojo mojo;
+
+   private DependenciesHandler(AbstractDeployerMojo mojo)
+   {
+      this.mojo = mojo;
+   }
+
+   public static void process(AbstractDeployerMojo mojo) throws MojoExecutionException
+   {
+      new DependenciesHandler(mojo).process();
+   }
+
+   private void process() throws MojoExecutionException
+   {
+      List<Deployment> dependencies = mojo.getDependencies();
+      if (dependencies != null)
+      {
+         mojo.getLog().info("Dependencies");
+         for (Deployment dep : dependencies)
+         {
+            dep.validateConfiguration(mojo, false);
+            processDeployment(dep);
+         }
+      }
+   }
+
+   private void processDeployment(Deployment dep) throws MojoExecutionException
+   {
+      boolean stripVersion = true;
+      ExtCopyDependenciesMojo depMojo = new ExtCopyDependenciesMojo();
+      depMojo.setFactory(mojo.getFactory());
+      depMojo.setResolver(mojo.getResolver());
+      depMojo.setArtifactCollector(mojo.getArtifactCollector());
+      depMojo.setArtifactMetadataSource(mojo.getArtifactMetadataSource());
+      depMojo.setLocal(mojo.getLocal());
+      depMojo.setRemoteRepos(mojo.getRemoteRepos());
+      depMojo.setArchiverManager(mojo.getArchiverManager());
+      depMojo.setReactorProjects(mojo.getReactorProjects());
+      depMojo.setProject(mojo.getProject());
+      depMojo.setLog(mojo.getLog());
+      depMojo.setStripVersion(stripVersion);
+      depMojo.setCopyPom(false);
+      depMojo.setSilent(true);
+
+      File outputDirectory = new File(mojo.getLayoutDirectory() + "/" + dep.getTargetDir());
+      mojo.getLog().info(" +- " + dep.getTargetDir());
+
+      depMojo.setOutputDirectory(outputDirectory);
+
+      List<String> includes = dep.getIncludes();
+      if (includes != null)
+      {
+         String includeArtifactIds = includes.toString();
+         includeArtifactIds = includeArtifactIds.substring(1, includeArtifactIds.length() - 1);
+         depMojo.setIncludeArtifactIds(includeArtifactIds);
+      }
+
+      List<String> excludes = dep.getExcludes();
+      if (excludes != null)
+      {
+         String excludeArtifactIds = excludes.toString();
+         excludeArtifactIds = excludeArtifactIds.substring(1, excludeArtifactIds.length() - 1);
+         depMojo.setExcludeArtifactIds(excludeArtifactIds);
+      }
+
+      DependencyStatusSets dss = depMojo.getDependencySets(true);
+      Set artifacts = dss.getResolvedDependencies();
+
+      for (Iterator i = artifacts.iterator(); i.hasNext();)
+      {
+         Artifact artifact = (Artifact)i.next();
+         depMojo.copyArtifact(artifact, stripVersion);
+         mojo.getLog().info("  +- " + artifact);
+      }
+   }
+
+   /** Provides access to protected properties */
+   class ExtCopyDependenciesMojo extends CopyDependenciesMojo
+   {
+      public void setProject(MavenProject project)
+      {
+         super.project = project;
+      }
+
+      public void setReactorProjects(List reactorProjects)
+      {
+         super.reactorProjects = reactorProjects;
+      }
+
+      public void setIncludeArtifactIds(String includeArtifactIds)
+      {
+         super.includeArtifactIds = includeArtifactIds;
+      }
+
+      public void setExcludeArtifactIds(String excludeArtifactIds)
+      {
+         super.excludeArtifactIds = excludeArtifactIds;
+      }
+      
+      public void setSilent(boolean silent)
+      {
+         super.silent = silent;
+      }
+
+      @Override
+      public DependencyStatusSets getDependencySets(boolean stopOnFailure) throws MojoExecutionException
+      {
+         return super.getDependencySets(stopOnFailure);
+      }
+
+      @Override
+      public void copyArtifact(Artifact artifact, boolean removeVersion) throws MojoExecutionException
+      {
+         super.copyArtifact(artifact, removeVersion);
+      }
+   }
+}

Copied: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DeploymentsHandler.java (from rev 72328, projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/DeploymentsHandler.java)
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DeploymentsHandler.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/DeploymentsHandler.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,143 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.maven.plugin.deployer.handlers;
+
+// $Id$
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.deployer.AbstractDeployerMojo;
+import org.jboss.maven.plugin.deployer.Deployment;
+
+/**
+ * Handles deployment of artifacts.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2008
+ */
+public class DeploymentsHandler
+{
+   private AbstractDeployerMojo mojo;
+
+   private DeploymentsHandler(AbstractDeployerMojo mojo)
+   {
+      this.mojo = mojo;
+   }
+
+   public static void process(AbstractDeployerMojo mojo) throws MojoExecutionException, IOException
+   {
+      new DeploymentsHandler(mojo).process();
+   }
+
+   private void process() throws MojoExecutionException, IOException
+   {
+      List<Deployment> deployments = mojo.getDeployments();
+      if (deployments != null)
+      {
+         mojo.getLog().info("Deploy");
+         for (Deployment dep : deployments)
+         {
+            dep.validateConfiguration(mojo, true);
+            processDeployment(dep);
+         }
+      }
+   }
+
+   private void processDeployment(Deployment dep) throws MojoExecutionException, IOException
+   {
+      String targetDir = dep.getTargetDir();
+      File sourceDir = dep.getSourceDir();
+
+      mojo.getLog().info(" +- " + targetDir);
+
+      List<String> includes = dep.getIncludes();
+      int offset = sourceDir.getCanonicalPath().length() + 1;
+
+      List<File> effectiveFiles = new ArrayList<File>();
+
+      // includes
+      if (includes != null)
+      {
+         for (String include : includes)
+         {
+            List<File> files = FileUtils.getFiles(sourceDir, include, null);
+            for (File file : files)
+            {
+               mojo.getLog().debug("Include: " + file.getCanonicalPath().substring(offset));
+               effectiveFiles.add(file);
+            }
+         }
+      }
+      else
+      {
+         List<File> files = FileUtils.getFiles(sourceDir, "**", null);
+         for (File file : files)
+         {
+            mojo.getLog().debug("Include: " + file.getCanonicalPath().substring(offset));
+            effectiveFiles.add(file);
+         }
+      }
+
+      // excludes
+      List<String> excludes = dep.getExcludes();
+      if (excludes != null)
+      {
+         for (String exclude : excludes)
+         {
+            List<File> files = FileUtils.getFiles(sourceDir, exclude, null);
+            for (File file : files)
+            {
+               mojo.getLog().debug("Exclude: " + file.getCanonicalPath().substring(offset));
+               effectiveFiles.remove(file);
+            }
+         }
+      }
+
+      File destRoot = new File(mojo.getLayoutDirectory() + "/" + targetDir);
+      copyFiles(effectiveFiles, sourceDir, destRoot);
+
+      for (File file : effectiveFiles)
+      {
+         mojo.getLog().info("  +- " + file.getCanonicalPath().substring(offset));
+      }
+   }
+
+   public static void copyFiles(List<File> files, File sourceDir, File destRoot) throws IOException
+   {
+      int offset = sourceDir.getCanonicalPath().length() + 1;
+      for (File file : files)
+      {
+         if (file.getCanonicalPath().startsWith(sourceDir.getCanonicalPath()) == false)
+            throw new IOException("File is not from sourceDir: " + file);
+
+         String relFile = file.getCanonicalPath().substring(offset);
+         String relPath = new File(relFile).getParent();
+         File destDir = new File(destRoot + (relPath != null ? "/" + relPath : ""));
+         FileUtils.copyFileToDirectory(file, destDir);
+      }
+   }
+}

Copied: projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/UndeploymentsHandler.java (from rev 72328, projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/UndeploymentsHandler.java)
===================================================================
--- projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/UndeploymentsHandler.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/main/java/org/jboss/maven/plugin/deployer/handlers/UndeploymentsHandler.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.maven.plugin.deployer.handlers;
+
+// $Id$
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.deployer.AbstractDeployerMojo;
+
+/**
+ * Handles undeployment of artifacts.
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2008
+ */
+public class UndeploymentsHandler
+{
+   private AbstractDeployerMojo mojo;
+
+   private UndeploymentsHandler(AbstractDeployerMojo mojo)
+   {
+      this.mojo = mojo;
+   }
+
+   public static void process(AbstractDeployerMojo mojo) throws IOException
+   {
+      new UndeploymentsHandler(mojo).process();
+   }
+
+   private void process() throws IOException
+   {
+      List<String> undeployments = mojo.getUndeploy();
+      if (undeployments != null)
+      {
+         mojo.getLog().info("Undeploy");
+         for (String relFile : undeployments)
+         {
+            File file = new File(mojo.getJBossHome() + "/" + relFile);
+            if (file.isDirectory())
+            {
+               mojo.getLog().info(" +- " + relFile + " (directory)");
+               FileUtils.deleteDirectory(file);
+            }
+            else if (file.exists())
+            {
+               mojo.getLog().info(" +- " + relFile + " (file)");
+               file.delete();
+            }
+            else
+            {
+               mojo.getLog().info(" +- " + relFile + " (not found)");
+            }
+         }
+      }
+   }
+}

Added: projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/DeployerMojoTestCase.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/DeployerMojoTestCase.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/DeployerMojoTestCase.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,66 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.maven.plugin.deployer;
+
+// $Id$
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.deployer.DeployerMojo;
+
+/**
+ * Test DeployerMojo.deploy-jboss
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2008
+ */
+public class DeployerMojoTestCase extends AbstractMojoTestCase
+{
+   // required for mojo lookups to work
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+   }
+
+   public void testMojoGoal() throws Exception
+   {
+      File testPom = new File(getBasedir(), "src/test/resources/deploy-jboss-pom.xml");
+
+      DeployerMojo mojo = (DeployerMojo)lookupMojo("deploy-jboss", testPom);
+
+      assertNotNull("lookup mojo", mojo);
+      //assertNotNull("mojo project", mojo.getProject());
+
+      mojo.execute();
+
+      File layoutResult = new File(getBasedir(), "target/test-layout/deploy-layout.txt");
+      assertTrue("Cannot find layoutResult: " + layoutResult, layoutResult.exists());
+      
+      List<File> layoutFiles = FileUtils.getFiles(mojo.getLayoutDirectory(), null, null);
+      List<File> jbossFiles = FileUtils.getFiles(mojo.getJBossHome(), null, null);
+      assertTrue("Expected layout files: " + layoutResult, layoutFiles.size() > 0);
+      assertEquals("Filesets expected to have equal size", layoutFiles.size(), jbossFiles.size());
+   }
+}


Property changes on: projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/DeployerMojoTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/UndeployerMojoTestCase.java
===================================================================
--- projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/UndeployerMojoTestCase.java	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/UndeployerMojoTestCase.java	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.maven.plugin.deployer;
+
+// $Id$
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.plugin.testing.AbstractMojoTestCase;
+import org.codehaus.plexus.util.FileUtils;
+import org.jboss.maven.plugin.deployer.UndeployerMojo;
+import org.jboss.maven.plugin.deployer.handlers.DeploymentsHandler;
+
+/**
+ * Test UndeployerMojo.deploy-jboss
+ *
+ * @author Thomas.Diesler at jboss.com
+ * @since 16-Apr-2008
+ */
+public class UndeployerMojoTestCase extends AbstractMojoTestCase
+{
+   // required for mojo lookups to work
+   protected void setUp() throws Exception
+   {
+      super.setUp();
+
+      String jbossHome = "target/test-jboss-home";
+      FileUtils.deleteDirectory(jbossHome);
+
+      File sourceDir = new File("src/test/resources/test-jboss-home");
+      List<File> files = FileUtils.getFiles(sourceDir, null, null);
+      DeploymentsHandler.copyFiles(files, sourceDir, new File(jbossHome));
+   }
+
+   public void testMojoGoal() throws Exception
+   {
+      File testPom = new File(getBasedir(), "src/test/resources/undeploy-jboss-pom.xml");
+
+      UndeployerMojo mojo = (UndeployerMojo)lookupMojo("undeploy-jboss", testPom);
+
+      assertNotNull("lookup mojo", mojo);
+      //assertNotNull("mojo project", mojo.getProject());
+
+      mojo.execute();
+
+      List<File> jbossFiles = FileUtils.getFiles(mojo.getJBossHome(), null, null);
+      assertEquals("Expected no jboss files", 0, jbossFiles.size());
+   }
+}


Property changes on: projects/maven/plugins/deployer/trunk/src/test/java/org/jboss/test/maven/plugin/deployer/UndeployerMojoTestCase.java
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/maven/plugins/deployer/trunk/src/test/resources/deploy-jboss-pom.xml
===================================================================
--- projects/maven/plugins/deployer/trunk/src/test/resources/deploy-jboss-pom.xml	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/test/resources/deploy-jboss-pom.xml	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,64 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <name>Maven Deployer Plugin Test</name>
+  <groupId>org.jboss.maven.plugin</groupId>
+  <artifactId>maven-deployer-plugin-test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <url>http://maven.apache.org</url>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.maven.plugin</groupId>
+      <artifactId>maven-deployer-plugin</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.jboss.maven.plugin</groupId>
+        <artifactId>maven-deployer-plugin</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <configuration>
+          <jbossHome>target/test-jboss-home</jbossHome>
+          <layoutDirectory>target/test-layout</layoutDirectory>
+          <layoutResult>target/test-layout/deploy-layout.txt</layoutResult>
+          <keepLayout>true</keepLayout>
+          <!-- relative to jbossHome -->
+          <undeploy>
+            <include>../test-classes/deploy-jboss-pom.xml</include>
+            <include>../test-classes/bogus</include>
+          </undeploy>
+          <deployments>
+            <deployment>
+              <targetDir>bin</targetDir>
+              <sourceDir>src/main/java</sourceDir>
+              <includes>
+                <include>**/*.java</include>
+              </includes>
+            </deployment>
+          </deployments>
+          <!-- 
+            does not work from test case
+            http://svn.apache.org/viewvc/maven/plugins/tags/maven-plugins-10/maven-dependency-plugin/src/test/java/org/apache/maven/plugin/dependency/TestCopyDependenciesMojo.java?revision=587345&view=markup
+            
+          <dependencies>
+            <deployment>
+              <targetDir>libs</targetDir>
+              <includes>
+                <include>commons-validator</include>
+              </includes>
+            </deployment>
+          </dependencies>
+          -->
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>


Property changes on: projects/maven/plugins/deployer/trunk/src/test/resources/deploy-jboss-pom.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF

Added: projects/maven/plugins/deployer/trunk/src/test/resources/undeploy-jboss-pom.xml
===================================================================
--- projects/maven/plugins/deployer/trunk/src/test/resources/undeploy-jboss-pom.xml	                        (rev 0)
+++ projects/maven/plugins/deployer/trunk/src/test/resources/undeploy-jboss-pom.xml	2008-04-17 14:20:00 UTC (rev 72359)
@@ -0,0 +1,35 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  
+  <name>Maven Deployer Plugin Test</name>
+  <groupId>org.jboss.maven.plugin</groupId>
+  <artifactId>maven-deployer-plugin-test</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>pom</packaging>
+  <url>http://maven.apache.org</url>
+  
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.maven.plugin</groupId>
+      <artifactId>maven-deployer-plugin</artifactId>
+      <version>${version}</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.jboss.maven.plugin</groupId>
+        <artifactId>maven-deployer-plugin</artifactId>
+        <version>1.0-SNAPSHOT</version>
+        <configuration>
+          <jbossHome>target/test-jboss-home</jbossHome>
+          <layoutResult>target/test-jboss-home/deploy-layout.txt</layoutResult>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+  
+</project>


Property changes on: projects/maven/plugins/deployer/trunk/src/test/resources/undeploy-jboss-pom.xml
___________________________________________________________________
Name: svn:keywords
   + Id Revision
Name: svn:eol-style
   + LF




More information about the jboss-cvs-commits mailing list