From 385b7c96ae6576712a6c9a8b4486f4c8c58f2eed Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Sat, 18 Jun 2005 22:38:49 +0000 Subject: [PATCH] PR: MNG-487 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@191309 13f79535-47bb-0310-9956-ffa450edef68 --- maven-settings/settings.mdo | 34 +++++++++++++++ .../settings/DefaultMavenSettingsBuilder.java | 41 ++++++++++++++++--- 2 files changed, 70 insertions(+), 5 deletions(-) diff --git a/maven-settings/settings.mdo b/maven-settings/settings.mdo index 6d8cc5f988..08808e5478 100644 --- a/maven-settings/settings.mdo +++ b/maven-settings/settings.mdo @@ -264,6 +264,33 @@ return match; } + private Map profileMap; + + public void flushProfileMap() + { + this.profileMap = null; + } + + public Map getProfilesAsMap() + { + if ( profileMap == null ) + { + profileMap = new HashMap(); + + if ( getProfiles() != null ) + { + for ( Iterator it = getProfiles().iterator(); it.hasNext(); ) + { + Profile profile = (Profile) it.next(); + + profileMap.put( profile.getId(), profile ); + } + } + } + + return profileMap; + } + private RuntimeInfo runtimeInfo; public void setRuntimeInfo( RuntimeInfo runtimeInfo ) @@ -465,6 +492,13 @@ Activation + + localRepository + 1.0.0 + String + backwards-compatible location for specifying the local repository for use in builds + THIS IS DEPRECATED: use localRepository under the root element instead. + properties Extended configuration specific to this profile goes diff --git a/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java b/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java index e6c2fdbd38..b6ae6a6bf3 100644 --- a/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java +++ b/maven-settings/src/main/java/org/apache/maven/settings/DefaultMavenSettingsBuilder.java @@ -26,6 +26,8 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException; import java.io.File; import java.io.FileReader; import java.io.IOException; +import java.util.Iterator; +import java.util.List; /** * @author jdcasey @@ -115,16 +117,47 @@ public class DefaultMavenSettingsBuilder SettingsUtils.merge( userSettings, globalSettings, TrackableBase.GLOBAL_LEVEL ); + setLocalRepository( userSettings ); + + return userSettings; + } + + private void setLocalRepository( Settings userSettings ) + { // try using the local repository specified on the command line... String localRepository = System.getProperty( MavenSettingsBuilder.ALT_LOCAL_REPOSITORY_LOCATION ); - + // otherwise, use the one in settings.xml if ( localRepository == null || localRepository.length() < 1 ) { localRepository = userSettings.getLocalRepository(); } - - // if both are missing, default to ~/.m2/repository. + + // this is a backward compatibility feature... + if ( localRepository == null || localRepository.length() < 1 ) + { + List profiles = userSettings.getProfiles(); + + for ( Iterator it = profiles.iterator(); it.hasNext(); ) + { + Profile profile = (Profile) it.next(); + + localRepository = profile.getLocalRepository(); + + if ( localRepository != null && localRepository.length() > 0 ) + { + getLogger().warn( + "DEPRECATED: Please specify the local repository as:\n\n" + + "\n " + localRepository + "" + + "\n ...\n\n" ); + + // we've found it! so stop looking through the profiles... + break; + } + } + } + + // if all of the above are missing, default to ~/.m2/repository. if ( localRepository == null || localRepository.length() < 1 ) { File mavenUserConfigurationDirectory = new File( userHome, ".m2" ); @@ -140,8 +173,6 @@ public class DefaultMavenSettingsBuilder } userSettings.setLocalRepository( localRepository ); - - return userSettings; } private File getFile( String pathPattern, String basedirSysProp, String altLocationSysProp )