maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1416982 - /maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
Date Tue, 04 Dec 2012 15:11:25 GMT
Author: krosenvold
Date: Tue Dec  4 15:11:24 2012
New Revision: 1416982

URL: http://svn.apache.org/viewvc?rev=1416982&view=rev
Log:
Added ability to fine-control where resources are extracted

Modified:
    maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java

Modified: maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java?rev=1416982&r1=1416981&r2=1416982&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
(original)
+++ maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
Tue Dec  4 15:11:24 2012
@@ -59,27 +59,32 @@ public class ResourceExtractor {
     public static File extractResourcePath(Class cl, String resourcePath, File tempDir, boolean
alwaysExtract)
             throws IOException {
         File dest = new File(tempDir, resourcePath);
+        return extractResourceToDestination(cl, resourcePath, dest,  alwaysExtract);
+    }
+
+    public static File extractResourceToDestination(Class cl, String resourcePath, File destination,
boolean alwaysExtract)
+            throws IOException {
         URL url = cl.getResource(resourcePath);
         if (url == null) throw new IllegalArgumentException("Resource not found: " + resourcePath);
         if ("jar".equalsIgnoreCase(url.getProtocol())) {
             File jarFile = getJarFileFromUrl(url);
-            extractResourcePathFromJar(cl, jarFile, resourcePath, dest);
+            extractResourcePathFromJar(cl, jarFile, resourcePath, destination);
         } else {
             try {
                 File resourceFile = new File(new URI(url.toExternalForm()));
                 if (!alwaysExtract) return resourceFile;
                 if (resourceFile.isDirectory()) {
-                    FileUtils.copyDirectoryStructure(resourceFile, dest);
+                    FileUtils.copyDirectoryStructure(resourceFile, destination);
                 } else {
-                    FileUtils.copyFile(resourceFile, dest);
+                    FileUtils.copyFile(resourceFile, destination);
                 }
             } catch (URISyntaxException e) {
                 throw new RuntimeException("Couldn't convert URL to File:" + url, e);
             }
         }
-        return dest;
+        return destination;
     }
-    
+
     private static void extractResourcePathFromJar(Class cl, File jarFile, String resourcePath,
File dest) throws IOException {
         ZipFile z = new ZipFile(jarFile, ZipFile.OPEN_READ);
         String zipStyleResourcePath = resourcePath.substring(1) + "/"; 



Mime
View raw message