mirror of https://github.com/apache/maven.git
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:
parent
dd2d1738a7
commit
5dc8cb4f33
|
@ -345,7 +345,7 @@ public class MavenCli
|
|||
|
||||
if ( localRepository == null )
|
||||
{
|
||||
String userConfigurationDirectory = System.getProperty( "user.home" );
|
||||
String userConfigurationDirectory = System.getProperty( "user.home" ) + "/.m2";
|
||||
localRepository = new File( userConfigurationDirectory, MavenConstants.MAVEN_REPOSITORY ).getAbsolutePath();
|
||||
}
|
||||
|
||||
|
|
|
@ -190,12 +190,17 @@ public class MBoot
|
|||
{
|
||||
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();
|
||||
|
||||
mavenRepoLocal = new File( activeProfile.getLocalRepo() ).getAbsolutePath();
|
||||
}
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
@ -204,18 +209,24 @@ public class MBoot
|
|||
|
||||
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 @@ public class MBoot
|
|||
|
||||
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;
|
||||
|
|
Loading…
Reference in New Issue