You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by kr...@apache.org on 2012/12/04 16:13:36 UTC

svn commit: r1416983 - in /maven/shared/trunk/maven-verifier/src: main/java/org/apache/maven/it/ main/java/org/apache/maven/it/util/ site/ test/java/org/apache/maven/it/

Author: krosenvold
Date: Tue Dec  4 15:13:34 2012
New Revision: 1416983

URL: http://svn.apache.org/viewvc?rev=1416983&view=rev
Log:
o Reformated to code style so Hervé doesn't have to do it ;)

Modified:
    maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Classpath3xLauncher.java
    maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Embedded3xLauncher.java
    maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java
    maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
    maven/shared/trunk/maven-verifier/src/site/site.xml
    maven/shared/trunk/maven-verifier/src/test/java/org/apache/maven/it/VerifierTest.java

Modified: maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Classpath3xLauncher.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Classpath3xLauncher.java?rev=1416983&r1=1416982&r2=1416983&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Classpath3xLauncher.java (original)
+++ maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Classpath3xLauncher.java Tue Dec  4 15:13:34 2012
@@ -30,7 +30,7 @@ import java.util.Properties;
 /**
  * Launches an embedded Maven 3.x instance from the current class path, i.e. the Maven 3.x dependencies are assumed to
  * be present on the class path.
- * 
+ *
  * @author Benjamin Bentmann
  */
 class Classpath3xLauncher
@@ -88,7 +88,7 @@ class Classpath3xLauncher
             Thread.currentThread().setContextClassLoader( mavenCli.getClass().getClassLoader() );
             try
             {
-                Object result = doMain.invoke( mavenCli, new Object[] { cliArgs, workingDirectory, out, out } );
+                Object result = doMain.invoke( mavenCli, new Object[]{ cliArgs, workingDirectory, out, out } );
 
                 return ( (Number) result ).intValue();
             }

Modified: maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Embedded3xLauncher.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Embedded3xLauncher.java?rev=1416983&r1=1416982&r2=1416983&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Embedded3xLauncher.java (original)
+++ maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Embedded3xLauncher.java Tue Dec  4 15:13:34 2012
@@ -37,7 +37,7 @@ import java.util.Properties;
 
 /**
  * Launches an embedded Maven 3.x instance from some Maven installation directory.
- * 
+ *
  * @author Benjamin Bentmann
  */
 class Embedded3xLauncher
@@ -70,9 +70,9 @@ class Embedded3xLauncher
 
             Object launcher = launcherClass.newInstance();
 
-            Method configure = launcherClass.getMethod( "configure", new Class[] { InputStream.class } );
+            Method configure = launcherClass.getMethod( "configure", new Class[]{ InputStream.class } );
 
-            configure.invoke( launcher, new Object[] { new FileInputStream( config ) } );
+            configure.invoke( launcher, new Object[]{ new FileInputStream( config ) } );
 
             Method getWorld = launcherClass.getMethod( "getWorld", null );
             Object classWorld = getWorld.invoke( launcher, null );
@@ -80,8 +80,8 @@ class Embedded3xLauncher
             Method getMainClass = launcherClass.getMethod( "getMainClass", null );
             Class cliClass = (Class) getMainClass.invoke( launcher, null );
 
-            Constructor newMavenCli = cliClass.getConstructor( new Class[] { classWorld.getClass() } );
-            mavenCli = newMavenCli.newInstance( new Object[] { classWorld } );
+            Constructor newMavenCli = cliClass.getConstructor( new Class[]{ classWorld.getClass() } );
+            mavenCli = newMavenCli.newInstance( new Object[]{ classWorld } );
 
             Class[] parameterTypes = { String[].class, String.class, PrintStream.class, PrintStream.class };
             doMain = cliClass.getMethod( "doMain", parameterTypes );
@@ -174,7 +174,7 @@ class Embedded3xLauncher
             Thread.currentThread().setContextClassLoader( mavenCli.getClass().getClassLoader() );
             try
             {
-                Object result = doMain.invoke( mavenCli, new Object[] { cliArgs, workingDirectory, out, out } );
+                Object result = doMain.invoke( mavenCli, new Object[]{ cliArgs, workingDirectory, out, out } );
 
                 return ( (Number) result ).intValue();
             }

Modified: maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java?rev=1416983&r1=1416982&r2=1416983&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java (original)
+++ maven/shared/trunk/maven-verifier/src/main/java/org/apache/maven/it/Verifier.java Tue Dec  4 15:13:34 2012
@@ -19,23 +19,6 @@ package org.apache.maven.it;
  * under the License.
  */
 
-import junit.framework.Assert;
-import org.apache.maven.shared.utils.cli.CommandLineException;
-import org.apache.maven.shared.utils.cli.CommandLineUtils;
-import org.apache.maven.shared.utils.cli.Commandline;
-import org.apache.maven.shared.utils.cli.StreamConsumer;
-import org.apache.maven.shared.utils.cli.WriterStreamConsumer;
-import org.apache.maven.shared.utils.StringUtils;
-import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-import org.xml.sax.helpers.DefaultHandler;
-
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.parsers.SAXParser;
-import javax.xml.parsers.SAXParserFactory;
 import java.io.BufferedReader;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
@@ -63,6 +46,24 @@ import java.util.Properties;
 import java.util.StringTokenizer;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
+import org.apache.maven.shared.utils.StringUtils;
+import org.apache.maven.shared.utils.cli.CommandLineException;
+import org.apache.maven.shared.utils.cli.CommandLineUtils;
+import org.apache.maven.shared.utils.cli.Commandline;
+import org.apache.maven.shared.utils.cli.StreamConsumer;
+import org.apache.maven.shared.utils.cli.WriterStreamConsumer;
+import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
+
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+
+import junit.framework.Assert;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * @author Jason van Zyl
@@ -250,10 +251,11 @@ public class Verifier
     {
         List lines = loadFile( getBasedir(), "expected-results.txt", false );
 
-        for (Object line1 : lines) {
+        for ( Object line1 : lines )
+        {
             String line = (String) line1;
 
-            verifyExpectedResult(line);
+            verifyExpectedResult( line );
         }
 
         if ( chokeOnErrorOutput )
@@ -265,12 +267,14 @@ public class Verifier
     public void verifyErrorFreeLog()
         throws VerificationException
     {
-        List<String> lines = loadFile(getBasedir(), getLogFileName(), false);
+        List<String> lines = loadFile( getBasedir(), getLogFileName(), false );
 
-        for (String line : lines) {
+        for ( String line : lines )
+        {
             // A hack to keep stupid velocity resource loader errors from triggering failure
-            if (line.contains("[ERROR]") && !isVelocityError(line)) {
-                throw new VerificationException("Error in execution: " + line);
+            if ( line.contains( "[ERROR]" ) && !isVelocityError( line ) )
+            {
+                throw new VerificationException( "Error in execution: " + line );
             }
         }
     }
@@ -284,7 +288,7 @@ public class Verifier
      */
     private static boolean isVelocityError( String line )
     {
-        return line.contains("VM_global_library.vm") || line.contains("VM #") && line.contains("macro");
+        return line.contains( "VM_global_library.vm" ) || line.contains( "VM #" ) && line.contains( "macro" );
     }
 
     /**
@@ -296,11 +300,13 @@ public class Verifier
     public void verifyTextInLog( String text )
         throws VerificationException
     {
-        List<String> lines = loadFile(getBasedir(), getLogFileName(), false);
+        List<String> lines = loadFile( getBasedir(), getLogFileName(), false );
 
         boolean result = false;
-        for (String line : lines) {
-            if (line.contains(text)) {
+        for ( String line : lines )
+        {
+            if ( line.contains( text ) )
+            {
                 result = true;
                 break;
             }
@@ -503,11 +509,15 @@ public class Verifier
                 }
             } );
 
-            for (String file : files) {
-                if (hasCommand) {
-                    l.add(command + " " + new File(dir, file).getPath());
-                } else {
-                    l.add(new File(dir, file).getPath());
+            for ( String file : files )
+            {
+                if ( hasCommand )
+                {
+                    l.add( command + " " + new File( dir, file ).getPath() );
+                }
+                else
+                {
+                    l.add( new File( dir, file ).getPath() );
                 }
             }
         }
@@ -691,10 +701,11 @@ public class Verifier
 
             List<String> lines = loadFile( f, true );
 
-            for (String line1 : lines) {
-                String line = resolveCommandLineArg(line1);
+            for ( String line1 : lines )
+            {
+                String line = resolveCommandLineArg( line1 );
 
-                executeCommand(line);
+                executeCommand( line );
             }
         }
         catch ( VerificationException e )
@@ -840,8 +851,9 @@ public class Verifier
         throws IOException
     {
         List<String> files = getArtifactFileNameList( org, name, version, ext );
-        for (String fileName : files) {
-            FileUtils.forceDelete(new File(fileName));
+        for ( String fileName : files )
+        {
+            FileUtils.forceDelete( new File( fileName ) );
         }
     }
 
@@ -943,9 +955,10 @@ public class Verifier
         File srcFile = new File( getBasedir(), srcPath );
         String data = FileUtils.fileRead( srcFile, fileEncoding );
 
-        for (String token : filterProperties.keySet()) {
-            String value = String.valueOf(filterProperties.get(token));
-            data = StringUtils.replace(data, token, value);
+        for ( String token : filterProperties.keySet() )
+        {
+            String value = String.valueOf( filterProperties.get( token ) );
+            data = StringUtils.replace( data, token, value );
         }
 
         File dstFile = new File( getBasedir(), dstPath );
@@ -1037,11 +1050,15 @@ public class Verifier
     private void verifyArtifactPresence( boolean wanted, String org, String name, String version, String ext )
     {
         List<String> files = getArtifactFileNameList( org, name, version, ext );
-        for (String fileName : files) {
-            try {
-                verifyExpectedResult(fileName, wanted);
-            } catch (VerificationException e) {
-                Assert.fail(e.getMessage());
+        for ( String fileName : files )
+        {
+            try
+            {
+                verifyExpectedResult( fileName, wanted );
+            }
+            catch ( VerificationException e )
+            {
+                Assert.fail( e.getMessage() );
             }
         }
     }
@@ -1153,8 +1170,10 @@ public class Verifier
 
                     if ( candidates != null )
                     {
-                        for (String candidate : candidates) {
-                            if (candidate.matches(shortNamePattern)) {
+                        for ( String candidate : candidates )
+                        {
+                            if ( candidate.matches( shortNamePattern ) )
+                            {
                                 found = true;
                                 break;
                             }
@@ -1205,7 +1224,7 @@ public class Verifier
     public void executeGoal( String goal, Map envVars )
         throws VerificationException
     {
-        executeGoals( Arrays.asList(goal), envVars );
+        executeGoals( Arrays.asList( goal ), envVars );
     }
 
     public void executeGoals( List<String> goals )
@@ -1261,14 +1280,18 @@ public class Verifier
 
         File logFile = new File( getBasedir(), getLogFileName() );
 
-        for (Object cliOption : cliOptions) {
-            String key = String.valueOf(cliOption);
+        for ( Object cliOption : cliOptions )
+        {
+            String key = String.valueOf( cliOption );
 
-            String resolvedArg = resolveCommandLineArg(key);
+            String resolvedArg = resolveCommandLineArg( key );
 
-            try {
-                args.addAll(Arrays.asList(CommandLineUtils.translateCommandline(resolvedArg)));
-            } catch (Exception e) {
+            try
+            {
+                args.addAll( Arrays.asList( CommandLineUtils.translateCommandline( resolvedArg ) ) );
+            }
+            catch ( Exception e )
+            {
                 e.printStackTrace();
             }
         }
@@ -1282,10 +1305,11 @@ public class Verifier
             args.add( "--debug" );
         }
 
-        for (Object o : systemProperties.keySet()) {
+        for ( Object o : systemProperties.keySet() )
+        {
             String key = (String) o;
-            String value = systemProperties.getProperty(key);
-            args.add("-D" + key + "=" + value);
+            String value = systemProperties.getProperty( key );
+            args.add( "-D" + key + "=" + value );
         }
 
         /*
@@ -1294,7 +1318,7 @@ public class Verifier
          * setup for the current build. In particular, using "maven.repo.local" will make sure the forked builds use
          * the same local repo as the parent build even if a custom user settings is provided.
          */
-        boolean useMavenRepoLocal = Boolean.valueOf(verifierProperties.getProperty("use.mavenRepoLocal", "true"));
+        boolean useMavenRepoLocal = Boolean.valueOf( verifierProperties.getProperty( "use.mavenRepoLocal", "true" ) );
 
         if ( useMavenRepoLocal )
         {
@@ -1356,10 +1380,10 @@ public class Verifier
         {
             System.err.println( "Exit code: " + ret );
 
-            throw new VerificationException( "Exit code was non-zero: " + ret + "; command line and log = \n"
-                                                 + new File( defaultMavenHome, "bin/mvn" ) + " "
-                                                 + StringUtils.join( args.iterator(), " " ) + "\n" + getLogContents(
-                logFile ) );
+            throw new VerificationException(
+                "Exit code was non-zero: " + ret + "; command line and log = \n" + new File( defaultMavenHome,
+                                                                                             "bin/mvn" ) + " "
+                    + StringUtils.join( args.iterator(), " " ) + "\n" + getLogContents( logFile ) );
         }
     }
 
@@ -1370,11 +1394,11 @@ public class Verifier
         {
             if ( StringUtils.isEmpty( defaultMavenHome ) )
             {
-                embeddedLauncher.set( new Classpath3xLauncher());
+                embeddedLauncher.set( new Classpath3xLauncher() );
             }
             else
             {
-                embeddedLauncher.set( new Embedded3xLauncher( defaultMavenHome ));
+                embeddedLauncher.set( new Embedded3xLauncher( defaultMavenHome ) );
             }
         }
     }
@@ -1463,7 +1487,7 @@ public class Verifier
     private String resolveCommandLineArg( String key )
     {
         String result = key.replaceAll( "\\$\\{basedir\\}", getBasedir() );
-        if (result.contains("\\\\"))
+        if ( result.contains( "\\\\" ) )
         {
             result = result.replaceAll( "\\\\", "\\" );
         }
@@ -1481,8 +1505,9 @@ public class Verifier
 
             List<File> subTests = FileUtils.getFiles( new File( directory ), "**/goals.txt", null );
 
-            for (File testCase : subTests) {
-                tests.add(testCase.getParent());
+            for ( File testCase : subTests )
+            {
+                tests.add( testCase.getParent() );
             }
 
             return tests;
@@ -1599,25 +1624,35 @@ public class Verifier
         {
             tests = new ArrayList<String>( argsList.size() );
             NumberFormat fmt = new DecimalFormat( "0000" );
-            for (String test : argsList) {
-                if (test.endsWith(",")) {
-                    test = test.substring(0, test.length() - 1);
+            for ( String test : argsList )
+            {
+                if ( test.endsWith( "," ) )
+                {
+                    test = test.substring( 0, test.length() - 1 );
                 }
 
-                if (StringUtils.isNumeric(test)) {
+                if ( StringUtils.isNumeric( test ) )
+                {
 
-                    test = "it" + fmt.format(Integer.valueOf(test));
-                    tests.add(test.trim());
-                } else if ("it".startsWith(test)) {
+                    test = "it" + fmt.format( Integer.valueOf( test ) );
+                    tests.add( test.trim() );
+                }
+                else if ( "it".startsWith( test ) )
+                {
                     test = test.trim();
-                    if (test.length() > 0) {
-                        tests.add(test);
+                    if ( test.length() > 0 )
+                    {
+                        tests.add( test );
                     }
-                } else if (FileUtils.fileExists(test) && new File(test).isDirectory()) {
-                    tests.addAll(discoverIntegrationTests(test));
-                } else {
+                }
+                else if ( FileUtils.fileExists( test ) && new File( test ).isDirectory() )
+                {
+                    tests.addAll( discoverIntegrationTests( test ) );
+                }
+                else
+                {
                     System.err.println(
-                            "[WARNING] rejecting " + test + " as an invalid test or test source directory");
+                        "[WARNING] rejecting " + test + " as an invalid test or test source directory" );
                 }
             }
         }
@@ -1630,40 +1665,45 @@ public class Verifier
         int exitCode = 0;
 
         List<String> failed = new ArrayList<String>();
-        for (String test : tests) {
-            System.out.print(test + "... ");
+        for ( String test : tests )
+        {
+            System.out.print( test + "... " );
 
             String dir = basedir + "/" + test;
 
-            if (!new File(dir, "goals.txt").exists()) {
-                System.err.println("Test " + test + " in " + dir + " does not exist");
+            if ( !new File( dir, "goals.txt" ).exists() )
+            {
+                System.err.println( "Test " + test + " in " + dir + " does not exist" );
 
-                System.exit(2);
+                System.exit( 2 );
             }
 
-            Verifier verifier = new Verifier(dir);
-            verifier.findLocalRepo(settingsFile);
+            Verifier verifier = new Verifier( dir );
+            verifier.findLocalRepo( settingsFile );
 
-            System.out.println("Using default local repository: " + verifier.localRepo);
+            System.out.println( "Using default local repository: " + verifier.localRepo );
 
-            try {
-                runIntegrationTest(verifier);
-            } catch (Throwable e) {
+            try
+            {
+                runIntegrationTest( verifier );
+            }
+            catch ( Throwable e )
+            {
                 verifier.resetStreams();
 
-                System.out.println("FAILED");
+                System.out.println( "FAILED" );
 
                 verifier.displayStreamBuffers();
 
-                System.out.println(">>>>>> Error Stacktrace:");
-                e.printStackTrace(System.out);
-                System.out.println("<<<<<< Error Stacktrace");
+                System.out.println( ">>>>>> Error Stacktrace:" );
+                e.printStackTrace( System.out );
+                System.out.println( "<<<<<< Error Stacktrace" );
 
                 verifier.displayLogFile();
 
                 exitCode = 1;
 
-                failed.add(test);
+                failed.add( test );
             }
         }
 
@@ -1717,8 +1757,7 @@ public class Verifier
 
         Properties controlProperties = verifier.loadProperties( "verifier.properties" );
 
-        boolean chokeOnErrorOutput =
-                Boolean.valueOf(controlProperties.getProperty("failOnErrorOutput", "true"));
+        boolean chokeOnErrorOutput = Boolean.valueOf( controlProperties.getProperty( "failOnErrorOutput", "true" ) );
 
         List<String> goals = verifier.loadFile( verifier.getBasedir(), "goals.txt", false );
 

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=1416983&r1=1416982&r2=1416983&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:13:34 2012
@@ -19,9 +19,6 @@ package org.apache.maven.it.util;
  * under the License.
  */
 
-import org.apache.maven.shared.utils.io.FileUtils;
-import org.apache.maven.shared.utils.io.IOUtil;
-
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.IOException;
@@ -31,109 +28,157 @@ import java.net.URL;
 import java.util.Enumeration;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipFile;
+import org.apache.maven.shared.utils.io.FileUtils;
+import org.apache.maven.shared.utils.io.IOUtil;
 
 
 /* @todo this can be replaced with plexus-archiver */
-public class ResourceExtractor {
-    
-    public static File simpleExtractResources(Class cl, String resourcePath) throws IOException {
+public class ResourceExtractor
+{
+
+    public static File simpleExtractResources( Class cl, String resourcePath )
+        throws IOException
+    {
         String tempDirPath = System.getProperty( "maven.test.tmpdir", System.getProperty( "java.io.tmpdir" ) );
-        File tempDir = new File(tempDirPath);
-               
+        File tempDir = new File( tempDirPath );
+
         File testDir = new File( tempDir, resourcePath );
 
         FileUtils.deleteDirectory( testDir );
-        
-        testDir = ResourceExtractor.extractResourcePath(cl, resourcePath, tempDir, false);
+
+        testDir = ResourceExtractor.extractResourcePath( cl, resourcePath, tempDir, false );
         return testDir;
     }
-    
-    public static File extractResourcePath(String resourcePath, File dest) throws IOException {
-        return extractResourcePath(ResourceExtractor.class, resourcePath, dest);
-    }
-    
-    public static File extractResourcePath(Class cl, String resourcePath, File dest) throws IOException {
-        return extractResourcePath(cl, resourcePath, dest, false);
-    }
-    
-    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, destination);
-        } else {
-            try {
-                File resourceFile = new File(new URI(url.toExternalForm()));
-                if (!alwaysExtract) return resourceFile;
-                if (resourceFile.isDirectory()) {
-                    FileUtils.copyDirectoryStructure(resourceFile, destination);
-                } else {
-                    FileUtils.copyFile(resourceFile, destination);
+
+    public static File extractResourcePath( String resourcePath, File dest )
+        throws IOException
+    {
+        return extractResourcePath( ResourceExtractor.class, resourcePath, dest );
+    }
+
+    public static File extractResourcePath( Class cl, String resourcePath, File dest )
+        throws IOException
+    {
+        return extractResourcePath( cl, resourcePath, dest, false );
+    }
+
+    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, destination );
+        }
+        else
+        {
+            try
+            {
+                File resourceFile = new File( new URI( url.toExternalForm() ) );
+                if ( !alwaysExtract )
+                {
+                    return resourceFile;
                 }
-            } catch (URISyntaxException e) {
-                throw new RuntimeException("Couldn't convert URL to File:" + url, e);
+                if ( resourceFile.isDirectory() )
+                {
+                    FileUtils.copyDirectoryStructure( resourceFile, destination );
+                }
+                else
+                {
+                    FileUtils.copyFile( resourceFile, destination );
+                }
+            }
+            catch ( URISyntaxException e )
+            {
+                throw new RuntimeException( "Couldn't convert URL to File:" + url, e );
             }
         }
         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) + "/"; 
-        ZipEntry ze = z.getEntry(zipStyleResourcePath);
-        if (ze != null) {
+    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 ) + "/";
+        ZipEntry ze = z.getEntry( zipStyleResourcePath );
+        if ( ze != null )
+        {
             // DGF If it's a directory, then we need to look at all the entries
-            for (Enumeration entries = z.entries(); entries.hasMoreElements();) {
+            for ( Enumeration entries = z.entries(); entries.hasMoreElements(); )
+            {
                 ze = (ZipEntry) entries.nextElement();
-                if (ze.getName().startsWith(zipStyleResourcePath)) {
-                    String relativePath = ze.getName().substring(zipStyleResourcePath.length());
-                    File destFile = new File(dest, relativePath);
-                    if (ze.isDirectory()) {
+                if ( ze.getName().startsWith( zipStyleResourcePath ) )
+                {
+                    String relativePath = ze.getName().substring( zipStyleResourcePath.length() );
+                    File destFile = new File( dest, relativePath );
+                    if ( ze.isDirectory() )
+                    {
                         destFile.mkdirs();
-                    } else {
-                        FileOutputStream fos = new FileOutputStream(destFile);
-                        try {
+                    }
+                    else
+                    {
+                        FileOutputStream fos = new FileOutputStream( destFile );
+                        try
+                        {
                             IOUtil.copy( z.getInputStream( ze ), fos );
-                        } finally {
-                            IOUtil.close(fos);
+                        }
+                        finally
+                        {
+                            IOUtil.close( fos );
                         }
                     }
                 }
             }
-        } else {
-            FileOutputStream fos = new FileOutputStream(dest);
-            try {
-                IOUtil.copy(cl.getResourceAsStream(resourcePath), fos);
-            } finally {
-                IOUtil.close(fos);
+        }
+        else
+        {
+            FileOutputStream fos = new FileOutputStream( dest );
+            try
+            {
+                IOUtil.copy( cl.getResourceAsStream( resourcePath ), fos );
+            }
+            finally
+            {
+                IOUtil.close( fos );
             }
         }
-    } 
+    }
 
-    private static File getJarFileFromUrl(URL url) {
-        if (!"jar".equalsIgnoreCase(url.getProtocol()))
-            throw new IllegalArgumentException("This is not a Jar URL:"
-                    + url.toString());
+    private static File getJarFileFromUrl( URL url )
+    {
+        if ( !"jar".equalsIgnoreCase( url.getProtocol() ) )
+        {
+            throw new IllegalArgumentException( "This is not a Jar URL:" + url.toString() );
+        }
         String resourceFilePath = url.getFile();
-        int index = resourceFilePath.indexOf("!");
-        if (index == -1) {
-            throw new RuntimeException("Bug! " + url.toExternalForm()
-                    + " does not have a '!'");
-        }
-        String jarFileURI = resourceFilePath.substring(0, index);
-        try {
-            File jarFile = new File(new URI(jarFileURI));
+        int index = resourceFilePath.indexOf( "!" );
+        if ( index == -1 )
+        {
+            throw new RuntimeException( "Bug! " + url.toExternalForm() + " does not have a '!'" );
+        }
+        String jarFileURI = resourceFilePath.substring( 0, index );
+        try
+        {
+            File jarFile = new File( new URI( jarFileURI ) );
             return jarFile;
-        } catch (URISyntaxException e) {
-            throw new RuntimeException("Bug! URI failed to parse: " + jarFileURI, e);
+        }
+        catch ( URISyntaxException e )
+        {
+            throw new RuntimeException( "Bug! URI failed to parse: " + jarFileURI, e );
         }
 
     }

Modified: maven/shared/trunk/maven-verifier/src/site/site.xml
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/site/site.xml?rev=1416983&r1=1416982&r2=1416983&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/site/site.xml (original)
+++ maven/shared/trunk/maven-verifier/src/site/site.xml Tue Dec  4 15:13:34 2012
@@ -19,7 +19,8 @@ specific language governing permissions 
 under the License.
 -->
 
-<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
+<project xmlns="http://maven.apache.org/DECORATION/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/DECORATION/1.0.0 http://maven.apache.org/xsd/decoration-1.0.0.xsd">
   <body>
     <menu name="Overview">
       <item name="Introduction" href="index.html"/>

Modified: maven/shared/trunk/maven-verifier/src/test/java/org/apache/maven/it/VerifierTest.java
URL: http://svn.apache.org/viewvc/maven/shared/trunk/maven-verifier/src/test/java/org/apache/maven/it/VerifierTest.java?rev=1416983&r1=1416982&r2=1416983&view=diff
==============================================================================
--- maven/shared/trunk/maven-verifier/src/test/java/org/apache/maven/it/VerifierTest.java (original)
+++ maven/shared/trunk/maven-verifier/src/test/java/org/apache/maven/it/VerifierTest.java Tue Dec  4 15:13:34 2012
@@ -29,15 +29,14 @@ public class VerifierTest
 
     public void testExtractMavenVersion()
     {
-        assertEquals( "2.0.6", Verifier.extractMavenVersion( Arrays.asList( new String[] { "Maven version: 2.0.6" } ) ) );
-        assertEquals( "2.0.10",
-                      Verifier.extractMavenVersion( Arrays.asList( new String[] { "Maven version: 2.0.10",
-                          "Java version: 1.5.0_22",
-                          "OS name: \"windows 7\" version: \"6.1\" arch: \"x86\" Family: \"windows\"" } ) ) );
-        assertEquals( "3.0",
-                      Verifier.extractMavenVersion( Arrays.asList( new String[] {
-                          "Apache Maven 3.0 (r1004208; 2010-10-04 13:50:56+0200)", "Java version: 1.5.0_22",
-                          "OS name: \"windows 7\" version: \"6.1\" arch: \"x86\" Family: \"windows\"" } ) ) );
+        assertEquals( "2.0.6",
+                      Verifier.extractMavenVersion( Arrays.asList( new String[]{ "Maven version: 2.0.6" } ) ) );
+        assertEquals( "2.0.10", Verifier.extractMavenVersion( Arrays.asList(
+            new String[]{ "Maven version: 2.0.10", "Java version: 1.5.0_22",
+                "OS name: \"windows 7\" version: \"6.1\" arch: \"x86\" Family: \"windows\"" } ) ) );
+        assertEquals( "3.0", Verifier.extractMavenVersion( Arrays.asList(
+            new String[]{ "Apache Maven 3.0 (r1004208; 2010-10-04 13:50:56+0200)", "Java version: 1.5.0_22",
+                "OS name: \"windows 7\" version: \"6.1\" arch: \"x86\" Family: \"windows\"" } ) ) );
     }
 
 }