maven-m2-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdca...@apache.org
Subject cvs commit: maven-components/maven-core/src/main/java/org/apache/maven/cli MavenCli.java
Date Thu, 10 Mar 2005 16:35:04 GMT
jdcasey     2005/03/10 08:35:04

  Modified:    maven-mboot2/src/main/java MBoot.java
               maven-core/src/main/java/org/apache/maven/cli MavenCli.java
  Log:
  o Added default of ~/.m2/repository for users who don't have ~/.m2/user.xml specified.
  
  Revision  Changes    Path
  1.63      +29 -15    maven-components/maven-mboot2/src/main/java/MBoot.java
  
  Index: MBoot.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-mboot2/src/main/java/MBoot.java,v
  retrieving revision 1.62
  retrieving revision 1.63
  diff -u -r1.62 -r1.63
  --- MBoot.java	10 Mar 2005 07:35:38 -0000	1.62
  +++ MBoot.java	10 Mar 2005 16:35:03 -0000	1.63
  @@ -190,11 +190,16 @@
               {
                   String userHome = System.getProperty( "user.home" );
   
  -                userModelReader.parse( new File( userHome, ".m2/user.xml" ) );
  +                File userXml = new File( userHome, ".m2/user.xml" );
   
  -                MavenProfile activeProfile = userModelReader.getActiveMavenProfile();
  +                if ( userXml.exists() )
  +                {
  +                    userModelReader.parse( userXml );
  +
  +                    MavenProfile activeProfile = userModelReader.getActiveMavenProfile();
   
  -                mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath();
  +                    mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath();
  +                }
               }
               catch ( Exception e )
               {
  @@ -204,18 +209,24 @@
   
           if ( mavenRepoLocal == null )
           {
  -            System.out.println(
  -                "You must have a ~/.m2/user.xml file and must contain at least the following
information:\n" );
  +            String userHome = System.getProperty( "user.home" );
  +            String m2LocalRepoPath = "/.m2/repository";
   
  -            System.out.println(
  -                "<userModel>\n  " + "<mavenProfiles>\n    " + "<mavenProfile>\n
     " + "<id>someId</id>\n      " +
  -                "<localRepository>/path/to/your/repository</localRepository>\n
   " +
  -                "</mavenProfile>\n  " +
  -                "</mavenProfiles>\n  " +
  -                "<defaultProfiles>\n    " +
  -                "<mavenProfileId>someId</mavenProfileId>\n  " +
  -                "</defaultProfiles>\n" +
  -                "</userModel>\n" );
  +            File repoDir = new File( userHome, m2LocalRepoPath );
  +            if ( !repoDir.exists() )
  +            {
  +                repoDir.mkdirs();
  +            }
  +
  +            mavenRepoLocal = repoDir.getAbsolutePath();
  +
  +            System.out
  +                      .println( "You SHOULD have a ~/.m2/user.xml file and must contain
at least the following information:\n" );
  +
  +            System.out.println( "<userModel>\n  " + "<mavenProfiles>\n    "
+ "<mavenProfile>\n      "
  +                + "<id>someId</id>\n      " + "<localRepository>/path/to/your/repository</localRepository>\n
   "
  +                + "</mavenProfile>\n  " + "</mavenProfiles>\n  " + "<defaultProfiles>\n
   "
  +                + "<mavenProfileId>someId</mavenProfileId>\n  " + "</defaultProfiles>\n"
+ "</userModel>\n" );
   
               System.out.println( "where \'someId\' is just an id for matching within the
file." );
   
  @@ -223,7 +234,10 @@
   
               System.out.println( "Alternatively, you can specify -Dmaven.repo.local=/path/to/m2/repository"
);
   
  -            System.exit( 1 );
  +            System.out.println();
  +
  +            System.out.println( "HOWEVER, since you did not specify a repository path,
maven will use: "
  +                + repoDir.getAbsolutePath() + " to store artifacts locally." );
           }
   
           String mavenHome = null;
  
  
  
  1.17      +2 -2      maven-components/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java
  
  Index: MavenCli.java
  ===================================================================
  RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/cli/MavenCli.java,v
  retrieving revision 1.16
  retrieving revision 1.17
  diff -u -r1.16 -r1.17
  --- MavenCli.java	9 Mar 2005 22:13:06 -0000	1.16
  +++ MavenCli.java	10 Mar 2005 16:35:04 -0000	1.17
  @@ -345,7 +345,7 @@
   
           if ( localRepository == null )
           {
  -            String userConfigurationDirectory = System.getProperty( "user.home" );
  +            String userConfigurationDirectory = System.getProperty( "user.home" ) + "/.m2";
               localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY
).getAbsolutePath();
           }
   
  
  
  

Mime
View raw message