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/04/05 01:04:35 UTC

svn commit: r391439 - in /maven/components/branches/maven-embedder-refactor: maven-cli/ maven-cli/src/main/java/org/apache/maven/cli/ maven-embedder/ maven-embedder/src/main/java/org/apache/maven/embedder/ maven-tools/src/main/java/org/apache/maven/

Author: jvanzyl
Date: Tue Apr  4 16:04:33 2006
New Revision: 391439

URL: http://svn.apache.org/viewcvs?rev=391439&view=rev
Log:
o adding plexus-utils and classworlds to the cli POM to make sure the assembly is created with the right versions
  of each
o pushing some more sharable code to MavenTools
o accessing the new shared code via the embedder which is used in the CLI

Modified:
    maven/components/branches/maven-embedder-refactor/maven-cli/pom.xml
    maven/components/branches/maven-embedder-refactor/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java
    maven/components/branches/maven-embedder-refactor/maven-embedder/pom.xml
    maven/components/branches/maven-embedder-refactor/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
    maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java
    maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/MavenTools.java

Modified: maven/components/branches/maven-embedder-refactor/maven-cli/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-cli/pom.xml?rev=391439&r1=391438&r2=391439&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-cli/pom.xml (original)
+++ maven/components/branches/maven-embedder-refactor/maven-cli/pom.xml Tue Apr  4 16:04:33 2006
@@ -22,6 +22,16 @@
   </build>
   <dependencies>
     <dependency>
+      <groupId>classworlds</groupId>
+      <artifactId>classworlds</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.1</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-embedder</artifactId>
       <version>2.1-SNAPSHOT</version>

Modified: maven/components/branches/maven-embedder-refactor/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java?rev=391439&r1=391438&r2=391439&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java Tue Apr  4 16:04:33 2006
@@ -43,32 +43,6 @@
  */
 public class MavenCli
 {
-    public static final String userHome = System.getProperty( "user.home" );
-
-    public static final File userMavenConfigurationHome = new File( userHome, ".m2" );
-
-    public static final String mavenHome = System.getProperty( "maven.home" );
-
-    // ----------------------------------------------------------------------
-    // Settings
-    // ----------------------------------------------------------------------
-
-    public static final File defaultUserSettingsFile = new File( userMavenConfigurationHome, "settings.xml" );
-
-    public static final File defaultGlobalSettingsFile = new File( mavenHome, "conf/settings.xml" );
-
-    public static final String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings";
-
-    public static final String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings";
-
-    // ----------------------------------------------------------------------
-    // Local Repository
-    // ----------------------------------------------------------------------
-
-    public static final String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
-
-    public static final File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" );
-
     /**
      * @noinspection ConfusingMainMethod
      */
@@ -355,10 +329,10 @@
             }
 
             Properties executionProperties = getExecutionProperties( commandLine );
+            
+            File userSettingsPath = mavenEmbedder.getUserSettingsPath( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) );
 
-            File userSettingsPath = getUserSettingsPath( commandLine );
-
-            File globalSettingsFile = getGlobalSettingsPath();
+            File globalSettingsFile = mavenEmbedder.getGlobalSettingsPath();
 
             Settings settings = mavenEmbedder.buildSettings( userSettingsPath,
                                                              globalSettingsFile,
@@ -367,7 +341,7 @@
                                                              usePluginRegistry,
                                                              pluginUpdateOverride );
 
-            String localRepositoryPath = getLocalRepositoryPath( settings );
+            String localRepositoryPath = mavenEmbedder.getLocalRepositoryPath( settings );
 
             // @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
@@ -523,78 +497,5 @@
         // ----------------------------------------------------------------------
 
         System.setProperty( name, value );
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    /**
-     * Retrieve the user settings path using the followiwin search pattern:
-     * <p/>
-     * 1. System Property
-     * 2. CLI Option
-     * 3. ${user.home}/.m2/settings.xml
-     */
-    public static File getUserSettingsPath( CommandLine commandLine )
-    {
-        File userSettingsPath = new File( System.getProperty( ALT_USER_SETTINGS_XML_LOCATION ) + "" );
-
-        if ( !userSettingsPath.exists() )
-        {
-            if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) )
-            {
-                userSettingsPath = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) );
-            }
-            else
-            {
-                userSettingsPath = defaultUserSettingsFile;
-            }
-        }
-
-        return userSettingsPath;
-    }
-
-    /**
-     * Retrieve the global settings path using the followiwin search pattern:
-     * <p/>
-     * 1. System Property
-     * 2. CLI Option
-     * 3. ${maven.home}/conf/settings.xml
-     */
-    public static File getGlobalSettingsPath()
-    {
-        File globalSettingsFile = new File( System.getProperty( ALT_GLOBAL_SETTINGS_XML_LOCATION ) + "" );
-
-        if ( !globalSettingsFile.exists() )
-        {
-            globalSettingsFile = defaultGlobalSettingsFile;
-        }
-
-        return globalSettingsFile;
-    }
-
-    /**
-     * Retrieve the local repository path using the followiwin search pattern:
-     * <p/>
-     * 1. System Property
-     * 2. localRepository specified in user settings file
-     * 3. ${user.home}/.m2/repository
-     */
-    public static String getLocalRepositoryPath( Settings settings )
-    {
-        String localRepositoryPath = System.getProperty( ALT_LOCAL_REPOSITORY_LOCATION );
-
-        if ( localRepositoryPath == null )
-        {
-            localRepositoryPath = settings.getLocalRepository();
-        }
-
-        if ( localRepositoryPath == null )
-        {
-            localRepositoryPath = defaultUserLocalRepository.getAbsolutePath();
-        }
-
-        return localRepositoryPath;
     }
 }

Modified: maven/components/branches/maven-embedder-refactor/maven-embedder/pom.xml
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-embedder/pom.xml?rev=391439&r1=391438&r2=391439&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-embedder/pom.xml (original)
+++ maven/components/branches/maven-embedder-refactor/maven-embedder/pom.xml Tue Apr  4 16:04:33 2006
@@ -24,12 +24,12 @@
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-core</artifactId>
-      <version>${mavenVersion}</version>
+      <version>2.1-SNAPSHOT</version>
     </dependency>
     <dependency>
       <groupId>org.apache.maven</groupId>
       <artifactId>maven-tools</artifactId>
-      <version>${mavenVersion}</version>
+      <version>2.1-SNAPSHOT</version>
     </dependency>
   </dependencies>
   <reporting>
@@ -48,7 +48,4 @@
       </plugin>
     </plugins>
   </reporting>
-  <properties>
-    <mavenVersion>2.1-SNAPSHOT</mavenVersion>
-  </properties>
 </project>

Modified: maven/components/branches/maven-embedder-refactor/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java?rev=391439&r1=391438&r2=391439&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-embedder/src/main/java/org/apache/maven/embedder/MavenEmbedder.java Tue Apr  4 16:04:33 2006
@@ -634,4 +634,19 @@
                                                  usePluginRegistry,
                                                  pluginUpdateOverride );
     }
+
+    public File getUserSettingsPath( String optionalSettingsPath )
+    {
+        return mavenTools.getUserSettingsPath( optionalSettingsPath );
+    }
+
+    public File getGlobalSettingsPath()
+    {
+        return mavenTools.getGlobalSettingsPath();
+    }
+
+    public String getLocalRepositoryPath( Settings settings )
+    {
+        return mavenTools.getLocalRepositoryPath( settings );
+    }
 }

Modified: maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java?rev=391439&r1=391438&r2=391439&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/DefaultMavenTools.java Tue Apr  4 16:04:33 2006
@@ -28,10 +28,6 @@
 import java.util.Iterator;
 
 /**
- * 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 DefaultMavenTools
@@ -242,6 +238,92 @@
                 "\' for remote repository with id: \'" + mavenRepo.getId() + "\'.", e );
         }
         return repositoryLayout;
+    }
+
+    // ----------------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------------
+
+    /**
+     * Retrieve the user settings path using the followiwin search pattern:
+     * <p/>
+     * 1. System Property
+     * 2. Optional path
+     * 3. ${user.home}/.m2/settings.xml
+     */
+    public File getUserSettingsPath( String optionalSettingsPath )
+    {
+
+
+        
+
+        File userSettingsPath = new File( System.getProperty( ALT_USER_SETTINGS_XML_LOCATION ) + "" );
+
+        if ( !userSettingsPath.exists() )
+        {
+            if ( optionalSettingsPath != null )
+            {
+                File optionalSettingsPathFile = new File( optionalSettingsPath );
+
+                if ( optionalSettingsPathFile.exists() )
+                {
+                    userSettingsPath = optionalSettingsPathFile;
+                }
+                else
+                {
+                    userSettingsPath = defaultUserSettingsFile;
+                }
+            }
+            else
+            {
+                userSettingsPath = defaultUserSettingsFile;
+            }
+        }
+
+        return userSettingsPath;
+    }
+
+    /**
+     * Retrieve the global settings path using the followiwin search pattern:
+     * <p/>
+     * 1. System Property
+     * 2. CLI Option
+     * 3. ${maven.home}/conf/settings.xml
+     */
+    public File getGlobalSettingsPath()
+    {
+        File globalSettingsFile = new File( System.getProperty( ALT_GLOBAL_SETTINGS_XML_LOCATION ) + "" );
+
+        if ( !globalSettingsFile.exists() )
+        {
+            globalSettingsFile = defaultGlobalSettingsFile;
+        }
+
+        return globalSettingsFile;
+    }
+
+    /**
+     * Retrieve the local repository path using the followiwin search pattern:
+     * <p/>
+     * 1. System Property
+     * 2. localRepository specified in user settings file
+     * 3. ${user.home}/.m2/repository
+     */
+    public String getLocalRepositoryPath( Settings settings )
+    {
+        String localRepositoryPath = System.getProperty( ALT_LOCAL_REPOSITORY_LOCATION );
+
+        if ( localRepositoryPath == null )
+        {
+            localRepositoryPath = settings.getLocalRepository();
+        }
+
+        if ( localRepositoryPath == null )
+        {
+            localRepositoryPath = defaultUserLocalRepository.getAbsolutePath();
+        }
+
+        return localRepositoryPath;
     }
 
     // ----------------------------------------------------------------------------

Modified: maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/MavenTools.java
URL: http://svn.apache.org/viewcvs/maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/MavenTools.java?rev=391439&r1=391438&r2=391439&view=diff
==============================================================================
--- maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/MavenTools.java (original)
+++ maven/components/branches/maven-embedder-refactor/maven-tools/src/main/java/org/apache/maven/MavenTools.java Tue Apr  4 16:04:33 2006
@@ -16,7 +16,37 @@
  */
 public interface MavenTools
 {
-    static String ROLE = MavenTools.class.getName();
+    String ROLE = MavenTools.class.getName();
+
+    String userHome = System.getProperty( "user.home" );
+
+    File userMavenConfigurationHome = new File( userHome, ".m2" );
+
+    String mavenHome = System.getProperty( "maven.home" );
+
+    // ----------------------------------------------------------------------
+    // Settings
+    // ----------------------------------------------------------------------
+
+    File defaultUserSettingsFile = new File( userMavenConfigurationHome, "settings.xml" );
+
+    File defaultGlobalSettingsFile = new File( mavenHome, "conf/settings.xml" );
+
+    String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings";
+
+    String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings";
+
+    // ----------------------------------------------------------------------
+    // Local Repository
+    // ----------------------------------------------------------------------
+
+    String ALT_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
+
+    File defaultUserLocalRepository = new File( userMavenConfigurationHome, "repository" );
+
+    // ----------------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------------
 
     ArtifactRepository createLocalRepository( File localRepositoryPath,
                                               boolean offline,
@@ -37,6 +67,20 @@
                             boolean usePluginRegistry,
                             Boolean pluginUpdateOverride )
         throws SettingsConfigurationException;
+
+    // ----------------------------------------------------------------------------
+    // Methods taken from CLI
+    // ----------------------------------------------------------------------------
+
+    File getUserSettingsPath( String optionalSettingsPath );
+
+    File getGlobalSettingsPath();
+
+    String getLocalRepositoryPath( Settings settings );
+
+    // ----------------------------------------------------------------------------
+    // Methods taken from ProjectUtils
+    // ----------------------------------------------------------------------------
 
     List buildArtifactRepositories( List repositories )
         throws InvalidRepositoryException;