generics fixes
Chnaged environment variables to be Map<Sring,String>, not properties.
Introduced deprecated #filterFile(String, String, String, Properties).
Both changes were necessary to switch maven core ITs to latest
Verifier.
Signed-off-by: Igor Fedorenko <igor@ifedorenko.com>
git-svn-id: https://svn.apache.org/repos/asf/maven/shared/trunk@1544920 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/main/java/org/apache/maven/it/ForkedLauncher.java b/src/main/java/org/apache/maven/it/ForkedLauncher.java
index 6d149b6..16334f2 100644
--- a/src/main/java/org/apache/maven/it/ForkedLauncher.java
+++ b/src/main/java/org/apache/maven/it/ForkedLauncher.java
@@ -49,14 +49,14 @@
private final String executable;
- private final Map<Object, Object> envVars;
+ private final Map<String, String> envVars;
public ForkedLauncher( String mavenHome )
{
- this( mavenHome, Collections.<Object, Object> emptyMap(), false );
+ this( mavenHome, Collections.<String, String> emptyMap(), false );
}
- public ForkedLauncher( String mavenHome, Map<Object, Object> envVars, boolean debugJvm )
+ public ForkedLauncher( String mavenHome, Map<String, String> envVars, boolean debugJvm )
{
this.mavenHome = mavenHome;
this.envVars = envVars;
@@ -73,7 +73,7 @@
}
}
- public int run( String[] cliArgs, Map<?, ?> envVars, String workingDirectory, File logFile )
+ public int run( String[] cliArgs, Map<String, String> envVars, String workingDirectory, File logFile )
throws IOException, LauncherException
{
Commandline cmd = new Commandline();
@@ -87,11 +87,9 @@
if ( envVars != null )
{
- for ( Object o : envVars.keySet() )
+ for ( Map.Entry<String, String> envVar : envVars.entrySet() )
{
- String key = (String) o;
-
- cmd.addEnvironment( key, (String) envVars.get( key ) );
+ cmd.addEnvironment( envVar.getKey(), envVar.getValue() );
}
}
@@ -149,7 +147,7 @@
}
// disable EMMA runtime controller port allocation, should be harmless if EMMA is not used
- Map<?, ?> envVars = Collections.singletonMap( "MAVEN_OPTS", "-Demma.rt.control=false" );
+ Map<String, String> envVars = Collections.singletonMap( "MAVEN_OPTS", "-Demma.rt.control=false" );
run( new String[] { "--version" }, envVars, null, logFile );
List<String> logLines = FileUtils.loadFile( logFile );
diff --git a/src/main/java/org/apache/maven/it/Verifier.java b/src/main/java/org/apache/maven/it/Verifier.java
index d4adc75..e49876d 100644
--- a/src/main/java/org/apache/maven/it/Verifier.java
+++ b/src/main/java/org/apache/maven/it/Verifier.java
@@ -39,6 +39,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
@@ -90,7 +91,7 @@
private Properties systemProperties = new Properties();
- private Properties environmentVariables = new Properties();
+ private Map<String, String> environmentVariables = new HashMap<String, String>();
private Properties verifierProperties = new Properties();
@@ -960,6 +961,19 @@
}
/**
+ * 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/
+ *
+ * @deprecated use {@link #filterFile(String, String, String, Map)}
+ */
+ @SuppressWarnings( { "rawtypes", "unchecked" } )
+ public File filterFile( String srcPath, String dstPath, String fileEncoding, Properties filterProperties )
+ throws IOException
+ {
+ return filterFile( srcPath, dstPath, fileEncoding, (Map) filterProperties );
+ }
+
+ /**
* Gets a new copy of the default filter properties. These default filter properties map the tokens "@basedir@" and
* "@baseurl@" to the test's base directory and its base <code>file:</code> URL, respectively.
*
@@ -1214,7 +1228,7 @@
executeGoal( goal, environmentVariables );
}
- public void executeGoal( String goal, Map<Object, Object> envVars )
+ public void executeGoal( String goal, Map<String, String> envVars )
throws VerificationException
{
executeGoals( Arrays.asList( goal ), envVars );
@@ -1252,7 +1266,7 @@
}
}
- public void executeGoals( List<String> goals, Map<Object, Object> envVars )
+ public void executeGoals( List<String> goals, Map<String, String> envVars )
throws VerificationException
{
List<String> allGoals = new ArrayList<String>();
@@ -1348,7 +1362,7 @@
}
}
- private MavenLauncher getMavenLauncher( Map<Object, Object> envVars )
+ private MavenLauncher getMavenLauncher( Map<String, String> envVars )
throws LauncherException
{
boolean fork;
@@ -1437,7 +1451,7 @@
{
try
{
- return getMavenLauncher( Collections.emptyMap() ).getMavenVersion();
+ return getMavenLauncher( Collections.<String, String> emptyMap() ).getMavenVersion();
}
catch ( LauncherException e )
{
@@ -1905,12 +1919,12 @@
}
}
- public Properties getEnvironmentVariables()
+ public Map<String, String> getEnvironmentVariables()
{
return environmentVariables;
}
- public void setEnvironmentVariables( Properties environmentVariables )
+ public void setEnvironmentVariables( Map<String, String> environmentVariables )
{
this.environmentVariables = environmentVariables;
}
@@ -1919,7 +1933,7 @@
{
if ( value != null )
{
- environmentVariables.setProperty( key, value );
+ environmentVariables.put( key, value );
}
else
{