maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r570805 - in /maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder: ConfigurationValidationResult.java DefaultConfigurationValidationResult.java MavenEmbedder.java
Date Wed, 29 Aug 2007 13:26:29 GMT
Author: carlos
Date: Wed Aug 29 06:26:29 2007
New Revision: 570805

URL: http://svn.apache.org/viewvc?rev=570805&view=rev
Log:
Gather more information on settings validation

Modified:
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/ConfigurationValidationResult.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/DefaultConfigurationValidationResult.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/ConfigurationValidationResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/ConfigurationValidationResult.java?rev=570805&r1=570804&r2=570805&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/ConfigurationValidationResult.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/ConfigurationValidationResult.java
Wed Aug 29 06:26:29 2007
@@ -19,26 +19,82 @@
  * under the License.
  */
 
-/** @author Jason van Zyl */
+import org.apache.maven.settings.Settings;
+
+/**
+ * @author Jason van Zyl
+ */
 public interface ConfigurationValidationResult
 {
+    /**
+     * Whether both user and global settings are valid
+     */
     boolean isValid();
 
+    /**
+     * Parsed user settings, or null if there's any parse error, that can be retrieved through
+     * {@link #getUserSettingsException()}
+     */
+    Settings getUserSettings();
+
+    /**
+     * Parsed global settings, or null if there's any parse error, that can be retrieved
through
+     * {@link #getGlobalSettingsException()}
+     */
+    Settings getGlobalSettings();
+
+    /**
+     * Any exception that happened during parsing user settings, or null if there were no
errors.
+     */
+    Throwable getUserSettingsException();
+
+    /**
+     * Any exception that happened during parsing global settings, or null if there were
no errors.
+     */
+    Throwable getGlobalSettingsException();
+
+    /**
+     * @deprecated
+     */
     boolean isUserSettingsFilePresent();
 
+    /**
+     * @deprecated
+     */
     void setUserSettingsFilePresent( boolean userSettingsFilePresent );
 
+    /**
+     * @deprecated
+     */
     boolean isUserSettingsFileParses();
 
+    /**
+     * @deprecated
+     */
     void setUserSettingsFileParses( boolean userSettingsFileParses );
 
+    /**
+     * @deprecated
+     */
     boolean isGlobalSettingsFilePresent();
 
+    /**
+     * @deprecated
+     */
     void setGlobalSettingsFilePresent( boolean globalSettingsFilePresent );
 
+    /**
+     * @deprecated
+     */
     boolean isGlobalSettingsFileParses();
 
+    /**
+     * @deprecated
+     */
     void setGlobalSettingsFileParses( boolean globalSettingsFileParses );
 
+    /**
+     * @deprecated
+     */
     void display();
 }

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/DefaultConfigurationValidationResult.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/DefaultConfigurationValidationResult.java?rev=570805&r1=570804&r2=570805&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/DefaultConfigurationValidationResult.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/DefaultConfigurationValidationResult.java
Wed Aug 29 06:26:29 2007
@@ -19,69 +19,109 @@
  * under the License.
  */
 
-/** @author Jason van Zyl */
+import java.io.FileNotFoundException;
+
+import org.apache.maven.settings.Settings;
+
+/**
+ * @author Jason van Zyl
+ */
 public class DefaultConfigurationValidationResult
     implements ConfigurationValidationResult
 {
-    private boolean userSettingsFilePresent = true;
-
-    private boolean userSettingsFileParses = true;
+    private Throwable userSettingsException;
 
-    private boolean globalSettingsFilePresent = true;
+    private Throwable globalSettingsException;
 
-    private boolean globalSettingsFileParses = true;
+    private Settings userSettings, globalSettings;
 
     public boolean isValid()
     {
-        return userSettingsFilePresent && userSettingsFileParses && globalSettingsFilePresent
&&
-            globalSettingsFileParses;
+        return ( getUserSettings() != null ) && ( getGlobalSettings() != null );
     }
 
-    public boolean isUserSettingsFilePresent()
+    public Throwable getUserSettingsException()
     {
-        return userSettingsFilePresent;
+        return userSettingsException;
     }
 
-    public void setUserSettingsFilePresent( boolean userSettingsFilePresent )
+    public void setUserSettingsException( Throwable e )
     {
-        this.userSettingsFilePresent = userSettingsFilePresent;
+        this.userSettingsException = e;
     }
 
-    public boolean isUserSettingsFileParses()
+    public Throwable getGlobalSettingsException()
     {
-        return userSettingsFileParses;
+        return globalSettingsException;
     }
 
-    public void setUserSettingsFileParses( boolean userSettingsFileParses )
+    public void setGlobalSettingsException( Throwable e )
     {
-        this.userSettingsFileParses = userSettingsFileParses;
+        this.globalSettingsException = e;
     }
 
-    public boolean isGlobalSettingsFilePresent()
+    public Settings getUserSettings()
     {
-        return globalSettingsFilePresent;
+        return userSettings;
     }
 
-    public void setGlobalSettingsFilePresent( boolean globalSettingsFilePresent )
+    public void setUserSettings( Settings settings )
+    {
+        this.userSettings = settings;
+    }
+
+    public Settings getGlobalSettings()
+    {
+        return globalSettings;
+    }
+
+    public void setGlobalSettings( Settings globalSettings )
     {
-        this.globalSettingsFilePresent = globalSettingsFilePresent;
+        this.globalSettings = globalSettings;
     }
 
     public boolean isGlobalSettingsFileParses()
     {
-        return globalSettingsFileParses;
+        return getGlobalSettings() != null;
+    }
+
+    public boolean isGlobalSettingsFilePresent()
+    {
+        return getGlobalSettingsException() instanceof FileNotFoundException;
+    }
+
+    public boolean isUserSettingsFileParses()
+    {
+        return getUserSettings() != null;
+    }
+
+    public boolean isUserSettingsFilePresent()
+    {
+        return getUserSettingsException() instanceof FileNotFoundException;
     }
 
     public void setGlobalSettingsFileParses( boolean globalSettingsFileParses )
     {
-        this.globalSettingsFileParses = globalSettingsFileParses;
+        // ignored
+    }
+
+    public void setGlobalSettingsFilePresent( boolean globalSettingsFilePresent )
+    {
+        // ignored
+    }
+
+    public void setUserSettingsFileParses( boolean userSettingsFileParses )
+    {
+        // ignored
+    }
+
+    public void setUserSettingsFilePresent( boolean userSettingsFilePresent )
+    {
+        // ignored
     }
 
     public void display()
     {
-        System.out.println( "userSettingsFilePresent = " + userSettingsFilePresent );
-        System.out.println( "globalSettingsFileParses = " + globalSettingsFileParses );
-        System.out.println( "globalSettingsFilePresent = " + globalSettingsFilePresent );
-        System.out.println( "globalSettingsFileParses = " + globalSettingsFileParses );
+        // ignored
     }
 }

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java?rev=570805&r1=570804&r2=570805&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
Wed Aug 29 06:26:29 2007
@@ -87,7 +87,6 @@
 import org.jdom.output.Format;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.FileReader;
 import java.io.FileWriter;
 import java.io.IOException;
@@ -729,9 +728,9 @@
 
     public static ConfigurationValidationResult validateConfiguration( Configuration configuration
)
     {
-        ConfigurationValidationResult result = new DefaultConfigurationValidationResult();
+        DefaultConfigurationValidationResult result = new DefaultConfigurationValidationResult();
 
-        Reader fileReader;
+        Reader fileReader = null;
 
         // User settings
 
@@ -741,19 +740,26 @@
             {
                 fileReader = new FileReader( configuration.getUserSettingsFile() );
 
-                new SettingsXpp3Reader().read( fileReader );
-            }
-            catch ( FileNotFoundException e )
-            {
-                result.setUserSettingsFilePresent( false );
+                result.setUserSettings( new SettingsXpp3Reader().read( fileReader ) );
             }
             catch ( IOException e )
             {
-                result.setUserSettingsFileParses( false );
+                result.setUserSettingsException( e );
             }
             catch ( XmlPullParserException e )
             {
-                result.setUserSettingsFileParses( false );
+                result.setUserSettingsException( e );
+            }
+            finally
+            {
+                try
+                {
+                    fileReader.close();
+                }
+                catch ( IOException e )
+                {
+                    // nothing to do
+                }
             }
         }
 
@@ -765,19 +771,26 @@
             {
                 fileReader = new FileReader( configuration.getGlobalSettingsFile() );
 
-                new SettingsXpp3Reader().read( fileReader );
-            }
-            catch ( FileNotFoundException e )
-            {
-                result.setGlobalSettingsFilePresent( false );
+                result.setGlobalSettings( new SettingsXpp3Reader().read( fileReader ) );
             }
             catch ( IOException e )
             {
-                result.setGlobalSettingsFileParses( false );
+                result.setGlobalSettingsException( e );
             }
             catch ( XmlPullParserException e )
             {
-                result.setGlobalSettingsFileParses( false );
+                result.setGlobalSettingsException( e );
+            }
+            finally
+            {
+                try
+                {
+                    fileReader.close();
+                }
+                catch ( IOException e )
+                {
+                    // nothing to do
+                }
             }
         }
 



Mime
View raw message