[MSHARED-855] Support calling maven wrapper
diff --git a/src/main/java/org/apache/maven/it/ForkedLauncher.java b/src/main/java/org/apache/maven/it/ForkedLauncher.java
index 106fcbf..3607be1 100644
--- a/src/main/java/org/apache/maven/it/ForkedLauncher.java
+++ b/src/main/java/org/apache/maven/it/ForkedLauncher.java
@@ -59,18 +59,31 @@
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( mavenHome, "bin/" + script ).getPath();
+ String script = "mvnw" + ( debugJvm ? "Debug" : "" );
+ executable = new File( script ).getPath();
}
else
{
- executable = script;
+ String script = "mvn" + ( debugJvm ? "Debug" : "" );
+
+ if ( mavenHome != null )
+ {
+ executable = new File( mavenHome, "bin/" + script ).getPath();
+ }
+ else
+ {
+ executable = script;
+ }
}
}
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 @@
/**
* @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.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 @@
/**
* @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 @@
* 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 @@
* 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 @@
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 @@
}
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 @@
/**
- * @todo this can be replaced with plexus-archiver
+ * TODO this can be replaced with plexus-archiver
*/
public class ResourceExtractor
{