You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2020/03/15 19:16:00 UTC

[maven-verifier] branch MSHARED-855 created (now 11cc77e)

This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a change to branch MSHARED-855
in repository https://gitbox.apache.org/repos/asf/maven-verifier.git.


      at 11cc77e  [MSHARED-855] Support calling maven wrapper

This branch includes the following new commits:

     new 11cc77e  [MSHARED-855] Support calling maven wrapper

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



[maven-verifier] 01/01: [MSHARED-855] Support calling maven wrapper

Posted by rf...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

rfscholte pushed a commit to branch MSHARED-855
in repository https://gitbox.apache.org/repos/asf/maven-verifier.git

commit 11cc77e170f5cd2588891dd32472a52433209d1a
Author: rfscholte <rf...@apache.org>
AuthorDate: Sun Mar 15 20:15:42 2020 +0100

    [MSHARED-855] Support calling maven wrapper
---
 .../java/org/apache/maven/it/ForkedLauncher.java   | 11 ++++++++-
 .../org/apache/maven/it/VerificationException.java |  1 -
 src/main/java/org/apache/maven/it/Verifier.java    | 26 +++++++++++++++++-----
 .../apache/maven/it/util/ResourceExtractor.java    |  2 +-
 4 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/src/main/java/org/apache/maven/it/ForkedLauncher.java b/src/main/java/org/apache/maven/it/ForkedLauncher.java
index 106fcbf..4cc2b47 100644
--- a/src/main/java/org/apache/maven/it/ForkedLauncher.java
+++ b/src/main/java/org/apache/maven/it/ForkedLauncher.java
@@ -59,12 +59,21 @@ class ForkedLauncher
 
     ForkedLauncher( String mavenHome, Map<String, String> envVars, boolean debugJvm )
     {
+        this( mavenHome, envVars, debugJvm, false );
+    }
+
+    ForkedLauncher( String mavenHome, Map<String, String> envVars, boolean debugJvm, boolean wrapper )
+    {
         this.mavenHome = mavenHome;
         this.envVars = envVars;
 
         String script = debugJvm ? "mvnDebug" : "mvn";
 
-        if ( mavenHome != null )
+        if ( wrapper )
+        {
+            executable = new File( "mvnw" ).getPath();
+        }
+        else if ( mavenHome != null )
         {
             executable = new File( mavenHome, "bin/" + script ).getPath();
         }
diff --git a/src/main/java/org/apache/maven/it/VerificationException.java b/src/main/java/org/apache/maven/it/VerificationException.java
index e014488..6033f13 100644
--- a/src/main/java/org/apache/maven/it/VerificationException.java
+++ b/src/main/java/org/apache/maven/it/VerificationException.java
@@ -21,7 +21,6 @@ package org.apache.maven.it;
 
 /**
  * @author Jason van Zyl
- * @version $Id$
  */
 public class VerificationException
     extends Exception
diff --git a/src/main/java/org/apache/maven/it/Verifier.java b/src/main/java/org/apache/maven/it/Verifier.java
index 8ddb514..1474e74 100644
--- a/src/main/java/org/apache/maven/it/Verifier.java
+++ b/src/main/java/org/apache/maven/it/Verifier.java
@@ -34,6 +34,8 @@ import java.io.PrintStream;
 import java.io.Writer;
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
 import java.text.DecimalFormat;
 import java.text.NumberFormat;
 import java.util.ArrayList;
@@ -66,8 +68,6 @@ import org.xml.sax.helpers.DefaultHandler;
 /**
  * @author Jason van Zyl
  * @author <a href="mailto:brett@apache.org">Brett Porter</a>
- * @version $Id$
- * @noinspection UseOfSystemOutOrSystemErr, RefusedBequest, UnusedDeclaration
  */
 public class Verifier
 {
@@ -302,7 +302,7 @@ public class Verifier
      * Throws an exception if the text is not present in the log.
      *
      * @param text the text to assert present
-     * @throws VerificationException
+     * @throws VerificationException if text is not found in log
      */
     public void verifyTextInLog( String text )
         throws VerificationException
@@ -959,8 +959,18 @@ public class Verifier
      * There are 226 references to this method in Maven core ITs. In most (all?) cases it is used together with
      * {@link #newDefaultFilterProperties()}. Need to remove both methods and update all clients eventually/
      * 
+     * @param srcPath          The path to the input file, relative to the base directory, must not be
+     *                         <code>null</code>.
+     * @param dstPath          The path to the output file, relative to the base directory and possibly equal to the
+     *                         input file, must not be <code>null</code>.
+     * @param fileEncoding     The file encoding to use, may be <code>null</code> or empty to use the platform's default
+     *                         encoding.
+     * @param filterProperties The mapping from tokens to replacement values, must not be <code>null</code>.
+     * @return The path to the filtered output file, never <code>null</code>.
+     * @throws IOException If the file could not be filtered.
      * @deprecated use {@link #filterFile(String, String, String, Map)}
      */
+    @Deprecated
     @SuppressWarnings( { "rawtypes", "unchecked" } )
     public File filterFile( String srcPath, String dstPath, String fileEncoding, Properties filterProperties )
         throws IOException
@@ -1351,8 +1361,14 @@ public class Verifier
     private MavenLauncher getMavenLauncher( Map<String, String> envVars )
         throws LauncherException
     {
+        boolean useWrapper = Files.exists( Paths.get( getBasedir(), "mvnw" ) );
+        
         boolean fork;
-        if ( forkJvm != null )
+        if ( useWrapper )
+        {
+            fork = true;
+        }
+        else if ( forkJvm != null )
         {
             fork = forkJvm;
         }
@@ -1388,7 +1404,7 @@ public class Verifier
         }
         else
         {
-            return new ForkedLauncher( defaultMavenHome, envVars, debugJvm );
+            return new ForkedLauncher( defaultMavenHome, envVars, debugJvm, useWrapper );
         }
     }
 
diff --git a/src/main/java/org/apache/maven/it/util/ResourceExtractor.java b/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
index d2913b7..9df3c30 100644
--- a/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
+++ b/src/main/java/org/apache/maven/it/util/ResourceExtractor.java
@@ -33,7 +33,7 @@ import org.apache.maven.shared.utils.io.IOUtil;
 
 
 /**
- *  @todo this can be replaced with plexus-archiver
+ *  TODO this can be replaced with plexus-archiver
  */
 public class ResourceExtractor
 {