maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r571902 - in /maven/components/trunk/maven-embedder/src: main/java/org/apache/maven/embedder/ main/java/org/apache/maven/embedder/execution/ main/resources/META-INF/plexus/ test/java/org/apache/maven/embedder/ test/java/org/apache/maven/emb...
Date Sun, 02 Sep 2007 00:01:04 GMT
Author: jvanzyl
Date: Sat Sep  1 17:01:02 2007
New Revision: 571902

URL: http://svn.apache.org/viewvc?rev=571902&view=rev
Log:
o separate out the embedder tests into packages by concern

Added:
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/MavenEmbedderProjectNotInRepositoryTest.java
      - copied, changed from r571862, maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderBehaviorTest.java
Removed:
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestDefaultsPopulator.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/MavenExecutionRequestDefaultsPopulator.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/AbstractEmbedderExecutionTestCase.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/EmbedderUsingEclipsePluginTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/EmbedderUsingScmPluginTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderCrappySettingsConfigurationTest.java
    maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/ValidateConfigurationTest.java
Modified:
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
    maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
    maven/components/trunk/maven-embedder/src/main/resources/META-INF/plexus/components.xml

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=571902&r1=571901&r2=571902&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
Sat Sep  1 17:01:02 2007
@@ -34,7 +34,7 @@
 import org.apache.maven.artifact.resolver.ArtifactResolver;
 import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
 import org.apache.maven.context.BuildContextManager;
-import org.apache.maven.embedder.execution.MavenExecutionRequestDefaultsPopulator;
+import org.apache.maven.embedder.execution.MavenExecutionRequestPopulator;
 import org.apache.maven.embedder.writer.WriterUtils;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.DefaultMavenExecutionResult;
@@ -95,7 +95,6 @@
 import java.io.Reader;
 import java.io.Writer;
 import java.net.URL;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -159,7 +158,7 @@
 
     private MavenSettingsBuilder settingsBuilder;
 
-    private MavenExecutionRequestDefaultsPopulator defaultsPopulator;
+    private MavenExecutionRequestPopulator populator;
 
     // ----------------------------------------------------------------------
     // Configuration
@@ -426,7 +425,7 @@
 
         try
         {
-            request = defaultsPopulator.populateDefaults( request, this );
+            request = populator.populateDefaults( request, this );
             //mkleint: copied from DefaultLifecycleExecutor
 
             project = readProject( new File( request.getPomFile() ) );
@@ -458,7 +457,7 @@
         }
         catch ( ProjectBuildingException e )
         {
-
+            result.addException( e );
         }
 
         result.setProject( r.getProject() );
@@ -645,8 +644,8 @@
             defaultArtifactRepositoryLayout =
                 (ArtifactRepositoryLayout) container.lookup( ArtifactRepositoryLayout.ROLE,
DEFAULT_LAYOUT_ID );
 
-            defaultsPopulator = (MavenExecutionRequestDefaultsPopulator) container.lookup(
-                MavenExecutionRequestDefaultsPopulator.ROLE );
+            populator = (MavenExecutionRequestPopulator) container.lookup(
+                MavenExecutionRequestPopulator.ROLE );
 
             artifactHandlerManager = (ArtifactHandlerManager) container.lookup( ArtifactHandlerManager.ROLE
);
 
@@ -925,7 +924,7 @@
 
             try
             {
-                request = defaultsPopulator.populateDefaults( request, this );
+                request = populator.populateDefaults( request, this );
             }
             catch ( MavenEmbedderException e )
             {

Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java?rev=571902&r1=571901&r2=571902&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
(original)
+++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java
Sat Sep  1 17:01:02 2007
@@ -29,6 +29,8 @@
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.monitor.event.DefaultEventMonitor;
 import org.apache.maven.plugin.Mojo;
+import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.profiles.DefaultProfileManager;
 import org.apache.maven.settings.Mirror;
 import org.apache.maven.settings.Proxy;
 import org.apache.maven.settings.Server;
@@ -150,6 +152,10 @@
 
         container.getLoggerManager().setThreshold( request.getLoggingLevel() );
 
+        // Create the standard profile manager
+
+        request.setProfileManager( createProfileManager( request ) );
+
         return request;
     }
 
@@ -207,6 +213,23 @@
         {
             container.release( wagonManager );
         }
+    }
+
+    // ------------------------------------------------------------------------
+    // Profile Manager
+    // ------------------------------------------------------------------------
+
+    public ProfileManager createProfileManager( MavenExecutionRequest request )
+    {
+        ProfileManager globalProfileManager = new DefaultProfileManager( container, request.getProperties()
);
+
+        globalProfileManager.loadSettingsProfiles( request.getSettings() );
+
+        globalProfileManager.explicitlyActivate( request.getActiveProfiles() );
+
+        globalProfileManager.explicitlyDeactivate( request.getInactiveProfiles() );
+
+        return globalProfileManager;        
     }
 
     // ----------------------------------------------------------------------------

Modified: maven/components/trunk/maven-embedder/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/resources/META-INF/plexus/components.xml?rev=571902&r1=571901&r2=571902&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/main/resources/META-INF/plexus/components.xml
(original)
+++ maven/components/trunk/maven-embedder/src/main/resources/META-INF/plexus/components.xml
Sat Sep  1 17:01:02 2007
@@ -20,8 +20,8 @@
 <component-set>
   <components>
     <component>
-      <role>org.apache.maven.embedder.execution.MavenExecutionRequestDefaultsPopulator</role>
-      <implementation>org.apache.maven.embedder.execution.DefaultMavenExecutionRequestDefaultsPopulator</implementation>
+      <role>org.apache.maven.embedder.execution.MavenExecutionRequestPopulator</role>
+      <implementation>org.apache.maven.embedder.execution.DefaultMavenExecutionRequestPopulator</implementation>
       <requirements>
         <requirement>
           <role>org.apache.maven.artifact.manager.WagonManager</role>

Copied: maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/MavenEmbedderProjectNotInRepositoryTest.java
(from r571862, maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderBehaviorTest.java)
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/MavenEmbedderProjectNotInRepositoryTest.java?p2=maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/MavenEmbedderProjectNotInRepositoryTest.java&p1=maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderBehaviorTest.java&r1=571862&r2=571902&rev=571902&view=diff
==============================================================================
--- maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/MavenEmbedderBehaviorTest.java
(original)
+++ maven/components/trunk/maven-embedder/src/test/java/org/apache/maven/embedder/project/MavenEmbedderProjectNotInRepositoryTest.java
Sat Sep  1 17:01:02 2007
@@ -1,4 +1,4 @@
-package org.apache.maven.embedder;
+package org.apache.maven.embedder.project;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -19,35 +19,63 @@
  * under the License.
  */
 
-import org.codehaus.plexus.PlexusTestCase;
+import org.apache.maven.embedder.AbstractEmbedderTestCase;
+import org.apache.maven.embedder.Configuration;
+import org.apache.maven.embedder.ConfigurationValidationResult;
+import org.apache.maven.embedder.DefaultConfiguration;
+import org.apache.maven.embedder.MavenEmbedder;
+import org.apache.maven.embedder.MavenEmbedderConsoleLogger;
+import org.apache.maven.execution.DefaultMavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionRequest;
+import org.apache.maven.execution.MavenExecutionResult;
+import org.apache.maven.project.MavenProject;
 
 import java.io.File;
+import java.util.Iterator;
+import java.util.List;
 
-/** @author Jason van Zyl */
-public class MavenEmbedderBehaviorTest
+/**
+ * We want to make sure when projects are newly created and have dependencies between them
that
+ * projects will still resolve and allow good IDE integration. Currently if you have newly
+ * created projects that have interdependencies and you have not run "mvn install" then
+ * none of the dependencies will be resolved for projects with interdependencies.
+ *
+ * @author Jason van Zyl
+ */
+public class MavenEmbedderProjectNotInRepositoryTest
     extends AbstractEmbedderTestCase
 {
-    public void testThatTheLocalRepositoryIsTakenFromGlobalSettingsWhenUserSettingsAreNull()
+    public void testThatNewlyCreatedProjectsWithInterdependenciesStillResolveCorrectly()
         throws Exception
     {
         ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
 
         Configuration configuration = new DefaultConfiguration()
             .setClassLoader( classLoader )
-            .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() )
-            .setUserSettingsFile( null )
-            .setGlobalSettingsFile( new File( getBasedir(), "src/test/resources/settings/valid-settings.xml"
) );
+            .setMavenEmbedderLogger( new MavenEmbedderConsoleLogger() );
+
+        ConfigurationValidationResult cr = MavenEmbedder.validateConfiguration( configuration
);
+
+        assertTrue( cr.isValid() );
+
+        MavenEmbedder embedder = new MavenEmbedder( configuration );
+
+        File projectDirectory = new File( getBasedir(), "src/test/projects/no-artifact-in-repository-test"
);
 
-        ConfigurationValidationResult result = MavenEmbedder.validateConfiguration( configuration
);
+        MavenExecutionRequest request = new DefaultMavenExecutionRequest()
+            .setBaseDirectory( projectDirectory );
 
-         assertTrue( result.isValid() );
+        MavenExecutionResult result = embedder.readProjectWithDependencies( request );  
     
 
-        MavenEmbedder maven = new MavenEmbedder( configuration );
+        List projects = result.getTopologicallySortedProjects();
 
-        String expectedPath = ( new File( "/global/maven/local-repository" ) ).getCanonicalPath();
-        String actualPath = maven.getLocalRepository().getBasedir();
-        assertEquals( expectedPath, actualPath );
+        /*
+        for ( Iterator i = projects.iterator(); i.hasNext(); )
+        {
+            MavenProject project = (MavenProject) i.next();
 
-        maven.stop();
+            System.out.println( "project = " + project );
+        }
+        */
     }
-}
+}
\ No newline at end of file



Mime
View raw message