MNG-2935: make sure build tanks if the settings are bad (user and global)

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@572180 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jason van Zyl 2007-09-02 22:48:43 +00:00
parent 248c7199a0
commit 4005482797
5 changed files with 32 additions and 8 deletions

View File

@ -26,6 +26,7 @@ import org.apache.maven.embedder.Configuration;
import org.apache.maven.embedder.DefaultConfiguration;
import org.apache.maven.embedder.MavenEmbedder;
import org.apache.maven.embedder.MavenEmbedderException;
import org.apache.maven.embedder.ConfigurationValidationResult;
import org.apache.maven.execution.DefaultMavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionRequest;
import org.apache.maven.execution.MavenExecutionResult;
@ -343,6 +344,22 @@ public class MavenCli
.setGlobalSettingsFile( MavenEmbedder.DEFAULT_GLOBAL_SETTINGS_FILE )
.setClassWorld( classWorld );
ConfigurationValidationResult cvr = MavenEmbedder.validateConfiguration( configuration );
if ( cvr.isUserSettingsFilePresent() && !cvr.isUserSettingsFileParses() )
{
showFatalError( "Error reading user settings: " + cvr.getUserSettingsException().getMessage(), cvr.getUserSettingsException(), showErrors );
return 1;
}
if ( cvr.isGlobalSettingsFilePresent() && !cvr.isGlobalSettingsFileParses() )
{
showFatalError( "Error reading global settings: " + cvr.getGlobalSettingsException().getMessage(), cvr.getGlobalSettingsException(), showErrors );
return 1;
}
String localRepoProperty = executionProperties.getProperty( LOCAL_REPO_PROPERTY );
if ( localRepoProperty != null )

View File

@ -47,12 +47,12 @@ public interface ConfigurationValidationResult
/**
* Any exception that happened during parsing user settings, or null if there were no errors.
*/
Throwable getUserSettingsException();
Exception getUserSettingsException();
/**
* Any exception that happened during parsing global settings, or null if there were no errors.
*/
Throwable getGlobalSettingsException();
Exception getGlobalSettingsException();
/**
* @deprecated

View File

@ -29,9 +29,9 @@ import org.apache.maven.settings.Settings;
public class DefaultConfigurationValidationResult
implements ConfigurationValidationResult
{
private Throwable userSettingsException;
private Exception userSettingsException;
private Throwable globalSettingsException;
private Exception globalSettingsException;
private Settings userSettings, globalSettings;
@ -40,22 +40,22 @@ public class DefaultConfigurationValidationResult
return ( getUserSettingsException() == null ) && ( getGlobalSettingsException() == null );
}
public Throwable getUserSettingsException()
public Exception getUserSettingsException()
{
return userSettingsException;
}
public void setUserSettingsException( Throwable e )
public void setUserSettingsException( Exception e )
{
this.userSettingsException = e;
}
public Throwable getGlobalSettingsException()
public Exception getGlobalSettingsException()
{
return globalSettingsException;
}
public void setGlobalSettingsException( Throwable e )
public void setGlobalSettingsException( Exception e )
{
this.globalSettingsException = e;
}

View File

@ -346,6 +346,7 @@ public class MavenEmbedderTest
assertEquals( 3, result.getProject().getTestClasspathElements().size() );
}
/*
public void testProjectReadingWithDistributionStatus()
throws Exception
{
@ -365,6 +366,7 @@ public class MavenEmbedderTest
assertEquals( "deployed", result.getProject().getDistributionManagement().getStatus() );
}
*/
// ----------------------------------------------------------------------------
// Model Writing

View File

@ -464,6 +464,10 @@ public class DefaultMavenProjectBuilder
profileManager,
STRICT_MODEL_PARSING );
/*
MNG-3178: What is this actually for as we're not deploying this anymore.
if ( checkDistributionManagementStatus )
{
if ( ( project.getDistributionManagement() != null ) && ( project.getDistributionManagement().getStatus() != null ) )
@ -474,6 +478,7 @@ public class DefaultMavenProjectBuilder
"Invalid project file: distribution status must not be specified for a project outside of the repository" );
}
}
*/
return project;
}