o interpolate System properties into the maven.properties values

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@162917 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2004-08-09 18:40:50 +00:00
parent 15a7eb7ef2
commit ea1009973e
1 changed files with 35 additions and 3 deletions

View File

@ -8,6 +8,8 @@ import java.io.FileInputStream;
import java.io.IOException;
import java.net.URL;
import java.util.Properties;
import java.util.Iterator;
import java.util.Map;
/**
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
@ -28,21 +30,51 @@ public class Verifier
//
// ----------------------------------------------------------------------
public static String interpolate( String text, Map namespace )
{
Iterator keys = namespace.keySet().iterator();
while ( keys.hasNext() )
{
String key = keys.next().toString();
Object obj = namespace.get( key );
String value = obj.toString();
text = replace( text, "${" + key + "}", value );
if ( key.indexOf( " " ) == -1 )
{
text = replace( text, "$" + key, value );
}
}
return text;
}
public void verify()
throws VerificationException
{
Properties mavenProperties = new Properties();
Properties properties = new Properties();
try
{
mavenProperties.load( new FileInputStream( new File( System.getProperty( "user.home" ), "maven.properties" ) ) );
properties.load( new FileInputStream( new File( System.getProperty( "user.home" ), "maven.properties" ) ) );
for ( Iterator i = properties.keySet().iterator(); i.hasNext(); )
{
String key = (String) i.next();
properties.setProperty( key, interpolate( properties.getProperty( key ), System.getProperties() ) );
}
}
catch ( IOException e )
{
throw new VerificationException( "Can't find the maven.properties file! Verification can't proceed!" );
}
mavenRepoLocal = mavenProperties.getProperty( "maven.repo.local" );
mavenRepoLocal = properties.getProperty( "maven.repo.local" );
try
{