o Added default of ~/.m2/repository for users who don't have ~/.m2/user.xml specified.

git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@163519 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
John Dennis Casey 2005-03-10 16:35:04 +00:00
parent dd2d1738a7
commit 5dc8cb4f33
2 changed files with 30 additions and 16 deletions

View File

@ -345,7 +345,7 @@ public class MavenCli
if ( localRepository == null ) if ( localRepository == null )
{ {
String userConfigurationDirectory = System.getProperty( "user.home" ); String userConfigurationDirectory = System.getProperty( "user.home" ) + "/.m2";
localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath(); localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
} }

View File

@ -190,12 +190,17 @@ public class MBoot
{ {
String userHome = System.getProperty( "user.home" ); String userHome = System.getProperty( "user.home" );
userModelReader.parse( new File( userHome, ".m2/user.xml" ) ); File userXml = new File( userHome, ".m2/user.xml" );
if ( userXml.exists() )
{
userModelReader.parse( userXml );
MavenProfile activeProfile = userModelReader.getActiveMavenProfile(); MavenProfile activeProfile = userModelReader.getActiveMavenProfile();
mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath(); mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath();
} }
}
catch ( Exception e ) catch ( Exception e )
{ {
e.printStackTrace(); e.printStackTrace();
@ -204,18 +209,24 @@ public class MBoot
if ( mavenRepoLocal == null ) if ( mavenRepoLocal == null )
{ {
System.out.println( String userHome = System.getProperty( "user.home" );
"You must have a ~/.m2/user.xml file and must contain at least the following information:\n" ); String m2LocalRepoPath = "/.m2/repository";
System.out.println( File repoDir = new File( userHome, m2LocalRepoPath );
"<userModel>\n " + "<mavenProfiles>\n " + "<mavenProfile>\n " + "<id>someId</id>\n " + if ( !repoDir.exists() )
"<localRepository>/path/to/your/repository</localRepository>\n " + {
"</mavenProfile>\n " + repoDir.mkdirs();
"</mavenProfiles>\n " + }
"<defaultProfiles>\n " +
"<mavenProfileId>someId</mavenProfileId>\n " + mavenRepoLocal = repoDir.getAbsolutePath();
"</defaultProfiles>\n" +
"</userModel>\n" ); 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." ); System.out.println( "where \'someId\' is just an id for matching within the file." );
@ -223,7 +234,10 @@ public class MBoot
System.out.println( "Alternatively, you can specify -Dmaven.repo.local=/path/to/m2/repository" ); 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; String mavenHome = null;