You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2005/10/08 07:34:48 UTC

svn commit: r307263 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java maven-core/src/main/java/org/apache/maven/cli/MavenCli.java maven-settings/pom.xml

Author: brett
Date: Fri Oct  7 22:34:40 2005
New Revision: 307263

URL: http://svn.apache.org/viewcvs?rev=307263&view=rev
Log:
PR: MNG-838
improve error reporting for bad settings

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
    maven/components/trunk/maven-settings/pom.xml

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java?rev=307263&r1=307262&r2=307263&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/SettingsConfigurationException.java Fri Oct  7 22:34:40 2005
@@ -25,8 +25,25 @@
 public class SettingsConfigurationException
     extends Exception
 {
+    private int lineNumber;
+
+    private int columnNumber;
+
     public SettingsConfigurationException( String message )
     {
         super( message );
+    }
+
+    public SettingsConfigurationException( String message, Throwable cause )
+    {
+        super( message, cause );
+    }
+
+    public SettingsConfigurationException( String message, Throwable cause, int lineNumber, int columnNumber )
+    {
+        super( message + ( lineNumber > 0 ? "\n  Line:   " + lineNumber : "" ) +
+            ( columnNumber > 0 ? "\n  Column: " + columnNumber : "" ), cause );
+        this.lineNumber = lineNumber;
+        this.columnNumber = columnNumber;
     }
 }

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=307263&r1=307262&r2=307263&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java Fri Oct  7 22:34:40 2005
@@ -52,6 +52,7 @@
 import org.codehaus.plexus.embed.Embedder;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.logging.LoggerManager;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import java.io.File;
 import java.io.IOException;
@@ -159,7 +160,13 @@
         {
             settings = buildSettings( commandLine );
         }
-        catch ( Exception e )
+        catch ( SettingsConfigurationException e )
+        {
+            showError( "Error reading settings.xml: " + e.getMessage(), e, showErrors );
+
+            return 1;
+        }
+        catch ( ComponentLookupException e )
         {
             showFatalError( "Unable to read settings.xml", e, showErrors );
 
@@ -265,7 +272,7 @@
     }
 
     private static Settings buildSettings( CommandLine commandLine )
-        throws Exception
+        throws ComponentLookupException, SettingsConfigurationException
     {
         String userSettingsPath = null;
 
@@ -278,24 +285,36 @@
 
         MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) embedder.lookup( MavenSettingsBuilder.ROLE );
 
-        if ( userSettingsPath != null )
+        try
         {
-            File userSettingsFile = new File( userSettingsPath );
-
-            if ( userSettingsFile.exists() && !userSettingsFile.isDirectory() )
+            if ( userSettingsPath != null )
             {
-                settings = settingsBuilder.buildSettings( userSettingsFile );
+                File userSettingsFile = new File( userSettingsPath );
+
+                if ( userSettingsFile.exists() && !userSettingsFile.isDirectory() )
+                {
+                    settings = settingsBuilder.buildSettings( userSettingsFile );
+                }
+                else
+                {
+                    System.out.println( "WARNING: Alternate user settings file: " + userSettingsPath +
+                        " is invalid. Using default path." );
+                }
             }
-            else
+
+            if ( settings == null )
             {
-                System.out.println(
-                    "WARNING: Alternate user settings file: " + userSettingsPath + " is invalid. Using default path." );
+                settings = settingsBuilder.buildSettings();
             }
         }
-
-        if ( settings == null )
+        catch ( IOException e )
+        {
+            throw new SettingsConfigurationException( "Error reading settings file", e );
+        }
+        catch ( XmlPullParserException e )
         {
-            settings = settingsBuilder.buildSettings();
+            throw new SettingsConfigurationException( e.getMessage(), e.getDetail(), e.getLineNumber(),
+                                                      e.getColumnNumber() );
         }
 
         // why aren't these part of the runtime info? jvz.

Modified: maven/components/trunk/maven-settings/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/trunk/maven-settings/pom.xml?rev=307263&r1=307262&r2=307263&view=diff
==============================================================================
--- maven/components/trunk/maven-settings/pom.xml (original)
+++ maven/components/trunk/maven-settings/pom.xml Fri Oct  7 22:34:40 2005
@@ -13,7 +13,7 @@
       <plugin>
         <groupId>org.codehaus.modello</groupId>
         <artifactId>modello-maven-plugin</artifactId>
-        <version>1.0-alpha-3</version>
+        <version>1.0-alpha-6-SNAPSHOT</version>
         <executions>
           <execution>
             <goals>
@@ -27,9 +27,6 @@
             </configuration>
           </execution>
         </executions>
-        <configuration>
-          <packageWithVersion>false</packageWithVersion>
-        </configuration>
       </plugin>
     </plugins>
   </build>
@@ -48,4 +45,4 @@
       <artifactId>plexus-container-default</artifactId>
     </dependency>
   </dependencies>
-</project>
\ No newline at end of file
+</project>