maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bentm...@apache.org
Subject svn commit: r800418 - in /maven/components/trunk: maven-core/src/main/java/org/apache/maven/project/ maven-model-builder/src/main/java/org/apache/maven/model/building/
Date Mon, 03 Aug 2009 15:13:47 GMT
Author: bentmann
Date: Mon Aug  3 15:13:46 2009
New Revision: 800418

URL: http://svn.apache.org/viewvc?rev=800418&view=rev
Log:
o Refactored model building listener to use problem collector

Modified:
    maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java
    maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java

Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java?rev=800418&r1=800417&r2=800418&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
(original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/project/DefaultModelBuildingListener.java
Mon Aug  3 15:13:46 2009
@@ -21,7 +21,9 @@
 
 import java.util.List;
 
+import org.apache.maven.artifact.InvalidRepositoryException;
 import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.building.AbstractModelBuildingListener;
 import org.apache.maven.model.building.ModelBuildingEvent;
@@ -104,21 +106,41 @@
 
     @Override
     public void buildExtensionsAssembled( ModelBuildingEvent event )
-        throws Exception
     {
         Model model = event.getModel();
 
-        remoteRepositories =
-            projectBuildingHelper.createArtifactRepositories( model.getRepositories(), remoteRepositories
);
+        try
+        {
+            remoteRepositories =
+                projectBuildingHelper.createArtifactRepositories( model.getRepositories(),
remoteRepositories );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            event.getProblems().addError( "Invalid artifact repository: " + e.getMessage(),
e );
+        }
 
-        pluginRepositories =
-            projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(),
pluginRepositories );
+        try
+        {
+            pluginRepositories =
+                projectBuildingHelper.createArtifactRepositories( model.getPluginRepositories(),
pluginRepositories );
+        }
+        catch ( InvalidRepositoryException e )
+        {
+            event.getProblems().addError( "Invalid plugin repository: " + e.getMessage(),
e );
+        }
 
         if ( event.getRequest().isProcessPlugins() )
         {
-            projectRealm =
-                projectBuildingHelper.createProjectRealm( model, projectBuildingRequest.getLocalRepository(),
-                                                          pluginRepositories );
+            try
+            {
+                projectRealm =
+                    projectBuildingHelper.createProjectRealm( model, projectBuildingRequest.getLocalRepository(),
+                                                              pluginRepositories );
+            }
+            catch ( ArtifactResolutionException e )
+            {
+                event.getProblems().addError( "Unresolveable build extensions: " + e.getMessage(),
e );
+            }
 
             if ( projectRealm != null )
             {

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java?rev=800418&r1=800417&r2=800418&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/AbstractModelBuildingListener.java
Mon Aug  3 15:13:46 2009
@@ -29,7 +29,6 @@
 {
 
     public void buildExtensionsAssembled( ModelBuildingEvent event )
-        throws Exception
     {
         // default does nothing
     }

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java?rev=800418&r1=800417&r2=800418&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuilder.java
Mon Aug  3 15:13:46 2009
@@ -718,18 +718,11 @@
             return;
         }
 
-        ModelBuildingEvent event = new DefaultModelBuildingEvent( model, request );
+        ModelBuildingEvent event = new DefaultModelBuildingEvent( model, request, problems
);
 
         for ( ModelBuildingListener listener : request.getModelBuildingListeners() )
         {
-            try
-            {
-                listener.buildExtensionsAssembled( event );
-            }
-            catch ( Exception e )
-            {
-                problems.addError( "Invalid build extensions: " + e.getMessage(), e );
-            }
+            listener.buildExtensionsAssembled( event );
         }
     }
 

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java?rev=800418&r1=800417&r2=800418&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelBuildingEvent.java
Mon Aug  3 15:13:46 2009
@@ -34,10 +34,13 @@
 
     private final ModelBuildingRequest request;
 
-    public DefaultModelBuildingEvent( Model model, ModelBuildingRequest request )
+    private final ModelProblemCollector problems;
+
+    public DefaultModelBuildingEvent( Model model, ModelBuildingRequest request, ModelProblemCollector
problems )
     {
         this.model = model;
         this.request = request;
+        this.problems = problems;
     }
 
     public Model getModel()
@@ -50,4 +53,9 @@
         return request;
     }
 
+    public ModelProblemCollector getProblems()
+    {
+        return problems;
+    }
+
 }

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java?rev=800418&r1=800417&r2=800418&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingEvent.java
Mon Aug  3 15:13:46 2009
@@ -30,17 +30,24 @@
 {
 
     /**
-     * The model being built. The precise state of this model depends on the event being
fired.
+     * Gets the model being built. The precise state of this model depends on the event being
fired.
      * 
      * @return The model being built, never {@code null}.
      */
     Model getModel();
 
     /**
-     * The model building request being processed.
+     * Gets the model building request being processed.
      * 
      * @return The model building request being processed, never {@code null}.
      */
     ModelBuildingRequest getRequest();
 
+    /**
+     * Gets the container used to collect problems that were encountered while processing
the event.
+     * 
+     * @return The container used to collect problems that were encountered, never {@code
null}.
+     */
+    ModelProblemCollector getProblems();
+
 }

Modified: maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java?rev=800418&r1=800417&r2=800418&view=diff
==============================================================================
--- maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java
(original)
+++ maven/components/trunk/maven-model-builder/src/main/java/org/apache/maven/model/building/ModelBuildingListener.java
Mon Aug  3 15:13:46 2009
@@ -20,9 +20,8 @@
  */
 
 /**
- * Defines events that the model builder fires during construction of the effective model.
Unless otherwise noted, an
- * exception thrown by the listener during processing of the event will be treated as a fatal
error and aborts building
- * of the corresponding model.
+ * Defines events that the model builder fires during construction of the effective model.
When a listener encounteres
+ * errors while processing the event, it can report these problems via {@link ModelBuildingEvent#getProblems()}.
  * 
  * @author Benjamin Bentmann
  */
@@ -33,9 +32,7 @@
      * Notifies the listener that the model has been constructed to the extent where build
extensions can be processed.
      * 
      * @param event The details about the event.
-     * @throws Exception If the listener encountered an error.
      */
-    void buildExtensionsAssembled( ModelBuildingEvent event )
-        throws Exception;
+    void buildExtensionsAssembled( ModelBuildingEvent event );
 
 }



Mime
View raw message