You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2006/02/26 17:08:26 UTC

svn commit: r381114 - in /maven/components/branches/maven-embedder-refactor/maven-core/src/main: java/org/apache/maven/ java/org/apache/maven/cli/ java/org/apache/maven/execution/ resources/META-INF/plexus/

Author: jvanzyl
Date: Sun Feb 26 08:08:25 2006
New Revision: 381114

URL: http://svn.apache.org/viewcvs?rev=381114&view=rev
Log:
o all the artifact repository handling code is now out of the CLI and we're getting closer to a simple recipe
  for a maven request:

            MavenExecutionRequest request = new DefaultMavenExecutionRequest()
                .setBasedir( baseDirectory )
                .setGoals( goals )
                .setLocalRepositoryPath( localRepositoryPath )
                .setProperties( executionProperties )
                .setFailureBehavior( reactorFailureBehaviour )
                .setRecursive( recursive )
                .setReactorActive( reactorActive )
                .setPomFile( alternatePomFile )
                .setShowErrors( showErrors )
                .setInteractive( interactive )
                .addActiveProfiles( activeProfiles )
                .addInactiveProfiles( inactiveProfiles )
                .setLoggingLevel( loggingLevel )
                .activateDefaultEventMonitor()
                .setSettings( settings )
                .setTransferListener( transferListener )
                .setOffline( offline )
                .setUpdateSnapshots( updateSnapshots )
                .setGlobalChecksumPolicy( globalChecksumPolicy );

            maven.execute( request );

  Some things are still a little confused but I'm almost there. Need to clarify the relationship
  between MavenExecutionRequest, MavenSession, Settings and RuntimeInfo. For the Maven internals
  I'm not sure why Settings and RuntimeInfo were made and shouldn't really go past the CLI.


Added:
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java   (with props)
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java   (with props)
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java   (with props)
Modified:
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/Maven.java
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
    maven/components/branches/maven-embedder-refactor/maven-core/src/main/resources/META-INF/plexus/components.xml

Added: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java?rev=381114&view=auto
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java (added)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java Sun Feb 26 08:08:25 2006
@@ -0,0 +1,17 @@
+package org.apache.maven;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.codehaus.plexus.component.repository.exception.ComponentLookupException;
+
+import java.io.File;
+
+/**
+ * @author Jason van Zyl
+ */
+public interface CommonMavenObjectFactory
+{
+     ArtifactRepository createLocalRepository( File localRepositoryPath,
+                                               boolean offline,
+                                               boolean updateSnapshots,
+                                               String globalChecksumPolicy );
+}

Propchange: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/CommonMavenObjectFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java?rev=381114&view=auto
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java (added)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java Sun Feb 26 08:08:25 2006
@@ -0,0 +1,55 @@
+package org.apache.maven;
+
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
+import org.apache.maven.artifact.repository.DefaultArtifactRepository;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
+
+import java.io.File;
+
+/**
+ * A small utility that provides a common place for creating object instances that are used frequently in Maven:
+ * ArtifactRepositories, Artifacts .... A facade for all factories we have lying around. This could very well
+ * belong somewhere else but is here for the maven-embedder-refactor.
+ * 
+ * @author Jason van Zyl
+ */
+public class DefaultCommonMavenObjectFactory
+    implements CommonMavenObjectFactory
+{
+    private ArtifactRepositoryLayout repositoryLayout;
+
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+    public ArtifactRepository createLocalRepository( File localRepositoryPath,
+                                                     boolean offline,
+                                                     boolean updateSnapshots,
+                                                     String globalChecksumPolicy )
+    {
+        String localRepositoryUrl = localRepositoryPath.getAbsolutePath();
+
+        if ( !localRepositoryUrl.startsWith( "file:" ) )
+        {
+            localRepositoryUrl = "file://" + localRepositoryUrl;
+        }
+
+        ArtifactRepository localRepository = new DefaultArtifactRepository( "local", localRepositoryUrl, repositoryLayout );
+
+        boolean snapshotPolicySet = false;
+
+        if ( offline )
+        {
+            snapshotPolicySet = true;
+        }
+
+        if ( !snapshotPolicySet && updateSnapshots )
+        {
+            artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
+        }
+
+        artifactRepositoryFactory.setGlobalChecksumPolicy( globalChecksumPolicy );
+
+        return localRepository;
+    }
+}

Propchange: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultCommonMavenObjectFactory.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=381114&r1=381113&r2=381114&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Sun Feb 26 08:08:25 2006
@@ -28,12 +28,13 @@
 import org.apache.maven.execution.RuntimeInformation;
 import org.apache.maven.lifecycle.LifecycleExecutionException;
 import org.apache.maven.lifecycle.LifecycleExecutor;
-import org.apache.maven.monitor.event.EventDispatcher;
-import org.apache.maven.monitor.event.MavenEvents;
 import org.apache.maven.monitor.event.DefaultEventDispatcher;
 import org.apache.maven.monitor.event.DefaultEventMonitor;
-import org.apache.maven.profiles.ProfileManager;
+import org.apache.maven.monitor.event.EventDispatcher;
+import org.apache.maven.monitor.event.MavenEvents;
+import org.apache.maven.plugin.Mojo;
 import org.apache.maven.profiles.DefaultProfileManager;
+import org.apache.maven.profiles.ProfileManager;
 import org.apache.maven.profiles.activation.ProfileActivationException;
 import org.apache.maven.project.DuplicateProjectException;
 import org.apache.maven.project.MavenProject;
@@ -46,7 +47,6 @@
 import org.apache.maven.settings.Settings;
 import org.apache.maven.usability.SystemWarnings;
 import org.apache.maven.usability.diagnostics.ErrorDiagnostics;
-import org.apache.maven.plugin.Mojo;
 import org.codehaus.plexus.PlexusConstants;
 import org.codehaus.plexus.PlexusContainer;
 import org.codehaus.plexus.component.repository.exception.ComponentLifecycleException;
@@ -54,8 +54,8 @@
 import org.codehaus.plexus.context.Context;
 import org.codehaus.plexus.context.ContextException;
 import org.codehaus.plexus.logging.AbstractLogEnabled;
-import org.codehaus.plexus.logging.LoggerManager;
 import org.codehaus.plexus.logging.Logger;
+import org.codehaus.plexus.logging.LoggerManager;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Contextualizable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
 import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
@@ -101,6 +101,8 @@
 
     protected LoggerManager loggerManager;
 
+    protected CommonMavenObjectFactory mavenObjectFactory;
+
     private static final long MB = 1024 * 1024;
 
     private static final int MS_PER_SEC = 1000;
@@ -114,6 +116,11 @@
     public void execute( MavenExecutionRequest request )
         throws MavenExecutionException
     {
+        request.setLocalRepository( mavenObjectFactory.createLocalRepository( request.getLocalRepositoryPath(),
+                                                                              request.isOffline(),
+                                                                              request.isUpdateSnapshots(),
+                                                                              request.getGlobalChecksumPolicy() ) );
+
         Logger logger = loggerManager.getLoggerForComponent( Mojo.ROLE );
 
         if ( request.isDefaultEventMonitorActive() )
@@ -129,13 +136,16 @@
 
         wagonManager.setDownloadMonitor( request.getTransferListener() );
 
-        EventDispatcher dispatcher = new DefaultEventDispatcher( request.getEventMonitors()  );
+        wagonManager.setOnline( !request.getSettings().isOffline() );
+
+        EventDispatcher dispatcher = new DefaultEventDispatcher( request.getEventMonitors() );
 
         String event = MavenEvents.REACTOR_EXECUTION;
 
         dispatcher.dispatchStart( event, request.getBaseDirectory() );
 
         ReactorManager rm;
+
         try
         {
             rm = doExecute( request, dispatcher );
@@ -378,8 +388,12 @@
         {
             List files = getProjectFiles( request );
 
-            projects = collectProjects( files, request.getLocalRepository(), request.isRecursive(),
-                                        request.getSettings(), globalProfileManager, !request.isReactorActive() );
+            projects = collectProjects( files,
+                                        request.getLocalRepository(),
+                                        request.isRecursive(),
+                                        request.getSettings(),
+                                        globalProfileManager,
+                                        !request.isReactorActive() );
 
         }
         catch ( IOException e )

Modified: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/Maven.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/Maven.java?rev=381114&r1=381113&r2=381114&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/Maven.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/Maven.java Sun Feb 26 08:08:25 2006
@@ -31,6 +31,24 @@
 
     String RELEASE_POMv4 = "release-pom.xml";
 
+    // ----------------------------------------------------------------------
+    // Logging
+    // ----------------------------------------------------------------------
+
+    static final int LOGGING_LEVEL_DEBUG = 0;
+
+    static final int LOGGING_LEVEL_INFO = 1;
+
+    static final int LOGGING_LEVEL_WARN = 2;
+
+    static final int LOGGING_LEVEL_ERROR = 3;
+
+    static final int LOGGING_LEVEL_FATAL = 4;
+
+    static final int LOGGING_LEVEL_DISABLE = 5;
+
+    
+
     void execute( MavenExecutionRequest request )
         throws MavenExecutionException;
 }

Added: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java?rev=381114&view=auto
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java (added)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java Sun Feb 26 08:08:25 2006
@@ -0,0 +1,145 @@
+/*
+ * Copyright (c) 2006 Your Corporation. All Rights Reserved.
+ */
+package org.apache.maven.cli;
+
+import org.apache.commons.cli.Options;
+import org.apache.commons.cli.OptionBuilder;
+import org.apache.commons.cli.CommandLine;
+import org.apache.commons.cli.ParseException;
+import org.apache.commons.cli.CommandLineParser;
+import org.apache.commons.cli.GnuParser;
+import org.apache.commons.cli.HelpFormatter;
+
+/**
+ * @author Jason van Zyl
+ * @version $Revision:$
+ */
+public class CLIManager
+{
+    public static final char ALTERNATE_POM_FILE = 'f';
+
+    public static final char BATCH_MODE = 'B';
+
+    public static final char SET_SYSTEM_PROPERTY = 'D';
+
+    public static final char OFFLINE = 'o';
+
+    public static final char REACTOR = 'r';
+
+    public static final char DEBUG = 'X';
+
+    public static final char ERRORS = 'e';
+
+    public static final char HELP = 'h';
+
+    public static final char VERSION = 'v';
+
+    public static final char NON_RECURSIVE = 'N';
+
+    public static final char UPDATE_SNAPSHOTS = 'U';
+
+    public static final char ACTIVATE_PROFILES = 'P';
+
+    public static final String FORCE_PLUGIN_UPDATES = "cpu";
+
+    public static final String FORCE_PLUGIN_UPDATES2 = "up";
+
+    public static final String SUPPRESS_PLUGIN_UPDATES = "npu";
+
+    public static final String SUPPRESS_PLUGIN_REGISTRY = "npr";
+
+    public static final char CHECKSUM_FAILURE_POLICY = 'C';
+
+    public static final char CHECKSUM_WARNING_POLICY = 'c';
+
+    public static final char ALTERNATE_USER_SETTINGS = 's';
+
+    public static final String FAIL_FAST = "ff";
+
+    public static final String FAIL_AT_END = "fae";
+
+    public static final String FAIL_NEVER = "fn";
+
+    private Options options;
+
+    public CLIManager()
+    {
+        options = new Options();
+
+        options.addOption( OptionBuilder.withLongOpt( "file" ).hasArg().withDescription(
+            "Force the use of an alternate POM file." ).create( ALTERNATE_POM_FILE ) );
+
+        options.addOption(
+            OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create(
+                SET_SYSTEM_PROPERTY ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create(
+                VERSION ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create(
+                DEBUG ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create(
+                ERRORS ) );
+        options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription(
+            "Execute goals for project found in the reactor" ).create( REACTOR ) );
+        options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription(
+            "Do not recurse into sub-projects" ).create( NON_RECURSIVE ) );
+        options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription(
+            "Update all snapshots regardless of repository policies" ).create( UPDATE_SNAPSHOTS ) );
+        options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription(
+            "Comma-delimited list of profiles to activate" ).hasArg().create( ACTIVATE_PROFILES ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription(
+            "Run in non-interactive (batch) mode" ).create( BATCH_MODE ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription(
+            "Force upToDate check for any relevant registered plugins" ).create( FORCE_PLUGIN_UPDATES ) );
+        options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription(
+            "Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) );
+        options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription(
+            "Suppress upToDate check for any relevant registered plugins" ).create( SUPPRESS_PLUGIN_UPDATES ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription(
+            "Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription(
+            "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
+        options.addOption(
+            OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create(
+                CHECKSUM_WARNING_POLICY ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "settings" )
+            .withDescription( "Alternate path for the user settings file" ).hasArg()
+            .create( ALTERNATE_USER_SETTINGS ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription(
+            "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription(
+            "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) );
+
+        options.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription(
+            "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) );
+    }
+
+    public CommandLine parse( String[] args )
+        throws ParseException
+    {
+        CommandLineParser parser = new GnuParser();
+        return parser.parse( options, args );
+    }
+
+    public void displayHelp()
+    {
+        System.out.println();
+
+        HelpFormatter formatter = new HelpFormatter();
+        formatter.printHelp( "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", options, "\n" );
+    }
+}

Propchange: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/CLIManager.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java?rev=381114&r1=381113&r2=381114&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java Sun Feb 26 08:08:25 2006
@@ -17,19 +17,10 @@
  */
 
 import org.apache.commons.cli.CommandLine;
-import org.apache.commons.cli.CommandLineParser;
-import org.apache.commons.cli.GnuParser;
-import org.apache.commons.cli.HelpFormatter;
-import org.apache.commons.cli.OptionBuilder;
-import org.apache.commons.cli.Options;
 import org.apache.commons.cli.ParseException;
 import org.apache.maven.Maven;
 import org.apache.maven.SettingsConfigurationException;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
 import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.DefaultArtifactRepository;
-import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.execution.DefaultMavenExecutionRequest;
 import org.apache.maven.execution.MavenExecutionRequest;
 import org.apache.maven.execution.ReactorManager;
@@ -52,12 +43,13 @@
 import java.util.Properties;
 import java.util.StringTokenizer;
 
+
 /**
  * @author jason van zyl
  * @version $Id$
  * @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE
  * @todo clear strategy for creating local repository
- * @todo clear strategy        
+ * @todo clear strategy
  * @todo clearn strategy for using settings, they are really an artifact of the CLI but people want integration with existing installations
  */
 public class MavenCli
@@ -303,9 +295,14 @@
             // From here we are CLI free
             // ----------------------------------------------------------------------
 
-            //  1. LoggerManager: can get from the container
-            //  2. debug: use to set the threshold on the logger manager
-            //  3. Settings
+            //  -> baseDirectory
+            //  -> goals
+            //  -> debug: use to set the threshold on the logger manager
+            //  -> active profiles (settings)
+            //  -> inactive profiles (settings)
+            //  -> offline (settings)
+            //  -> interactive (settings)
+            //  -> Settings
             //     -> localRepository
             //     -> interactiveMode
             //     -> usePluginRegistry
@@ -316,22 +313,14 @@
             //     -> profiles
             //     -> activeProfiles
             //     -> pluginGroups
-            //  4. ProfileManager
-            //     -> active profiles
-            //     -> inactive profiles
-            //  5. EventDispatcher
-            //  6. baseDirectory
-            //  7. goals
-            //  8. executionProperties
-            //  9. reactorFailureBehaviour: fail fast, fail at end, fail never
-            // 10. globalChecksumPolicy: fail, warn
-            // 11. showErrors (this is really CLI is but used inside Maven internals
-            // 12. recursive
-            // 13. offline
-            // 14. updateSnapshots
-            // 15. reactorActive
-            // 16. transferListener: in the CLI this is batch or console
-            // 17. interactive
+            //  -> executionProperties
+            //  -> reactorFailureBehaviour: fail fast, fail at end, fail never
+            //  -> globalChecksumPolicy: fail, warn
+            //  -> showErrors (this is really CLI is but used inside Maven internals
+            //  -> recursive
+            //  -> updateSnapshots
+            //  -> reactorActive
+            //  -> transferListener: in the CLI this is batch or console
 
             // We have a general problem with plexus components that are singletons in that they use
             // the same logger for their lifespan. This is not good in that many requests may be fired
@@ -340,9 +329,15 @@
 
             Properties executionProperties = getExecutionProperties( commandLine );
 
-            Settings settings = buildSettings( userSettingsPath, interactive, usePluginRegistry, pluginUpdateOverride );
+            Settings settings = buildSettings( userSettingsPath, interactive, offline, usePluginRegistry, pluginUpdateOverride );
+
+            // the local repository should just be a path and we should look here:
+            // in the system property
+            // user specified settings.xml
+            // default ~/.m2/settings.xml
+            // and with that maven internals should contruct the ArtifactRepository object
 
-            ArtifactRepository localRepository = createLocalRepository( settings, offline, updateSnapshots, globalChecksumPolicy );
+            String localRepositoryPath = settings.getLocalRepository();
 
             int loggingLevel;
 
@@ -357,23 +352,31 @@
 
             Maven maven = (Maven) embedder.lookup( Maven.ROLE );
 
+            // @todo we either make Settings the official configuration mechanism or allow the indiviaul setting in the request
+            // for each of the things in the settings object. Seems redundant to configure some things via settings and
+            // some via the request. The Settings object is used in about 16 different places in the core so something
+            // to consider.
+
             MavenExecutionRequest request = new DefaultMavenExecutionRequest()
                 .setBasedir( baseDirectory )
                 .setGoals( goals )
-                .setSettings( settings )
-                .setLocalRepository( localRepository )
+                .setLocalRepositoryPath( localRepositoryPath )
                 .setProperties( executionProperties )
-                .setRecursive( recursive )
                 .setFailureBehavior( reactorFailureBehaviour )
+                .setRecursive( recursive )
                 .setReactorActive( reactorActive )
                 .setPomFile( alternatePomFile )
                 .setShowErrors( showErrors )
                 .setInteractive( interactive )
-                .setTransferListener( transferListener )
                 .addActiveProfiles( activeProfiles )
                 .addInactiveProfiles( inactiveProfiles )
                 .setLoggingLevel( loggingLevel )
-                .activateDefaultEventMonitor();
+                .activateDefaultEventMonitor()
+                .setSettings( settings )
+                .setTransferListener( transferListener )
+                .setOffline( offline )
+                .setUpdateSnapshots( updateSnapshots )
+                .setGlobalChecksumPolicy( globalChecksumPolicy );
 
             maven.execute( request );
         }
@@ -513,177 +516,9 @@
     // Command line manager
     // ----------------------------------------------------------------------
 
-    static class CLIManager
-    {
-        public static final char ALTERNATE_POM_FILE = 'f';
-
-        public static final char BATCH_MODE = 'B';
-
-        public static final char SET_SYSTEM_PROPERTY = 'D';
-
-        public static final char OFFLINE = 'o';
-
-        public static final char REACTOR = 'r';
-
-        public static final char DEBUG = 'X';
-
-        public static final char ERRORS = 'e';
-
-        public static final char HELP = 'h';
-
-        public static final char VERSION = 'v';
-
-        private Options options;
-
-        public static final char NON_RECURSIVE = 'N';
-
-        public static final char UPDATE_SNAPSHOTS = 'U';
-
-        public static final char ACTIVATE_PROFILES = 'P';
-
-        public static final String FORCE_PLUGIN_UPDATES = "cpu";
-
-        public static final String FORCE_PLUGIN_UPDATES2 = "up";
-
-        public static final String SUPPRESS_PLUGIN_UPDATES = "npu";
-
-        public static final String SUPPRESS_PLUGIN_REGISTRY = "npr";
-
-        public static final char CHECKSUM_FAILURE_POLICY = 'C';
-
-        public static final char CHECKSUM_WARNING_POLICY = 'c';
-
-        private static final char ALTERNATE_USER_SETTINGS = 's';
-
-        private static final String FAIL_FAST = "ff";
-
-        private static final String FAIL_AT_END = "fae";
-
-        private static final String FAIL_NEVER = "fn";
-
-        public CLIManager()
-        {
-            options = new Options();
-
-            options.addOption( OptionBuilder.withLongOpt( "file" ).hasArg().withDescription(
-                "Force the use of an alternate POM file." ).create( ALTERNATE_POM_FILE ) );
-
-            options.addOption(
-                OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create(
-                    SET_SYSTEM_PROPERTY ) );
-            options.addOption(
-                OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) );
-            options.addOption(
-                OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) );
-            options.addOption(
-                OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create(
-                    VERSION ) );
-            options.addOption(
-                OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create(
-                    DEBUG ) );
-            options.addOption(
-                OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create(
-                    ERRORS ) );
-            options.addOption( OptionBuilder.withLongOpt( "reactor" ).withDescription(
-                "Execute goals for project found in the reactor" ).create( REACTOR ) );
-            options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription(
-                "Do not recurse into sub-projects" ).create( NON_RECURSIVE ) );
-            options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription(
-                "Update all snapshots regardless of repository policies" ).create( UPDATE_SNAPSHOTS ) );
-            options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription(
-                "Comma-delimited list of profiles to activate" ).hasArg().create( ACTIVATE_PROFILES ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription(
-                "Run in non-interactive (batch) mode" ).create( BATCH_MODE ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription(
-                "Force upToDate check for any relevant registered plugins" ).create( FORCE_PLUGIN_UPDATES ) );
-            options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription(
-                "Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) );
-            options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription(
-                "Suppress upToDate check for any relevant registered plugins" ).create( SUPPRESS_PLUGIN_UPDATES ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription(
-                "Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription(
-                "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) );
-            options.addOption(
-                OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create(
-                    CHECKSUM_WARNING_POLICY ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "settings" )
-                .withDescription( "Alternate path for the user settings file" ).hasArg()
-                .create( ALTERNATE_USER_SETTINGS ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription(
-                "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription(
-                "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) );
-
-            options.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription(
-                "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) );
-        }
-
-        public CommandLine parse( String[] args )
-            throws ParseException
-        {
-            CommandLineParser parser = new GnuParser();
-            return parser.parse( options, args );
-        }
-
-        public void displayHelp()
-        {
-            System.out.println();
-
-            HelpFormatter formatter = new HelpFormatter();
-            formatter.printHelp( "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", options, "\n" );
-        }
-    }
-
-    private static ArtifactRepository createLocalRepository( Settings settings,
-                                                             boolean offline,
-                                                             boolean updateSnapshots,
-                                                             String globalChecksumPolicy )
-        throws ComponentLookupException
-    {
-        // @requirement
-        ArtifactRepositoryLayout repositoryLayout = (ArtifactRepositoryLayout) embedder.lookup( ArtifactRepositoryLayout.ROLE, "default" );
-
-        // @requirement
-        ArtifactRepositoryFactory artifactRepositoryFactory = (ArtifactRepositoryFactory) embedder.lookup( ArtifactRepositoryFactory.ROLE );
-
-        String url = settings.getLocalRepository();
-
-        if ( !url.startsWith( "file:" ) )
-        {
-            url = "file://" + url;
-        }
-
-        ArtifactRepository localRepository = new DefaultArtifactRepository( "local", url, repositoryLayout );
-
-        boolean snapshotPolicySet = false;
-
-        if ( offline )
-        {
-            settings.setOffline( true );
-
-            snapshotPolicySet = true;
-        }
-
-        if ( !snapshotPolicySet && updateSnapshots )
-        {
-            artifactRepositoryFactory.setGlobalUpdatePolicy( ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS );
-        }
-
-        artifactRepositoryFactory.setGlobalChecksumPolicy( globalChecksumPolicy );
-
-        return localRepository;
-    }
-
     private static Settings buildSettings( String userSettingsPath,
                                            boolean interactive,
+                                           boolean offline,
                                            boolean usePluginRegistry,
                                            Boolean pluginUpdateOverride )
         throws ComponentLookupException, SettingsConfigurationException
@@ -691,6 +526,11 @@
         Settings settings = null;
 
         MavenSettingsBuilder settingsBuilder = (MavenSettingsBuilder) embedder.lookup( MavenSettingsBuilder.ROLE );
+
+        if ( offline )
+        {
+            settings.setOffline( true );
+        }
 
         try
         {

Modified: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=381114&r1=381113&r2=381114&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java Sun Feb 26 08:08:25 2006
@@ -16,10 +16,10 @@
  * limitations under the License.
  */
 
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.monitor.event.EventMonitor;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.artifact.repository.ArtifactRepository;
 
 import java.util.Date;
 import java.util.List;
@@ -41,6 +41,8 @@
      */
     private ArtifactRepository localRepository;
 
+    private File localRepositoryPath;
+
     private  List goals;
 
     protected MavenSession session;
@@ -75,6 +77,12 @@
 
     private boolean activateDefaultEventMonitor;
 
+    private boolean offline;
+
+    private boolean updateSnapshots;
+
+    private String globalChecksumPolicy;
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -99,6 +107,11 @@
         return localRepository;
     }
 
+    public File getLocalRepositoryPath()
+    {
+        return localRepositoryPath;
+    }
+
     public List getGoals()
     {
         return goals;
@@ -174,6 +187,21 @@
         return activateDefaultEventMonitor;
     }
 
+    public boolean isOffline()
+    {
+        return offline;
+    }
+
+    public boolean isUpdateSnapshots()
+    {
+        return updateSnapshots;
+    }
+
+    public String getGlobalChecksumPolicy()
+    {
+        return globalChecksumPolicy;
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -220,6 +248,20 @@
         return this;
     }
 
+    public MavenExecutionRequest setLocalRepositoryPath( File localRepository )
+    {
+        this.localRepositoryPath = localRepository;
+
+        return this;
+    }
+
+    public MavenExecutionRequest setLocalRepositoryPath( String localRepository )
+    {
+        this.localRepositoryPath = new File( localRepository );
+
+        return this;
+    }
+
     public MavenExecutionRequest setProperties( Properties properties )
     {
         this.properties = properties;
@@ -352,6 +394,27 @@
     public MavenExecutionRequest setLoggingLevel( int loggingLevel )
     {
         this.loggingLevel = loggingLevel;
+
+        return this;
+    }
+
+    public MavenExecutionRequest setOffline( boolean offline )
+    {
+        this.offline = offline;
+
+        return this;
+    }
+
+    public MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots )
+    {
+        this.updateSnapshots = updateSnapshots;
+
+        return this;
+    }
+
+    public MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy )
+    {
+        this.globalChecksumPolicy = globalChecksumPolicy;
 
         return this;
     }

Modified: maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=381114&r1=381113&r2=381114&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java Sun Feb 26 08:08:25 2006
@@ -16,10 +16,10 @@
  * limitations under the License.
  */
 
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.monitor.event.EventMonitor;
 import org.apache.maven.settings.Settings;
 import org.apache.maven.wagon.events.TransferListener;
+import org.apache.maven.artifact.repository.ArtifactRepository;
 
 import java.io.File;
 import java.util.Date;
@@ -32,6 +32,8 @@
  */
 public interface MavenExecutionRequest
 {
+    File getLocalRepositoryPath();
+
     ArtifactRepository getLocalRepository();
 
     List getGoals();
@@ -68,6 +70,12 @@
 
     boolean isDefaultEventMonitorActive();
 
+    boolean isOffline();
+
+    boolean isUpdateSnapshots();
+
+    String getGlobalChecksumPolicy();
+
     // ----------------------------------------------------------------------
     // Logging
     // ----------------------------------------------------------------------
@@ -85,6 +93,16 @@
     static final int LOGGING_LEVEL_DISABLE = 5;
 
     // ----------------------------------------------------------------------
+    // Reactor Failure Mode
+    // ----------------------------------------------------------------------
+
+    static final int REACTOR_FAIL_FAST = 0;
+
+    static final int REACTOR_FAIL_END = 1;
+
+    static final int REACTOR_FAIL_NEVER = 2;
+
+    // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
 
@@ -98,6 +116,10 @@
 
     MavenExecutionRequest setLocalRepository( ArtifactRepository localRepository );
 
+    MavenExecutionRequest setLocalRepositoryPath( String localRepository );
+
+    MavenExecutionRequest setLocalRepositoryPath( File localRepository );
+
     MavenExecutionRequest setProperties( Properties properties );
 
     MavenExecutionRequest setFailureBehavior( String failureBehavior );
@@ -129,4 +151,10 @@
     MavenExecutionRequest setLoggingLevel( int loggingLevel );
 
     MavenExecutionRequest activateDefaultEventMonitor();
+
+    MavenExecutionRequest setOffline( boolean offline );
+
+    MavenExecutionRequest setUpdateSnapshots( boolean updateSnapshots );
+
+    MavenExecutionRequest setGlobalChecksumPolicy( String globalChecksumPolicy );
 }

Modified: maven/components/branches/maven-embedder-refactor/maven-core/src/main/resources/META-INF/plexus/components.xml
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-core/src/main/resources/META-INF/plexus/components.xml?rev=381114&r1=381113&r2=381114&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-core/src/main/resources/META-INF/plexus/components.xml (original)
+++ maven/components/branches/maven-embedder-refactor/maven-core/src/main/resources/META-INF/plexus/components.xml Sun Feb 26 08:08:25 2006
@@ -67,6 +67,21 @@
      |
      |
      -->
+
+    <component>
+      <role>org.apache.maven.CommonMavenObjectFactory</role>
+      <implementation>org.apache.maven.DefaultCommonMavenObjectFactory</implementation>
+      <requirements>
+        <requirement>
+          <role>org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout</role>
+          <role-hint>default</role-hint>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.artifact.repository.ArtifactRepositoryFactory</role>
+        </requirement>
+      </requirements>
+    </component>
+
     <component>
       <role>org.apache.maven.Maven</role>
       <implementation>org.apache.maven.DefaultMaven</implementation>
@@ -85,6 +100,9 @@
         </requirement>
         <requirement>
           <role>org.apache.maven.artifact.manager.WagonManager</role>
+        </requirement>
+        <requirement>
+          <role>org.apache.maven.CommonMavenObjectFactory</role>
         </requirement>
       </requirements>
     </component>