maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject svn commit: r611014 [2/2] - in /maven/components/trunk: ./ maven-core/src/main/aspect/org/apache/maven/errors/ maven-core/src/main/java/org/apache/maven/errors/ maven-core/src/main/java/org/apache/maven/extension/ maven-embedder/ maven-embedder/src/tes...
Date Fri, 11 Jan 2008 01:57:30 GMT
Modified: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java (original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/error/ErrorReporterPointcutTest.java Thu Jan 10 17:57:27 2008
@@ -1,5 +1,10 @@
 package org.apache.maven.error;
 
+import org.apache.commons.httpclient.HttpClient;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.commons.httpclient.HttpException;
+import org.apache.commons.httpclient.HttpStatus;
+import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.maven.embedder.Configuration;
 import org.apache.maven.embedder.DefaultConfiguration;
 import org.apache.maven.embedder.MavenEmbedder;
@@ -7,6 +12,8 @@
 import org.apache.maven.errors.CoreErrorReporter;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionResult;
+import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
 import org.codehaus.plexus.logging.Logger;
 import org.codehaus.plexus.util.FileUtils;
 import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
@@ -14,8 +21,12 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
 import java.net.URISyntaxException;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Iterator;
 
 import junit.framework.TestCase;
 
@@ -31,6 +42,10 @@
 
     private String basedir;
 
+    private static boolean isOffline;
+
+    private static boolean offlineIsSet = false;
+
     public void setUp()
         throws Exception
     {
@@ -57,10 +72,68 @@
         maven = new MavenEmbedder( configuration );
     }
 
+    private boolean checkOnline()
+    {
+        if ( !offlineIsSet )
+        {
+            HttpClient client = new HttpClient();
+            GetMethod get = new GetMethod(
+                                           "http://repo1.maven.org/maven2/org/apache/maven/maven-core/2.0/maven-core-2.0.pom" );
+
+            HttpConnectionManager mgr = client.getHttpConnectionManager();
+            mgr.getParams().setConnectionTimeout( 1 );
+
+            try
+            {
+                int result = client.executeMethod( get );
+                if ( result == HttpStatus.SC_OK )
+                {
+                    new MavenXpp3Reader().read( get.getResponseBodyAsStream() );
+                    isOffline = false;
+                }
+            }
+            catch ( HttpException e )
+            {
+                System.out.println( "System is offline" );
+                isOffline = true;
+            }
+            catch ( IOException e )
+            {
+                System.out.println( "System is offline" );
+                isOffline = true;
+            }
+            catch ( XmlPullParserException e )
+            {
+                System.out.println( "System is offline" );
+                isOffline = true;
+            }
+            finally
+            {
+                offlineIsSet = true;
+            }
+        }
+
+        if ( isOffline )
+        {
+            String method = getTestMethodName();
+            System.out.println( "Test: " + method
+                                + " requires an access to the Maven central repository. SKIPPING." );
+            return false;
+        }
+
+        return true;
+    }
+
+    private String getTestMethodName()
+    {
+        String method = new Throwable().getStackTrace()[2].getMethodName();
+        return method;
+    }
+
     private File prepareProjectDir()
         throws URISyntaxException, IOException
     {
-        String method = new Throwable().getStackTrace()[1].getMethodName();
+        String method = getTestMethodName();
 
         String resource = "error-reporting-projects/" + method;
 
@@ -74,8 +147,9 @@
             {
                 FileUtils.deleteDirectory( targetDirectory );
             }
-            catch( IOException e )
-            {}
+            catch ( IOException e )
+            {
+            }
         }
 
         FileUtils.copyDirectoryStructure( testDirectory, targetDirectory );
@@ -108,10 +182,69 @@
 
     }
 
+    // FIXME: Fix the offline detection for this one!
     public void testReportAggregatedMojoFailureException()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        if ( !checkOnline() )
+        {
+            return;
+        }
+
+        File projectDir = prepareProjectDir();
+
+        buildTestAccessory( new File( projectDir, "plugin" ) );
+
+        File basedir = new File( projectDir, "project" );
+
+        reporter.reportAggregatedMojoFailureException( null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "org.apache.maven.errortest:testReportAggregatedMojoFailureException-maven-plugin:1:test"
+                                                                          } ) );
+
+        maven.execute( request );
+
+        reporterCtl.verify();
+    }
+
+    private void buildTestAccessory( File basedir )
+    {
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( basedir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( new DummyCoreErrorReporter() )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "clean",
+                                                                              "install"
+                                                                          } ) );
+
+        MavenExecutionResult result = maven.execute( request );
+
+        if ( result.hasExceptions() )
+        {
+            StringWriter writer = new StringWriter();
+            PrintWriter pWriter = new PrintWriter( writer );
+
+            writer.write( "Failed to build project in: " );
+            writer.write( basedir.getPath() );
+            writer.write( "\nEncountered the following errors:" );
 
+            for ( Iterator it = result.getExceptions().iterator(); it.hasNext(); )
+            {
+                Throwable error = (Throwable) it.next();
+                writer.write( "\n\n" );
+                error.printStackTrace( pWriter );
+            }
+
+            fail( writer.toString() );
+        }
     }
 
     public void testReportAttemptToOverrideUneditableMojoParameter()
@@ -277,8 +410,19 @@
 
     public void testReportNoGoalsSpecifiedException()
     {
-        // TODO Auto-generated method stub
+        reporter.reportNoGoalsSpecifiedException( null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Collections.EMPTY_LIST );
+
+        maven.execute( request );
 
+        reporterCtl.verify();
     }
 
     public void testReportPluginErrorWhileValidatingTask()
@@ -300,9 +444,26 @@
     }
 
     public void testReportProjectCycle()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
+
+        reporter.reportProjectCycle( null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "initialize"
+                                                                          } ) );
+
+        maven.execute( request );
 
+        reporterCtl.verify();
     }
 
     public void testReportProjectDependenciesNotFound()
@@ -377,82 +538,149 @@
 
     }
 
-    public void clearErrors()
+    // FIXME: How can I test this when it's masked by reportActivatorErrorWhileGettingRepositoriesFromProfiles?
+    public void testReportActivatorError()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
-
-    }
+        File projectDir = prepareProjectDir();
 
-    public Throwable findReportedException( Throwable error )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
+        reporter.reportActivatorError( null, null, null, null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
 
-    public String getFormattedMessage( Throwable error )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
+        reporterCtl.replay();
 
-    public Throwable getRealCause( Throwable error )
-    {
-        // TODO Auto-generated method stub
-        return null;
-    }
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "initialize"
+                                                                          } ) );
 
-    public void testReportActivatorErrorWhileApplyingProfiles()
-    {
-        // TODO Auto-generated method stub
+        maven.execute( request );
 
+        reporterCtl.verify();
     }
 
-    public void testReportActivatorErrorWhileGettingRepositoriesFromProfiles()
+    public void testReportActivatorLookupError()
     {
         // TODO Auto-generated method stub
 
     }
 
-    public void testReportActivatorLookupErrorWhileApplyingProfiles()
+    public void testReportBadDependencyVersion()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
 
-    }
+        reporter.reportBadDependencyVersion( null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
 
-    public void testReportActivatorLookupErrorWhileGettingRepositoriesFromProfiles()
-    {
-        // TODO Auto-generated method stub
+        reporterCtl.replay();
 
-    }
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "compile"
+                                                                          } ) );
 
-    public void testReportBadDependencyVersion()
-    {
-        // TODO Auto-generated method stub
+        maven.execute( request );
 
+        reporterCtl.verify();
     }
 
     public void testReportBadManagedDependencyVersion()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
+
+        reporter.reportBadManagedDependencyVersion( null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "initialize"
+                                                                          } ) );
+
+        maven.execute( request );
 
+        reporterCtl.verify();
     }
 
     public void testReportBadNonDependencyProjectArtifactVersion()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
 
+        reporter.reportBadNonDependencyProjectArtifactVersion( null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "initialize"
+                                                                          } ) );
+
+        maven.execute( request );
+
+        reporterCtl.verify();
     }
 
     public void testReportErrorCreatingArtifactRepository()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
+
+        reporter.reportErrorCreatingArtifactRepository( null, null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
 
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "compile"
+                                                                          } ) );
+
+        maven.execute( request );
+
+        reporterCtl.verify();
     }
 
     public void testReportErrorCreatingDeploymentArtifactRepository()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
 
+        reporter.reportErrorCreatingDeploymentArtifactRepository( null, null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "compile"
+                                                                          } ) );
+
+        maven.execute( request );
+
+        reporterCtl.verify();
     }
 
     public void testReportErrorInterpolatingModel_UsingModelInstance()
@@ -520,7 +748,9 @@
 
         reporterCtl.replay();
 
-        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File( projectDir, "pom.xml" ) )
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setPom( new File(
+                                                                                             projectDir,
+                                                                                             "pom.xml" ) )
                                                                           .setShowErrors( true )
                                                                           .setErrorReporter( reporter )
                                                                           .setGoals( Arrays.asList( new String[] {
@@ -551,15 +781,49 @@
     }
 
     public void testReportProjectCollision()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
+
+        reporter.reportProjectCollision( null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "initialize"
+                                                                          } ) );
+
+        maven.execute( request );
 
+        reporterCtl.verify();
     }
 
     public void testReportProjectValidationFailure()
+        throws URISyntaxException, IOException
     {
-        // TODO Auto-generated method stub
+        File projectDir = prepareProjectDir();
 
+        reporter.reportProjectValidationFailure( null, null, null );
+        reporterCtl.setMatcher( MockControl.ALWAYS_MATCHER );
+        reporterCtl.setVoidCallable();
+
+        reporterCtl.replay();
+
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest().setBaseDirectory( projectDir )
+                                                                          .setShowErrors( true )
+                                                                          .setErrorReporter( reporter )
+                                                                          .setGoals( Arrays.asList( new String[] {
+                                                                              "initialize"
+                                                                          } ) );
+
+        maven.execute( request );
+
+        reporterCtl.verify();
     }
 
 }

Modified: maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj (original)
+++ maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/PBEDerivativeReporterAspect.aj Thu Jan 10 17:57:27 2008
@@ -12,6 +12,7 @@
 import org.apache.maven.model.DeploymentRepository;
 import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.MavenTools;
+import org.apache.maven.project.build.model.DefaultModelLineageBuilder;
 import org.apache.maven.project.MavenProject;
 import org.apache.maven.project.DefaultMavenProjectBuilder;
 import org.apache.maven.project.InvalidProjectModelException;
@@ -19,6 +20,7 @@
 
 import java.io.File;
 import java.util.Set;
+import java.util.List;
 
 public privileged aspect PBEDerivativeReporterAspect
     extends AbstractProjectErrorReporterAspect
@@ -34,6 +36,10 @@
         execution( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
         && args( project, pomFile, .. );
 
+    private pointcut within_pbldr_processProjectLogic( MavenProject project, File pomFile ):
+        withincode( private MavenProject DefaultMavenProjectBuilder.processProjectLogic( MavenProject, File, .. ) )
+        && args( project, pomFile, .. );
+
     private pointcut within_DefaultMavenProjectBuilder():
         !withincode( * DefaultProfileAdvisor.*( .. ) )
         && notWithinAspect();
@@ -63,8 +69,6 @@
         call( ArtifactRepository MavenTools+.buildArtifactRepository( Repository ) )
         && args( repo );
 
-    private boolean processingPluginRepositories = false;
-
     // =========================================================================
     // Call Stack:
     // =========================================================================
@@ -82,31 +86,31 @@
     after( MavenProject project, File pomFile, Repository repo ) throwing( UnknownRepositoryLayoutException cause ):
         mavenTools_buildArtifactRepository( repo )
         && cflow( pbldr_processProjectLogic( project, pomFile ) )
-        && within_DefaultMavenProjectBuilder()
     {
-        getReporter().reportErrorCreatingArtifactRepository( project, pomFile, repo, cause, processingPluginRepositories );
+        getReporter().reportErrorCreatingArtifactRepository( project.getId(), pomFile, repo, cause );
     }
 
-    after():
-        call( * Model+.getPluginRepositories() )
-        && cflow( pbldr_processProjectLogic( MavenProject, File ) )
-        && within_DefaultMavenProjectBuilder()
-    {
-        processingPluginRepositories = true;
-    }
+    private pointcut mlbldr_updateRepositorySet( Model model, File pomFile ):
+        execution( List DefaultModelLineageBuilder.updateRepositorySet( Model, *, File, .. ) )
+        && args( model, *, pomFile, .. );
 
-    after():
-        call( * Model+.getRepositories() )
-        && cflow( pbldr_processProjectLogic( MavenProject, File ) )
-        && within_DefaultMavenProjectBuilder()
-    {
-        processingPluginRepositories = false;
-    }
-
-    after( MavenProject project, File pomFile ):
-        pbldr_processProjectLogic( project, pomFile )
+    // =========================================================================
+    // Call Stack:
+    // =========================================================================
+    // ...
+    // --> DefaultModelLineageBuilder.buildModelLineage(..)
+    // --> DefaultModelLineageBuilder.resumeBuildingModelLineage(..)
+    //     --> DefaultModelLineageBuilder.updateRepositorySet(..) (private)
+    //         --> DefaultMavenTools.buildArtifactRepositories(..)
+    //             --> DefaultMavenTools.buildArtifactRepository(..)
+    //         <------ UnknownRepositoryLayoutException
+    // <------ ProjectBuildingException
+    // =========================================================================
+    after( Model model, File pomFile, Repository repo ) throwing( UnknownRepositoryLayoutException cause ):
+        mavenTools_buildArtifactRepository( repo )
+        && cflow( mlbldr_updateRepositorySet( model, pomFile ) )
     {
-        processingPluginRepositories = false;
+        getReporter().reportErrorCreatingArtifactRepository( model.getId(), pomFile, repo, cause );
     }
 
     // ModelInterpolationException

Modified: maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj (original)
+++ maven/components/trunk/maven-project/src/main/aspect/org/apache/maven/project/aspect/ProfileErrorReporterAspect.aj Thu Jan 10 17:57:27 2008
@@ -72,7 +72,7 @@
         throwing( ComponentLookupException cause ):
             applyActivatedProfiles_ComponentLookupException( model, pomFile, profile )
     {
-        getReporter().reportActivatorLookupErrorWhileApplyingProfiles( model, pomFile, profile, cause );
+        getReporter().reportActivatorLookupError( model.getId(), pomFile, profile, cause );
     }
 
     protected pointcut profileActivatorCall( ProfileActivator activator ):
@@ -107,7 +107,7 @@
         throwing( ProfileActivationException cause ):
             applyActivatedProfiles_ActivatorThrown( activator, model, pomFile, profile, context )
     {
-        getReporter().reportActivatorErrorWhileApplyingProfiles( activator, model, pomFile, profile, context, cause );
+        getReporter().reportActivatorError( activator, model.getId(), pomFile, profile, context, cause );
     }
 
     private pointcut pAdv_loadExternalProjectProfiles( Model model, File pomFile ):
@@ -189,7 +189,7 @@
         throwing( ComponentLookupException cause ):
             getArtifactRepositoriesFromActiveProfiles_ComponentLookupException( projectId, pomFile, profile )
     {
-        getReporter().reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( projectId, pomFile, profile, cause );
+        getReporter().reportActivatorLookupError( projectId, pomFile, profile, cause );
     }
 
     private pointcut getArtifactRepositoriesFromActiveProfiles_ActivatorThrown( ProfileActivator activator,
@@ -220,7 +220,7 @@
         throwing( ProfileActivationException cause ):
             getArtifactRepositoriesFromActiveProfiles_ActivatorThrown( activator, projectId, pomFile, profile, context )
     {
-        getReporter().reportActivatorErrorWhileGettingRepositoriesFromProfiles( activator, projectId, pomFile, profile, context, cause );
+        getReporter().reportActivatorError( activator, projectId, pomFile, profile, context, cause );
     }
 
     private pointcut getArtifactRepositoriesFromActiveProfiles_InvalidRepository( Repository repo,

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Thu Jan 10 17:57:27 2008
@@ -915,8 +915,15 @@
 
         validateModel( model, pomFile );
 
-        project.setRemoteArtifactRepositories(
-            mavenTools.buildArtifactRepositories( model.getRepositories() ) );
+        try
+        {
+            project.setRemoteArtifactRepositories(
+                                                  mavenTools.buildArtifactRepositories( model.getRepositories() ) );
+        }
+        catch( Exception e )
+        {
+            e.printStackTrace();
+        }
 
         String projectId = safeVersionlessKey( model.getGroupId(), model.getArtifactId() );
 

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/DefaultProjectErrorReporter.java Thu Jan 10 17:57:27 2008
@@ -114,51 +114,12 @@
     /**
      * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileApplyingProfiles(org.apache.maven.profiles.activation.ProfileActivator, org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
      */
-    public void reportActivatorErrorWhileApplyingProfiles( ProfileActivator activator,
-                                                           Model model,
-                                                           File pomFile,
-                                                           Profile profile,
-                                                           ProfileActivationContext context,
-                                                           ProfileActivationException cause )
-    {
-        StringWriter writer = new StringWriter();
-
-        writer.write( NEWLINE );
-        writer.write( "Profile activator: " );
-        writer.write( activator.getClass().getName() );
-        writer.write( " experienced an error while processing profile:" );
-        writer.write( NEWLINE );
-        writer.write( NEWLINE );
-        writer.write( profile.getId() );
-        writer.write( " (source: " );
-        writer.write( profile.getSource() );
-        writer.write( ")" );
-        writer.write( NEWLINE );
-        writer.write( NEWLINE );
-        writer.write( "Error message: " );
-        writer.write( NEWLINE );
-        writer.write( cause.getMessage() );
-
-        addStandardInfo( model.getId(), pomFile, writer );
-        addTips( ProjectErrorTips.getTipsForActivatorErrorWhileApplyingProfiles( activator,
-                                                                                 model,
-                                                                                 pomFile,
-                                                                                 profile,
-                                                                                 context,
-                                                                                 cause ), writer );
-
-        registerBuildError( cause, writer.toString(), cause.getCause() );
-    }
-
-    /**
-     * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorErrorWhileGettingRepositoriesFromProfiles(org.apache.maven.profiles.activation.ProfileActivator, java.lang.String, java.io.File, org.apache.maven.model.Profile, org.apache.maven.profiles.activation.ProfileActivationContext, org.apache.maven.profiles.activation.ProfileActivationException)
-     */
-    public void reportActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator,
-                                                                          String projectId,
-                                                                          File pomFile,
-                                                                          Profile profile,
-                                                                          ProfileActivationContext context,
-                                                                          ProfileActivationException cause )
+    public void reportActivatorError( ProfileActivator activator,
+                                      String projectId,
+                                      File pomFile,
+                                      Profile profile,
+                                      ProfileActivationContext context,
+                                      ProfileActivationException cause )
     {
         StringWriter writer = new StringWriter();
 
@@ -179,58 +140,23 @@
         writer.write( cause.getMessage() );
 
         addStandardInfo( projectId, pomFile, writer );
-        addTips( ProjectErrorTips.getTipsForActivatorErrorWhileGettingRepositoriesFromProfiles( activator,
-                                                                                                projectId,
-                                                                                                pomFile,
-                                                                                                profile,
-                                                                                                context,
-                                                                                                cause ),
-                 writer );
+        addTips( ProjectErrorTips.getTipsForActivatorError( activator,
+                                                            projectId,
+                                                            pomFile,
+                                                            profile,
+                                                            context,
+                                                            cause ), writer );
 
         registerBuildError( cause, writer.toString(), cause.getCause() );
     }
 
     /**
-     * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupErrorWhileApplyingProfiles(org.apache.maven.model.Model, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
+     * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupError(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
      */
-    public void reportActivatorLookupErrorWhileApplyingProfiles( Model model,
-                                                                 File pomFile,
-                                                                 Profile profile,
-                                                                 ComponentLookupException cause )
-    {
-        StringWriter writer = new StringWriter();
-
-        writer.write( NEWLINE );
-        writer.write( "Error retrieving profile-activator component while processing profile:" );
-        writer.write( NEWLINE );
-        writer.write( NEWLINE );
-        writer.write( profile.getId() );
-        writer.write( " (source: " );
-        writer.write( profile.getSource() );
-        writer.write( ")" );
-        writer.write( NEWLINE );
-        writer.write( NEWLINE );
-        writer.write( "Error message: " );
-        writer.write( NEWLINE );
-        writer.write( cause.getMessage() );
-
-        addStandardInfo( model.getId(), pomFile, writer );
-        addTips( ProjectErrorTips.getTipsForActivatorLookupErrorWhileApplyingProfiles( model,
-                                                                                       pomFile,
-                                                                                       profile,
-                                                                                       cause ),
-                 writer );
-
-        registerBuildError( cause, writer.toString(), cause.getCause() );
-    }
-
-    /**
-     * @see org.apache.maven.project.error.ProjectErrorReporter#reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles(java.lang.String, java.io.File, org.apache.maven.model.Profile, org.codehaus.plexus.component.repository.exception.ComponentLookupException)
-     */
-    public void reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId,
-                                                                                File pomFile,
-                                                                                Profile profile,
-                                                                                ComponentLookupException cause )
+    public void reportActivatorLookupError( String projectId,
+                                            File pomFile,
+                                            Profile profile,
+                                            ComponentLookupException cause )
     {
         StringWriter writer = new StringWriter();
 
@@ -249,11 +175,10 @@
         writer.write( cause.getMessage() );
 
         addStandardInfo( projectId, pomFile, writer );
-        addTips( ProjectErrorTips.getTipsForActivatorLookupErrorWhileGettingRepositoriesFromProfiles( projectId,
-                                                                                                      pomFile,
-                                                                                                      profile,
-                                                                                                      cause ),
-                 writer );
+        addTips( ProjectErrorTips.getTipsForActivatorLookupError( projectId,
+                                                                  pomFile,
+                                                                  profile,
+                                                                  cause ), writer );
 
         registerBuildError( cause, writer.toString(), cause.getCause() );
     }
@@ -385,11 +310,10 @@
         }
     }
 
-    public void reportErrorCreatingArtifactRepository( MavenProject project,
+    public void reportErrorCreatingArtifactRepository( String projectId,
                                                        File pomFile,
                                                        Repository repo,
-                                                       UnknownRepositoryLayoutException cause,
-                                                       boolean isPluginRepo )
+                                                       UnknownRepositoryLayoutException cause )
     {
         StringWriter writer = new StringWriter();
 
@@ -405,8 +329,8 @@
         writer.write( cause.getMessage() );
         writer.write( NEWLINE );
 
-        addStandardInfo( project.getId(), pomFile, writer );
-        addTips( ProjectErrorTips.getTipsForInvalidRepositorySpec( repo, project.getId(), pomFile, cause ),
+        addStandardInfo( projectId, pomFile, writer );
+        addTips( ProjectErrorTips.getTipsForInvalidRepositorySpec( repo, projectId, pomFile, cause ),
                  writer );
 
         registerBuildError( cause, writer.toString() );

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorReporter.java Thu Jan 10 17:57:27 2008
@@ -45,27 +45,6 @@
      * DefaultProfileAdvisor.applyActivatedProfiles(..)
      * DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
      * --&gt; DefaultProfileAdvisor.applyActivatedProfiles(..) (private)
-     *     --&gt; DefaultProfileManager.getActiveProfiles(..)
-     *         --&gt; DefaultProfileManager.isActive(..) (private)
-     *             --&gt; ProfileActivator.canDetermineActivation(..)
-     *             --&gt; ProfileActivator.isActive(..)
-     *         &lt;------ ProfileActivationException
-     * &lt;------ ProjectBuildingException
-     * </pre>
-     */
-    void reportActivatorErrorWhileApplyingProfiles( ProfileActivator activator,
-                                                    Model model,
-                                                    File pomFile,
-                                                    Profile profile,
-                                                    ProfileActivationContext context,
-                                                    ProfileActivationException cause );
-
-    /**
-     * <b>Call Stack:</b>
-     * <br/>
-     * <pre>
-     * DefaultProfileAdvisor.applyActivatedProfiles(..)
-     * DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
      * --&gt; DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
      *     --&gt; DefaultProfileManager.getActiveProfiles(..)
      *         --&gt; DefaultProfileManager.isActive(..) (private)
@@ -75,12 +54,12 @@
      * &lt;------ ProjectBuildingException
      * </pre>
      */
-    void reportActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator,
-                                                                   String projectId,
-                                                                   File pomFile,
-                                                                   Profile profile,
-                                                                   ProfileActivationContext context,
-                                                                   ProfileActivationException cause );
+    void reportActivatorError( ProfileActivator activator,
+                               String projectId,
+                               File pomFile,
+                               Profile profile,
+                               ProfileActivationContext context,
+                               ProfileActivationException cause );
 
     /**
      * <b>Call Stack:</b>
@@ -89,25 +68,6 @@
      * DefaultProfileAdvisor.applyActivatedProfiles(..)
      * DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
      * --&gt; DefaultProfileAdvisor.applyActivatedProfiles(..) (private)
-     *     --&gt; DefaultProfileManager.getActiveProfiles(..)
-     *         --&gt; DefaultProfileManager.isActive(..) (private)
-     *             --&gt; PlexusContainer.lookupList(..)
-     *             &lt;-- ComponentLookupException
-     *         &lt;-- ProfileActivationException
-     * &lt;------ ProjectBuildingException
-     * </pre>
-     */
-    void reportActivatorLookupErrorWhileApplyingProfiles( Model model,
-                                                          File pomFile,
-                                                          Profile profile,
-                                                          ComponentLookupException cause );
-
-    /**
-     * <b>Call Stack:</b>
-     * <br/>
-     * <pre>
-     * DefaultProfileAdvisor.applyActivatedProfiles(..)
-     * DefaultProfileAdvisor.applyActivatedExternalProfiles(..)
      * --&gt; DefaultProfileAdvisor.getArtifactRepositoriesFromActiveProfiles(..)
      *     --&gt; DefaultProfileManager.getActiveProfiles(..)
      *         --&gt; DefaultProfileManager.isActive(..) (private)
@@ -117,10 +77,10 @@
      * &lt;------ ProjectBuildingException
      * </pre>
      */
-    void reportActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId,
-                                                                         File pomFile,
-                                                                         Profile profile,
-                                                                         ComponentLookupException cause );
+    void reportActivatorLookupError( String projectId,
+                                     File pomFile,
+                                     Profile profile,
+                                     ComponentLookupException cause );
 
     /**
      * <b>Call Stack:</b>
@@ -211,11 +171,10 @@
      * &lt;---------- ProjectBuildingException
      * </pre>
      */
-    void reportErrorCreatingArtifactRepository( MavenProject project,
+    void reportErrorCreatingArtifactRepository( String projectId,
                                                 File pomFile,
                                                 Repository repo,
-                                                UnknownRepositoryLayoutException cause,
-                                                boolean isPluginRepo );
+                                                UnknownRepositoryLayoutException cause );
 
     /**
      * <b>Call Stack:</b>

Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/error/ProjectErrorTips.java Thu Jan 10 17:57:27 2008
@@ -33,12 +33,12 @@
     {
     }
 
-    public static List getTipsForActivatorErrorWhileApplyingProfiles( ProfileActivator activator,
-                                                                              Model model,
-                                                                              File pomFile,
-                                                                              Profile profile,
-                                                                              ProfileActivationContext context,
-                                                                              ProfileActivationException cause )
+    public static List getTipsForActivatorError( ProfileActivator activator,
+                                                 String projectId,
+                                                 File pomFile,
+                                                 Profile profile,
+                                                 ProfileActivationContext context,
+                                                 ProfileActivationException cause )
     {
         return listOf( new String[]{  "If this is a standard profile activator, see "
                                        + "http://maven.apache.org/pom.html#Activation for help configuring profile activation.",
@@ -47,37 +47,10 @@
                        "XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
     }
 
-    public static List getTipsForActivatorErrorWhileGettingRepositoriesFromProfiles( ProfileActivator activator,
-                                                                                             String projectId,
-                                                                                             File pomFile,
-                                                                                             Profile profile,
-                                                                                             ProfileActivationContext context,
-                                                                                             ProfileActivationException cause )
-    {
-        return listOf( new String[]{  "If this is a standard profile activator, see "
-                                       + "http://maven.apache.org/pom.html#Activation for help configuring profile activation.",
-                       "XSD location for pom.xml: http://maven.apache.org/xsd/maven-4.0.0.xsd",
-                       "XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd",
-                       "XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
-    }
-
-    public static List getTipsForActivatorLookupErrorWhileApplyingProfiles( Model model,
-                                                                                    File pomFile,
-                                                                                    Profile profile,
-                                                                                    ComponentLookupException cause )
-    {
-        return listOf( new String[]{  "If this is a custom profile activator, please ensure the activator's "
-                                       + "artifact is present in the POM's build/extensions list.",
-                       "See http://maven.apache.org/pom.html#Extensions for more on build extensions.",
-                       "XSD location for pom.xml: http://maven.apache.org/xsd/maven-4.0.0.xsd",
-                       "XSD location for settings.xml: http://maven.apache.org/xsd/settings-1.0.0.xsd",
-                       "XSD location for profiles.xml: http://maven.apache.org/xsd/profiles-1.0.0.xsd" } );
-    }
-
-    public static List getTipsForActivatorLookupErrorWhileGettingRepositoriesFromProfiles( String projectId,
-                                                                                                   File pomFile,
-                                                                                                   Profile profile,
-                                                                                                   ComponentLookupException cause )
+    public static List getTipsForActivatorLookupError( String projectId,
+                                                       File pomFile,
+                                                       Profile profile,
+                                                       ComponentLookupException cause )
     {
         return listOf( new String[]{  "If this is a custom profile activator, please ensure the activator's "
                                        + "artifact is present in the POM's build/extensions list.",

Modified: maven/components/trunk/pom.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/pom.xml?rev=611014&r1=611013&r2=611014&view=diff
==============================================================================
--- maven/components/trunk/pom.xml (original)
+++ maven/components/trunk/pom.xml Thu Jan 10 17:57:27 2008
@@ -227,6 +227,12 @@
         <version>1.2_Java1.3</version>
         <scope>test</scope>
       </dependency>
+      <dependency>
+        <groupId>commons-httpclient</groupId>
+        <artifactId>commons-httpclient</artifactId>
+        <version>3.1</version>
+        <scope>test</scope>
+      </dependency>
     </dependencies>
   </dependencyManagement>
   <distributionManagement>



Mime
View raw message