initialize remote repositories before attempting to load projects

git-svn-id: https://svn.apache.org/repos/asf/maven/sandbox/trunk/mae@1160893 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java b/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java
index 4338b4f..86913cd 100644
--- a/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java
+++ b/mae-booter/src/main/java/org/apache/maven/mae/app/AbstractMAEApplication.java
@@ -19,6 +19,11 @@
 
 package org.apache.maven.mae.app;
 
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.log4j.Logger;
 import org.apache.maven.mae.MAEException;
 import org.apache.maven.mae.boot.embed.MAEEmbedder;
@@ -35,16 +40,10 @@
 import org.apache.maven.mae.internal.container.VirtualInstance;
 import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
- * {@link MAEApplication} implementation that provides support for loading a full Maven component
- * environment, complete with {@link MAELibrary}'s, {@link ComponentSelector} and {@link InstanceRegistry}.
- * This class supervises the assembly of the environment, giving the application developer an easy
- * way to inject the behavior he needs.
+ * {@link MAEApplication} implementation that provides support for loading a full Maven component environment, complete
+ * with {@link MAELibrary}'s, {@link ComponentSelector} and {@link InstanceRegistry}. This class supervises the assembly
+ * of the environment, giving the application developer an easy way to inject the behavior he needs.
  * 
  * @author John Casey
  */
@@ -66,9 +65,8 @@
     }
 
     /**
-     * Programmatically add a new {@link MAELibrary} instance, beyond those that are automatically
-     * detected via the /META-INF/services/org.apache.maven.mae.conf.MAELibrary files on the
-     * classpath.
+     * Programmatically add a new {@link MAELibrary} instance, beyond those that are automatically detected via the
+     * /META-INF/services/org.apache.maven.mae.conf.MAELibrary files on the classpath.
      */
     protected final AbstractMAEApplication withLibrary( final MAELibrary library )
     {
@@ -78,6 +76,7 @@
 
     /**
      * {@inheritDoc}
+     * 
      * @see org.apache.maven.mae.app.MAEApplication#load()
      */
     @Override
@@ -88,21 +87,19 @@
     }
 
     /**
-     * Carry out the application loading process. This means:
-     * <br/>
+     * Carry out the application loading process. This means: <br/>
      * <ul>
-     *   <li>Create a new {@link MAEEmbedderBuilder}</li>
-     *   <li>Add to that an {@link InstanceLibraryLoader} to handle libraries that were 
-     *       programmatically added here</li>
-     *   <li>Call {@link AbstractMAEApplication#beforeLoading()}</li>
-     *   <li>Call {@link AbstractMAEApplication#configureBuilder(MAEEmbedderBuilder)} to allow 
-     *       fine-tuning of the {@link MAEEmbedderBuilder} instance</li>
-     *   <li>Call {@link MAEEmbedderBuilder#build} to create an instance of {@link MAEEmbedder}</li>
-     *   <li>For each instance in the {@link InstanceRegistry}, lookup via {@link MAEEmbedder#container()}
-     *       to ensure injectable component dependencies are filled</li>
-     *   <li>Call {@link AbstractMAEApplication#afterLoading()}</li>
-     *   <li>Set the loaded flag, which will prevent this process from repeating for an application
-     *       that has already been loaded</li>
+     * <li>Create a new {@link MAEEmbedderBuilder}</li>
+     * <li>Add to that an {@link InstanceLibraryLoader} to handle libraries that were programmatically added here</li>
+     * <li>Call {@link AbstractMAEApplication#beforeLoading()}</li>
+     * <li>Call {@link AbstractMAEApplication#configureBuilder(MAEEmbedderBuilder)} to allow fine-tuning of the
+     * {@link MAEEmbedderBuilder} instance</li>
+     * <li>Call {@link MAEEmbedderBuilder#build} to create an instance of {@link MAEEmbedder}</li>
+     * <li>For each instance in the {@link InstanceRegistry}, lookup via {@link MAEEmbedder#container()} to ensure
+     * injectable component dependencies are filled</li>
+     * <li>Call {@link AbstractMAEApplication#afterLoading()}</li>
+     * <li>Set the loaded flag, which will prevent this process from repeating for an application that has already been
+     * loaded</li>
      * </ul>
      */
     private synchronized final MAEApplication doLoad()
@@ -113,7 +110,8 @@
             return this;
         }
 
-        final MAEEmbedderBuilder builder = new MAEEmbedderBuilder().withLibraryLoader( new InstanceLibraryLoader( additionalLibraries ) );
+        final MAEEmbedderBuilder builder =
+            new MAEEmbedderBuilder().withLibraryLoader( new InstanceLibraryLoader( additionalLibraries ) );
 
         configureBuilder( builder );
 
@@ -139,8 +137,8 @@
     }
 
     /**
-     * Register a new, external component instance for injection into other components, or to
-     * have components injected into it.
+     * Register a new, external component instance for injection into other components, or to have components injected
+     * into it.
      */
     @SuppressWarnings( { "unchecked", "rawtypes" } )
     protected final void withComponentInstance( final Object instance )
@@ -149,9 +147,9 @@
     }
 
     /**
-     * Register a new {@link VirtualInstance}, which allows the component environment to bind its
-     * requirements without actually having access to the component instance. The instance itself
-     * will be injected into the {@link VirtualInstance} later.
+     * Register a new {@link VirtualInstance}, which allows the component environment to bind its requirements without
+     * actually having access to the component instance. The instance itself will be injected into the
+     * {@link VirtualInstance} later.
      */
     protected final <C> void withVirtualComponent( final Class<C> virtualClass )
     {
@@ -167,8 +165,8 @@
     }
 
     /**
-     * Register a new, external component instance to make it available for injection, or to allow
-     * other components to be injected into it.
+     * Register a new, external component instance to make it available for injection, or to allow other components to
+     * be injected into it.
      */
     protected final <C> void withComponentInstance( final ComponentKey<C> componentKey, final C instance )
     {
@@ -176,9 +174,9 @@
     }
 
     /**
-     * Register a new {@link VirtualInstance}, which allows the component environment to bind its
-     * requirements without actually having access to the component instance. The instance itself
-     * will be injected into the {@link VirtualInstance} later.
+     * Register a new {@link VirtualInstance}, which allows the component environment to bind its requirements without
+     * actually having access to the component instance. The instance itself will be injected into the
+     * {@link VirtualInstance} later.
      */
     protected final <C> void withVirtualComponent( final ComponentKey<C> virtualKey )
     {
@@ -194,8 +192,8 @@
     }
 
     /**
-     * Fine-tune the {@link MAEEmbedderBuilder} instance before it is used to create the 
-     * {@link MAEEmbedder} that will be used to load the application components.
+     * Fine-tune the {@link MAEEmbedderBuilder} instance before it is used to create the {@link MAEEmbedder} that will
+     * be used to load the application components.
      */
     protected void configureBuilder( final MAEEmbedderBuilder builder )
         throws MAEException
@@ -203,10 +201,10 @@
     }
 
     /**
-     * Hook allowing application developers access to the {@link MAEEmbedder} just after the registered
-     * external component instances have been injected, but before loading is considered complete.
+     * Hook allowing application developers access to the {@link MAEEmbedder} just after the registered external
+     * component instances have been injected, but before loading is considered complete.
      */
-    protected void afterLoading(MAEEmbedder embedder)
+    protected void afterLoading( final MAEEmbedder embedder )
         throws MAEException
     {
     }
@@ -278,7 +276,7 @@
         if ( provider == null )
         {
             throw new IllegalStateException( "Your application booter: " + getClass().getName()
-                            + " must implement either getVersion() or getVersionProvider()." );
+                + " must implement either getVersion() or getVersionProvider()." );
         }
 
         return provider.getVersion();
diff --git a/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/DefaultProjectLoader.java b/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/DefaultProjectLoader.java
index f53d288..bbfb62f 100644
--- a/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/DefaultProjectLoader.java
+++ b/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/DefaultProjectLoader.java
@@ -85,6 +85,7 @@
                                                             final File... rootPoms )
         throws ProjectToolsException
     {
+        sessionInjector.getRemoteRepositories( session );
         final ProjectBuildingRequest pbr = sessionInjector.getProjectBuildingRequest( session );
 
         try
@@ -217,6 +218,7 @@
     public MavenProject buildProjectInstance( final File pomFile, final ProjectToolsSession session )
         throws ProjectToolsException
     {
+        sessionInjector.getRemoteRepositories( session );
         final ProjectBuildingRequest pbr = sessionInjector.getProjectBuildingRequest( session );
 
         try
diff --git a/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/session/DefaultSessionInjector.java b/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/session/DefaultSessionInjector.java
index de90ce0..9499eee 100644
--- a/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/session/DefaultSessionInjector.java
+++ b/mae-components/mae-project-tools/src/main/java/org/apache/maven/mae/project/session/DefaultSessionInjector.java
@@ -60,6 +60,8 @@
     public synchronized ProjectBuildingRequest getProjectBuildingRequest( final ProjectToolsSession session )
         throws ProjectToolsException
     {
+        getRemoteRepositories( session );
+
         ProjectBuildingRequest pbr = session.getProjectBuildingRequest();
         try
         {