mirror of https://github.com/apache/maven.git
o simplifying settings handling and pushing responsibility to the client code
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@512551 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
17a0c66920
commit
31366ad057
|
@ -41,7 +41,6 @@ public class DefaultMavenSettingsBuilder
|
||||||
extends AbstractLogEnabled
|
extends AbstractLogEnabled
|
||||||
implements MavenSettingsBuilder
|
implements MavenSettingsBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
private SettingsValidator validator;
|
private SettingsValidator validator;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,25 +49,6 @@ public class DefaultMavenSettingsBuilder
|
||||||
public Settings buildSettings( File userSettingsFile, File globalSettingsFile )
|
public Settings buildSettings( File userSettingsFile, File globalSettingsFile )
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
return buildSettings( userSettingsFile, globalSettingsFile, new SettingsBuilderAdvice() );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 2.1
|
|
||||||
*/
|
|
||||||
public Settings buildSettings( File userSettingsFile, File globalSettingsFile, SettingsBuilderAdvice advice )
|
|
||||||
throws IOException, XmlPullParserException
|
|
||||||
{
|
|
||||||
if ( advice.isDefaultUserLocationEnabled() && userSettingsFile == null )
|
|
||||||
{
|
|
||||||
userSettingsFile = DEFAULT_USER_SETTINGS_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( advice.isDefaultGlobalLocationEnabled() && globalSettingsFile == null )
|
|
||||||
{
|
|
||||||
globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( globalSettingsFile == null && userSettingsFile == null )
|
if ( globalSettingsFile == null && userSettingsFile == null )
|
||||||
{
|
{
|
||||||
getLogger().debug(
|
getLogger().debug(
|
||||||
|
@ -105,24 +85,6 @@ public class DefaultMavenSettingsBuilder
|
||||||
return userSettings;
|
return userSettings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public Settings buildSettings()
|
|
||||||
throws IOException, XmlPullParserException
|
|
||||||
{
|
|
||||||
return buildSettings( DEFAULT_USER_SETTINGS_FILE );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
public Settings buildSettings( File userSettingsFile )
|
|
||||||
throws IOException, XmlPullParserException
|
|
||||||
{
|
|
||||||
return buildSettings( userSettingsFile, null );
|
|
||||||
}
|
|
||||||
|
|
||||||
private Settings readSettings( File settingsFile )
|
private Settings readSettings( File settingsFile )
|
||||||
throws IOException, XmlPullParserException
|
throws IOException, XmlPullParserException
|
||||||
{
|
{
|
||||||
|
@ -142,6 +104,7 @@ public class DefaultMavenSettingsBuilder
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
reader = new FileReader( settingsFile );
|
reader = new FileReader( settingsFile );
|
||||||
|
|
||||||
StringWriter sWriter = new StringWriter();
|
StringWriter sWriter = new StringWriter();
|
||||||
|
|
||||||
IOUtil.copy( reader, sWriter );
|
IOUtil.copy( reader, sWriter );
|
||||||
|
@ -151,6 +114,7 @@ public class DefaultMavenSettingsBuilder
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
|
RegexBasedInterpolator interpolator = new RegexBasedInterpolator();
|
||||||
|
|
||||||
interpolator.addValueSource( new EnvarBasedValueSource() );
|
interpolator.addValueSource( new EnvarBasedValueSource() );
|
||||||
|
|
||||||
rawInput = interpolator.interpolate( rawInput, "settings" );
|
rawInput = interpolator.interpolate( rawInput, "settings" );
|
||||||
|
@ -220,6 +184,5 @@ public class DefaultMavenSettingsBuilder
|
||||||
{
|
{
|
||||||
throw new IOException( "Failed to validate Settings file at " + location + "\n" + validationResult.render( "\n" ) );
|
throw new IOException( "Failed to validate Settings file at " + location + "\n" + validationResult.render( "\n" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,33 +29,9 @@ public interface MavenSettingsBuilder
|
||||||
{
|
{
|
||||||
String ROLE = MavenSettingsBuilder.class.getName();
|
String ROLE = MavenSettingsBuilder.class.getName();
|
||||||
|
|
||||||
File DEFAULT_USER_SETTINGS_FILE = new File( System.getProperty( "user.home" ), ".m2/settings.xml" );
|
|
||||||
|
|
||||||
File DEFAULT_GLOBAL_SETTINGS_FILE = new File( System
|
|
||||||
.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/settings.xml" );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
Settings buildSettings()
|
|
||||||
throws IOException, XmlPullParserException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated
|
|
||||||
*/
|
|
||||||
Settings buildSettings( File userSettingsFile )
|
|
||||||
throws IOException, XmlPullParserException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 2.1
|
* @since 2.1
|
||||||
*/
|
*/
|
||||||
Settings buildSettings( File userSettingsFile, File globalSettingsFile )
|
Settings buildSettings( File userSettingsFile, File globalSettingsFile )
|
||||||
throws IOException, XmlPullParserException;
|
throws IOException, XmlPullParserException;
|
||||||
|
|
||||||
/**
|
|
||||||
* @since 2.1
|
|
||||||
*/
|
|
||||||
Settings buildSettings( File userSettingsPath, File globalSettingsPath, SettingsBuilderAdvice advice )
|
|
||||||
throws IOException, XmlPullParserException;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +0,0 @@
|
||||||
package org.apache.maven.settings;
|
|
||||||
|
|
||||||
public class SettingsBuilderAdvice
|
|
||||||
{
|
|
||||||
|
|
||||||
private boolean defaultUserLocationEnabled = true;
|
|
||||||
|
|
||||||
private boolean defaultGlobalLocationEnabled = true;
|
|
||||||
|
|
||||||
public boolean isDefaultGlobalLocationEnabled()
|
|
||||||
{
|
|
||||||
return defaultGlobalLocationEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isDefaultUserLocationEnabled()
|
|
||||||
{
|
|
||||||
return defaultUserLocationEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultGlobalLocationEnabled( boolean defaultGlobalLocationEnabled )
|
|
||||||
{
|
|
||||||
this.defaultGlobalLocationEnabled = defaultGlobalLocationEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultUserLocationEnabled( boolean defaultUserLocationEnabled )
|
|
||||||
{
|
|
||||||
this.defaultUserLocationEnabled = defaultUserLocationEnabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in New Issue