From a13a336cea5652866c70ba25648266b2b8e91025 Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 11 Oct 2009 22:39:55 +0000 Subject: [PATCH] [MNG-4390] Make parsing of settings.xml lenient with respect to unrecognized tags git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@824188 13f79535-47bb-0310-9956-ffa450edef68 --- .../building/DefaultSettingsBuilder.java | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java b/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java index f23aacd115..a4498766b1 100644 --- a/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java +++ b/maven-core/src/main/java/org/apache/maven/settings/building/DefaultSettingsBuilder.java @@ -121,22 +121,33 @@ public class DefaultSettingsBuilder try { - boolean strict = true; + Map options = Collections.singletonMap( SettingsReader.IS_STRICT, Boolean.TRUE ); - Map options = Collections.singletonMap( SettingsReader.IS_STRICT, Boolean.valueOf( strict ) ); + try + { + settings = settingsReader.read( settingsFile, options ); + } + catch ( SettingsParseException e ) + { + options = Collections.singletonMap( SettingsReader.IS_STRICT, Boolean.FALSE ); - settings = settingsReader.read( settingsFile, options ); + settings = settingsReader.read( settingsFile, options ); + + problems.add( new DefaultSettingsProblem( e.getMessage(), SettingsProblem.Severity.WARNING, + settingsFile.getAbsolutePath(), e.getLineNumber(), + e.getColumnNumber(), e ) ); + } } catch ( SettingsParseException e ) { - problems.add( new DefaultSettingsProblem( "Non-parseable settings " + settingsFile, + problems.add( new DefaultSettingsProblem( "Non-parseable settings " + settingsFile + ": " + e.getMessage(), SettingsProblem.Severity.FATAL, settingsFile.getAbsolutePath(), e.getLineNumber(), e.getColumnNumber(), e ) ); return new Settings(); } catch ( IOException e ) { - problems.add( new DefaultSettingsProblem( "Non-readable settings " + settingsFile, + problems.add( new DefaultSettingsProblem( "Non-readable settings " + settingsFile + ": " + e.getMessage(), SettingsProblem.Severity.FATAL, settingsFile.getAbsolutePath(), -1, -1, e ) ); return new Settings();