mirror of https://github.com/apache/maven.git
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:
parent
15a7eb7ef2
commit
ea1009973e
|
@ -8,6 +8,8 @@ import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author <a href="mailto:jason@maven.org">Jason van Zyl</a>
|
* @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()
|
public void verify()
|
||||||
throws VerificationException
|
throws VerificationException
|
||||||
{
|
{
|
||||||
Properties mavenProperties = new Properties();
|
Properties properties = new Properties();
|
||||||
|
|
||||||
try
|
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 )
|
catch ( IOException e )
|
||||||
{
|
{
|
||||||
throw new VerificationException( "Can't find the maven.properties file! Verification can't proceed!" );
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue