You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2012/06/11 17:12:43 UTC

svn commit: r1348895 - /openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java

Author: rmannibucau
Date: Mon Jun 11 15:12:43 2012
New Revision: 1348895

URL: http://svn.apache.org/viewvc?rev=1348895&view=rev
Log:
ability to specify a zip as dependency

Modified:
    openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java

Modified: openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java
URL: http://svn.apache.org/viewvc/openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java?rev=1348895&r1=1348894&r2=1348895&view=diff
==============================================================================
--- openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java (original)
+++ openejb/trunk/openejb/maven/tomee-maven-plugin/src/main/java/org/apache/openejb/maven/plugin/AbstractTomEEMojo.java Mon Jun 11 15:12:43 2012
@@ -49,6 +49,7 @@ import org.apache.maven.settings.Setting
 import org.apache.openejb.config.RemoteServer;
 import org.apache.openejb.loader.FileUtils;
 import org.apache.openejb.loader.IO;
+import org.apache.openejb.loader.Zips;
 
 import static org.apache.maven.artifact.Artifact.SCOPE_COMPILE;
 import static org.apache.maven.artifact.repository.ArtifactRepositoryPolicy.CHECKSUM_POLICY_WARN;
@@ -63,6 +64,8 @@ import static org.codehaus.plexus.util.I
 
 public abstract class AbstractTomEEMojo extends AbstractAddressMojo {
     private static final String NAME_STR = "?name=";
+    private static final String UNZIP_PREFIX = "unzip:";
+
 
     /**
      * @component
@@ -300,6 +303,12 @@ public abstract class AbstractTomEEMojo 
             }
         }
 
+        boolean unzip = false;
+        if (lib.startsWith(UNZIP_PREFIX)) {
+            lib = lib.substring(UNZIP_PREFIX.length());
+            unzip = true;
+        }
+
         final String[] infos = lib.split(":");
         final String classifier;
         final String type;
@@ -321,18 +330,25 @@ public abstract class AbstractTomEEMojo 
             final Artifact artifact = factory.createDependencyArtifact(infos[0], infos[1], createFromVersion(infos[2]), type, classifier, SCOPE_COMPILE);
             resolver.resolve(artifact, remoteRepos, local);
             final File file = artifact.getFile();
-            final File dest;
-            if (extractedName == null) {
-                dest = new File(destParent, file.getName());
-            } else {
-                dest = new File(destParent, extractedName);
-            }
 
-            is = new BufferedInputStream(new FileInputStream(file));
-            os = new BufferedOutputStream(new FileOutputStream(dest));
-            copy(is, os);
+            if (!unzip) {
+                final File dest;
+                if (extractedName == null) {
+                    dest = new File(destParent, file.getName());
+                } else {
+                    dest = new File(destParent, extractedName);
+                }
+
+                is = new BufferedInputStream(new FileInputStream(file));
+                os = new BufferedOutputStream(new FileOutputStream(dest));
+                copy(is, os);
+
+                getLog().info("Copied '" + lib + "' in '" + dest.getAbsolutePath());
+            } else {
+                Zips.unzip(file, destParent, true);
 
-            getLog().info("Copied '" + lib + "' in '" + dest.getAbsolutePath());
+                getLog().info("Unzipped '" + lib + "' in '" + destParent.getAbsolutePath());
+            }
         } catch (Exception e) {
             getLog().error(e.getMessage(), e);
             throw new TomEEException(e.getMessage(), e);