diff --git a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java index 03a0b0a146..4697f306e9 100644 --- a/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java +++ b/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java @@ -755,7 +755,6 @@ public class MavenEmbedder if ( configuration.getGlobalSettingsFile() != null ) { - try { fileReader = new FileReader( configuration.getGlobalSettingsFile() ); diff --git a/maven-embedder/src/test/java/org/apache/maven/embedder/configuration/ValidateConfigurationTest.java b/maven-embedder/src/test/java/org/apache/maven/embedder/configuration/ValidateConfigurationTest.java index 57d51b9ac5..2a17271223 100644 --- a/maven-embedder/src/test/java/org/apache/maven/embedder/configuration/ValidateConfigurationTest.java +++ b/maven-embedder/src/test/java/org/apache/maven/embedder/configuration/ValidateConfigurationTest.java @@ -18,11 +18,25 @@ public class ValidateConfigurationTest ConfigurationValidationResult result = MavenEmbedder.validateConfiguration( configuration ); - assertTrue( result.isUserSettingsFileParses() ); + assertTrue( result.isUserSettingsFilePresent() ); assertTrue( result.isUserSettingsFileParses() ); } + public void testConfigurationOnlyUserSettingsAreActiveAndItIsInvalid() + { + File user = new File( getBasedir(), "src/test/resources/settings/invalid-settings.xml" ); + + Configuration configuration = new DefaultConfiguration() + .setUserSettingsFile( user ); + + ConfigurationValidationResult result = MavenEmbedder.validateConfiguration( configuration ); + + assertTrue( result.isUserSettingsFilePresent() ); + + assertFalse( result.isUserSettingsFileParses() ); + } + public void testConfigurationOnlyGlobalSettingsAreActiveAndItIsValid() { File global = new File( getBasedir(), "src/test/resources/settings/valid-settings.xml" ); @@ -36,4 +50,18 @@ public class ValidateConfigurationTest assertTrue( result.isGlobalSettingsFileParses() ); } + + public void testConfigurationOnlyGlobalSettingsAreActiveAndItIsInvalid() + { + File global = new File( getBasedir(), "src/test/resources/settings/invalid-settings.xml" ); + + Configuration configuration = new DefaultConfiguration() + .setGlobalSettingsFile( global ); + + ConfigurationValidationResult result = MavenEmbedder.validateConfiguration( configuration ); + + assertTrue( result.isGlobalSettingsFilePresent() ); + + assertFalse( result.isGlobalSettingsFileParses() ); + } } diff --git a/maven-embedder/src/test/resources/settings/invalid-settings.xml b/maven-embedder/src/test/resources/settings/invalid-settings.xml new file mode 100644 index 0000000000..d0a5eac3db --- /dev/null +++ b/maven-embedder/src/test/resources/settings/invalid-settings.xml @@ -0,0 +1,5 @@ + + + + /Users/jvanzyl/maven-repo-local