mirror of https://github.com/apache/maven.git
o Re-adding support for user-level settings which are not assumed to be in ~ (for continuum and other server-style apps' convenience)
o Adding support for global (installation-level) settings.xml file which is identical to the one in ~/.m2, and which will be overridden by user-level settings. The default location for this is ${maven.home}/settings.xml. o Adding IT to test merging of global- and user-level settings.xml files o Moved DefaultMavenSettingsBuilder/MavenSettingsBuilder to maven-settings project, to make them more generally available (to ant, for instance) Resolves issue: MNG-294 git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@190517 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
eb0a46b6bb
commit
ce3665851c
|
@ -81,6 +81,8 @@ it0024: Test usage of <executions/> inside a plugin rather than <goals/>
|
|||
|
||||
it0025: Test multiple goal executions with different execution-level configs.
|
||||
|
||||
it0026: Test merging of global- and user-level settings.xml files.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
- generated sources
|
||||
|
|
|
@ -24,3 +24,4 @@ it0022
|
|||
it0023
|
||||
it0024
|
||||
it0025
|
||||
it0026
|
||||
|
|
|
@ -1 +1 @@
|
|||
org.apache.maven.SettingsXmlFile=settings.xml
|
||||
org.apache.maven.user-settings=settings.xml
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
target/test.txt
|
|
@ -0,0 +1,17 @@
|
|||
<settings>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>test-profile</id>
|
||||
|
||||
<activation>
|
||||
<property>
|
||||
<name>includeProfile</name>
|
||||
</property>
|
||||
</activation>
|
||||
|
||||
<properties>
|
||||
<test>test.txt</test>
|
||||
</properties>
|
||||
</profile>
|
||||
</profiles>
|
||||
</settings>
|
|
@ -0,0 +1 @@
|
|||
core-it:touch
|
|
@ -0,0 +1,24 @@
|
|||
<model>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven.</groupId>
|
||||
<artifactId>maven-it0023</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-core-it-plugin</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<configuration>
|
||||
<pluginItem>${test}</pluginItem>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<!-- plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-projecthelp-plugin</artifactId>
|
||||
<version>2.0-alpha-3-SNAPSHOT</version>
|
||||
</plugin -->
|
||||
</plugins>
|
||||
</build>
|
||||
</model>
|
|
@ -0,0 +1,16 @@
|
|||
package org.apache.maven.it0023;
|
||||
|
||||
public class Person
|
||||
{
|
||||
private String name;
|
||||
|
||||
public void setName( String name )
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,2 @@
|
|||
org.apache.maven.user-settings=user-settings.xml
|
||||
org.apache.maven.global-settings=global-settings.xml
|
|
@ -0,0 +1,5 @@
|
|||
<settings>
|
||||
<activeProfiles>
|
||||
<activeProfile>test-profile</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
|
@ -41,7 +41,7 @@ import org.apache.maven.settings.Mirror;
|
|||
import org.apache.maven.settings.Proxy;
|
||||
import org.apache.maven.settings.Server;
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.SettingsConversionUtils;
|
||||
import org.apache.maven.settings.SettingsUtils;
|
||||
import org.apache.maven.usability.ErrorDiagnoser;
|
||||
import org.codehaus.plexus.PlexusConstants;
|
||||
import org.codehaus.plexus.PlexusContainer;
|
||||
|
@ -336,7 +336,7 @@ public class DefaultMaven
|
|||
{
|
||||
org.apache.maven.settings.Profile rawProfile = (org.apache.maven.settings.Profile) it.next();
|
||||
|
||||
Profile profile = SettingsConversionUtils.convertFromSettingsProfile( rawProfile );
|
||||
Profile profile = SettingsUtils.convertFromSettingsProfile( rawProfile );
|
||||
|
||||
if( settingsActiveProfileIds.contains( rawProfile.getId() ) )
|
||||
{
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.modello</groupId>
|
||||
<artifactId>modello-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-3-SNAPSHOT</version>
|
||||
<version>1.0-alpha-2</version>
|
||||
<goals>
|
||||
<goal>
|
||||
<id>xpp3-writer</id>
|
||||
|
|
|
@ -125,6 +125,11 @@
|
|||
<version>1.0.0</version>
|
||||
<code><![CDATA[
|
||||
private Proxy activeProxy;
|
||||
|
||||
public void flushActiveProxy()
|
||||
{
|
||||
this.activeProxy = null;
|
||||
}
|
||||
|
||||
public synchronized Proxy getActiveProxy()
|
||||
{
|
||||
|
@ -155,6 +160,102 @@
|
|||
|
||||
return activeProxy;
|
||||
}
|
||||
|
||||
private Map mirrorMap;
|
||||
|
||||
public void flushMirrorMap()
|
||||
{
|
||||
this.mirrorMap = null;
|
||||
}
|
||||
|
||||
public Map getMirrorsAsMap()
|
||||
{
|
||||
if ( mirrorMap == null )
|
||||
{
|
||||
mirrorMap = new HashMap();
|
||||
|
||||
for ( Iterator it = getMirrors().iterator(); it.hasNext(); )
|
||||
{
|
||||
Mirror mirror = (Mirror) it.next();
|
||||
|
||||
mirrorMap.put( mirror.getId(), mirror );
|
||||
}
|
||||
}
|
||||
|
||||
return mirrorMap;
|
||||
}
|
||||
|
||||
private Map serverMap;
|
||||
|
||||
public void flushServerMap()
|
||||
{
|
||||
this.serverMap = null;
|
||||
}
|
||||
|
||||
public Map getServersAsMap()
|
||||
{
|
||||
if ( serverMap == null )
|
||||
{
|
||||
serverMap = new HashMap();
|
||||
|
||||
for ( Iterator it = getServers().iterator(); it.hasNext(); )
|
||||
{
|
||||
Server server = (Server) it.next();
|
||||
|
||||
serverMap.put( server.getId(), server );
|
||||
}
|
||||
}
|
||||
|
||||
return serverMap;
|
||||
}
|
||||
|
||||
private Map proxyMap;
|
||||
|
||||
public void flushProxyMap()
|
||||
{
|
||||
this.proxyMap = null;
|
||||
}
|
||||
|
||||
public Map getProxiesAsMap()
|
||||
{
|
||||
if ( proxyMap == null )
|
||||
{
|
||||
proxyMap = new HashMap();
|
||||
|
||||
for ( Iterator it = getProxies().iterator(); it.hasNext(); )
|
||||
{
|
||||
Proxy proxy = (Proxy) it.next();
|
||||
|
||||
proxyMap.put( proxy.getId(), proxy );
|
||||
}
|
||||
}
|
||||
|
||||
return proxyMap;
|
||||
}
|
||||
|
||||
private Map profileMap;
|
||||
|
||||
public void flushProfileMap()
|
||||
{
|
||||
this.profileMap = null;
|
||||
}
|
||||
|
||||
public Map getProfilesAsMap()
|
||||
{
|
||||
if ( profileMap == null )
|
||||
{
|
||||
profileMap = new HashMap();
|
||||
|
||||
for ( Iterator it = getProfiles().iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile profile = (Profile) it.next();
|
||||
|
||||
profileMap.put( profile.getId(), profile );
|
||||
}
|
||||
}
|
||||
|
||||
return profileMap;
|
||||
}
|
||||
|
||||
public Server getServer( String serverId )
|
||||
{
|
||||
|
@ -236,6 +337,12 @@
|
|||
<name>Proxy</name>
|
||||
<version>1.0.0</version>
|
||||
<fields>
|
||||
<field>
|
||||
<name>id</name>
|
||||
<required>true</required>
|
||||
<default>default</default>
|
||||
<type>String</type>
|
||||
</field>
|
||||
<field>
|
||||
<name>active</name>
|
||||
<version>1.0.0</version>
|
||||
|
|
|
@ -16,7 +16,6 @@ package org.apache.maven.settings;
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import org.apache.maven.settings.Settings;
|
||||
import org.apache.maven.settings.io.xpp3.SettingsXpp3Reader;
|
||||
import org.codehaus.plexus.logging.AbstractLogEnabled;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
|
@ -25,7 +24,6 @@ import org.codehaus.plexus.util.StringUtils;
|
|||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -42,9 +40,16 @@ public class DefaultMavenSettingsBuilder
|
|||
/**
|
||||
* @configuration
|
||||
*/
|
||||
private String settingsPath;
|
||||
private String userSettingsPath;
|
||||
|
||||
private File settingsFile;
|
||||
/**
|
||||
* @configuration
|
||||
*/
|
||||
private String globalSettingsPath;
|
||||
|
||||
private File userSettingsFile;
|
||||
|
||||
private File globalSettingsFile;
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Component Lifecycle
|
||||
|
@ -52,16 +57,18 @@ public class DefaultMavenSettingsBuilder
|
|||
|
||||
public void initialize()
|
||||
{
|
||||
settingsFile = getSettingsFile();
|
||||
userSettingsFile = getUserSettingsFile();
|
||||
globalSettingsFile = getGlobalSettingsFile();
|
||||
|
||||
getLogger().debug( "Building Maven settings from: '" + settingsFile.getAbsolutePath() + "'" );
|
||||
getLogger().debug( "Building Maven global-level settings from: '" + globalSettingsFile.getAbsolutePath() + "'" );
|
||||
getLogger().debug( "Building Maven user-level settings from: '" + userSettingsFile.getAbsolutePath() + "'" );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// MavenProfilesBuilder Implementation
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public Settings buildSettings()
|
||||
private Settings readSettings( File settingsFile )
|
||||
throws IOException, XmlPullParserException
|
||||
{
|
||||
Settings settings = null;
|
||||
|
@ -77,25 +84,29 @@ public class DefaultMavenSettingsBuilder
|
|||
|
||||
settings = modelReader.read( reader );
|
||||
}
|
||||
catch ( FileNotFoundException e )
|
||||
{
|
||||
// Not possible - just ignore
|
||||
getLogger().warn( "Settings file disappeared - ignoring", e );
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtil.close( reader );
|
||||
}
|
||||
}
|
||||
|
||||
if ( settings == null )
|
||||
{
|
||||
getLogger().debug( "Settings model not found. Creating empty instance of MavenSettings." );
|
||||
return settings;
|
||||
}
|
||||
|
||||
settings = new Settings();
|
||||
public Settings buildSettings()
|
||||
throws IOException, XmlPullParserException
|
||||
{
|
||||
Settings globalSettings = readSettings( globalSettingsFile );
|
||||
Settings userSettings = readSettings( userSettingsFile );
|
||||
|
||||
if ( userSettings == null )
|
||||
{
|
||||
userSettings = new Settings();
|
||||
}
|
||||
|
||||
if( settings.getLocalRepository() == null || settings.getLocalRepository().length() < 1 )
|
||||
|
||||
SettingsUtils.merge( userSettings, globalSettings );
|
||||
|
||||
if ( userSettings.getLocalRepository() == null || userSettings.getLocalRepository().length() < 1 )
|
||||
{
|
||||
File mavenUserConfigurationDirectory = new File( userHome, ".m2" );
|
||||
if ( !mavenUserConfigurationDirectory.exists() )
|
||||
|
@ -107,24 +118,46 @@ public class DefaultMavenSettingsBuilder
|
|||
}
|
||||
|
||||
String localRepository = new File( mavenUserConfigurationDirectory, "repository" ).getAbsolutePath();
|
||||
|
||||
settings.setLocalRepository( localRepository );
|
||||
|
||||
userSettings.setLocalRepository( localRepository );
|
||||
}
|
||||
|
||||
return settings;
|
||||
return userSettings;
|
||||
}
|
||||
|
||||
private File getSettingsFile()
|
||||
private File getUserSettingsFile()
|
||||
{
|
||||
String path = System.getProperty( MavenSettingsBuilder.ALT_SETTINGS_XML_LOCATION );
|
||||
|
||||
if( StringUtils.isEmpty( path ) )
|
||||
String path = System.getProperty( MavenSettingsBuilder.ALT_USER_SETTINGS_XML_LOCATION );
|
||||
|
||||
if ( StringUtils.isEmpty( path ) )
|
||||
{
|
||||
// TODO: This replacing shouldn't be necessary as user.home should be in the
|
||||
// context of the container and thus the value would be interpolated by Plexus
|
||||
String userHome = System.getProperty( "user.home" );
|
||||
|
||||
return new File( userHome, settingsPath ).getAbsoluteFile();
|
||||
path = userSettingsPath.replaceAll( "\\$\\{user.home\\}", userHome );
|
||||
|
||||
return new File( path ).getAbsoluteFile();
|
||||
}
|
||||
else
|
||||
{
|
||||
return new File( path ).getAbsoluteFile();
|
||||
}
|
||||
}
|
||||
|
||||
private File getGlobalSettingsFile()
|
||||
{
|
||||
String path = System.getProperty( MavenSettingsBuilder.ALT_GLOBAL_SETTINGS_XML_LOCATION );
|
||||
|
||||
if ( StringUtils.isEmpty( path ) )
|
||||
{
|
||||
// TODO: This replacing shouldn't be necessary as user.home should be in the
|
||||
// context of the container and thus the value would be interpolated by Plexus
|
||||
String mavenHome = System.getProperty( "maven.home" );
|
||||
|
||||
path = globalSettingsPath.replaceAll( "\\$\\{maven.home\\}", mavenHome );
|
||||
|
||||
return new File( path ).getAbsoluteFile();
|
||||
}
|
||||
else
|
||||
{
|
|
@ -29,7 +29,8 @@ public interface MavenSettingsBuilder
|
|||
{
|
||||
String ROLE = MavenSettingsBuilder.class.getName();
|
||||
|
||||
String ALT_SETTINGS_XML_LOCATION = "org.apache.maven.SettingsXmlFile";
|
||||
String ALT_USER_SETTINGS_XML_LOCATION = "org.apache.maven.user-settings";
|
||||
String ALT_GLOBAL_SETTINGS_XML_LOCATION = "org.apache.maven.global-settings";
|
||||
|
||||
Settings buildSettings()
|
||||
throws IOException, XmlPullParserException;
|
|
@ -1,97 +0,0 @@
|
|||
package org.apache.maven.settings;
|
||||
|
||||
import org.apache.maven.model.Activation;
|
||||
import org.apache.maven.model.ActivationProperty;
|
||||
import org.apache.maven.model.Profile;
|
||||
import org.apache.maven.model.Repository;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public final class SettingsConversionUtils
|
||||
{
|
||||
|
||||
public static Profile convertFromSettingsProfile( org.apache.maven.settings.Profile settingsProfile )
|
||||
{
|
||||
Profile profile = new Profile();
|
||||
|
||||
profile.setId( settingsProfile.getId() );
|
||||
|
||||
profile.setSource( "settings.xml" );
|
||||
|
||||
org.apache.maven.settings.Activation settingsActivation = settingsProfile.getActivation();
|
||||
|
||||
if ( settingsActivation != null )
|
||||
{
|
||||
Activation activation = new Activation();
|
||||
|
||||
activation.setJdk( settingsActivation.getJdk() );
|
||||
|
||||
org.apache.maven.settings.ActivationProperty settingsProp = settingsActivation.getProperty();
|
||||
|
||||
if ( settingsProp != null )
|
||||
{
|
||||
ActivationProperty prop = new ActivationProperty();
|
||||
|
||||
prop.setName( settingsProp.getName() );
|
||||
prop.setValue( settingsProp.getValue() );
|
||||
|
||||
activation.setProperty( prop );
|
||||
}
|
||||
}
|
||||
|
||||
profile.setProperties( settingsProfile.getProperties() );
|
||||
|
||||
List repos = settingsProfile.getRepositories();
|
||||
if ( repos != null )
|
||||
{
|
||||
for ( Iterator it = repos.iterator(); it.hasNext(); )
|
||||
{
|
||||
profile
|
||||
.addRepository( convertFromSettingsRepository( (org.apache.maven.settings.Repository) it.next() ) );
|
||||
}
|
||||
}
|
||||
|
||||
List pluginRepos = settingsProfile.getPluginRepositories();
|
||||
if ( pluginRepos != null )
|
||||
{
|
||||
for ( Iterator it = pluginRepos.iterator(); it.hasNext(); )
|
||||
{
|
||||
profile.addPluginRepository( convertFromSettingsRepository( (org.apache.maven.settings.Repository) it
|
||||
.next() ) );
|
||||
}
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static Repository convertFromSettingsRepository( org.apache.maven.settings.Repository settingsRepo )
|
||||
{
|
||||
Repository repo = new Repository();
|
||||
|
||||
repo.setId( settingsRepo.getId() );
|
||||
repo.setLayout( settingsRepo.getLayout() );
|
||||
repo.setName( settingsRepo.getName() );
|
||||
repo.setSnapshotPolicy( settingsRepo.getSnapshotPolicy() );
|
||||
repo.setUrl( settingsRepo.getUrl() );
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
package org.apache.maven.settings;
|
||||
|
||||
import org.codehaus.plexus.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/*
|
||||
* Copyright 2001-2005 The Apache Software Foundation.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
public final class SettingsUtils
|
||||
{
|
||||
|
||||
private SettingsUtils()
|
||||
{
|
||||
}
|
||||
|
||||
public static void merge( Settings dominant, Settings recessive )
|
||||
{
|
||||
if ( dominant == null || recessive == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
List dominantActiveProfiles = dominant.getActiveProfiles();
|
||||
List recessiveActiveProfiles = recessive.getActiveProfiles();
|
||||
|
||||
for ( Iterator it = recessiveActiveProfiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
String profileId = (String) it.next();
|
||||
|
||||
if ( !dominantActiveProfiles.contains( profileId ) )
|
||||
{
|
||||
dominantActiveProfiles.add( profileId );
|
||||
}
|
||||
}
|
||||
|
||||
if ( StringUtils.isEmpty( dominant.getLocalRepository() ) )
|
||||
{
|
||||
dominant.setLocalRepository( recessive.getLocalRepository() );
|
||||
}
|
||||
|
||||
List mergedMirrors = new ArrayList( dominant.getMirrors() );
|
||||
|
||||
List recessiveMirrors = recessive.getMirrors();
|
||||
|
||||
Map dominantMirrors = dominant.getMirrorsAsMap();
|
||||
|
||||
for ( Iterator it = recessiveMirrors.iterator(); it.hasNext(); )
|
||||
{
|
||||
Mirror recessiveMirror = (Mirror) it.next();
|
||||
|
||||
Mirror dominantMirror = (Mirror) dominantMirrors.get( recessiveMirror.getId() );
|
||||
|
||||
if ( dominantMirror == null )
|
||||
{
|
||||
mergedMirrors.add( recessiveMirror );
|
||||
}
|
||||
}
|
||||
|
||||
dominant.setMirrors( mergedMirrors );
|
||||
|
||||
List mergedServers = new ArrayList( dominant.getServers() );
|
||||
|
||||
List recessiveServers = recessive.getServers();
|
||||
|
||||
Map dominantServers = dominant.getServersAsMap();
|
||||
|
||||
for ( Iterator it = recessiveServers.iterator(); it.hasNext(); )
|
||||
{
|
||||
Server recessiveServer = (Server) it.next();
|
||||
|
||||
if ( !dominantServers.containsKey( recessiveServer.getId() ) )
|
||||
{
|
||||
mergedServers.add( recessiveServer );
|
||||
}
|
||||
}
|
||||
|
||||
dominant.setServers( mergedServers );
|
||||
|
||||
List mergedProxies = new ArrayList( dominant.getProxies() );
|
||||
|
||||
List recessiveProxies = recessive.getProxies();
|
||||
|
||||
Map dominantProxies = dominant.getProxiesAsMap();
|
||||
|
||||
for ( Iterator it = recessiveProxies.iterator(); it.hasNext(); )
|
||||
{
|
||||
Proxy recessiveProxy = (Proxy) it.next();
|
||||
|
||||
if ( !dominantProxies.containsKey( recessiveProxy ) )
|
||||
{
|
||||
mergedProxies.add( recessiveProxy );
|
||||
}
|
||||
}
|
||||
|
||||
dominant.setProxies( mergedProxies );
|
||||
|
||||
List mergedProfiles = new ArrayList( dominant.getProfiles() );
|
||||
|
||||
List recessiveProfiles = recessive.getProfiles();
|
||||
|
||||
Map dominantProfiles = dominant.getProfilesAsMap();
|
||||
|
||||
for ( Iterator it = recessiveProfiles.iterator(); it.hasNext(); )
|
||||
{
|
||||
Profile recessiveProfile = (Profile) it.next();
|
||||
|
||||
if ( !dominantProfiles.containsKey( recessiveProfile.getId() ) )
|
||||
{
|
||||
mergedProfiles.add( recessiveProfile );
|
||||
}
|
||||
}
|
||||
|
||||
dominant.setProfiles( mergedProfiles );
|
||||
|
||||
}
|
||||
|
||||
public static org.apache.maven.model.Profile convertFromSettingsProfile( Profile settingsProfile )
|
||||
{
|
||||
org.apache.maven.model.Profile profile = new org.apache.maven.model.Profile();
|
||||
|
||||
profile.setId( settingsProfile.getId() );
|
||||
|
||||
profile.setSource( "settings.xml" );
|
||||
|
||||
org.apache.maven.settings.Activation settingsActivation = settingsProfile.getActivation();
|
||||
|
||||
if ( settingsActivation != null )
|
||||
{
|
||||
org.apache.maven.model.Activation activation = new org.apache.maven.model.Activation();
|
||||
|
||||
activation.setJdk( settingsActivation.getJdk() );
|
||||
|
||||
org.apache.maven.settings.ActivationProperty settingsProp = settingsActivation.getProperty();
|
||||
|
||||
if ( settingsProp != null )
|
||||
{
|
||||
org.apache.maven.model.ActivationProperty prop = new org.apache.maven.model.ActivationProperty();
|
||||
|
||||
prop.setName( settingsProp.getName() );
|
||||
prop.setValue( settingsProp.getValue() );
|
||||
|
||||
activation.setProperty( prop );
|
||||
}
|
||||
}
|
||||
|
||||
profile.setProperties( settingsProfile.getProperties() );
|
||||
|
||||
List repos = settingsProfile.getRepositories();
|
||||
if ( repos != null )
|
||||
{
|
||||
for ( Iterator it = repos.iterator(); it.hasNext(); )
|
||||
{
|
||||
profile.addRepository( convertFromSettingsRepository( (Repository) it.next() ) );
|
||||
}
|
||||
}
|
||||
|
||||
List pluginRepos = settingsProfile.getPluginRepositories();
|
||||
if ( pluginRepos != null )
|
||||
{
|
||||
for ( Iterator it = pluginRepos.iterator(); it.hasNext(); )
|
||||
{
|
||||
profile.addPluginRepository( convertFromSettingsRepository( (Repository) it.next() ) );
|
||||
}
|
||||
}
|
||||
|
||||
return profile;
|
||||
}
|
||||
|
||||
private static org.apache.maven.model.Repository convertFromSettingsRepository( Repository settingsRepo )
|
||||
{
|
||||
org.apache.maven.model.Repository repo = new org.apache.maven.model.Repository();
|
||||
|
||||
repo.setId( settingsRepo.getId() );
|
||||
repo.setLayout( settingsRepo.getLayout() );
|
||||
repo.setName( settingsRepo.getName() );
|
||||
repo.setSnapshotPolicy( settingsRepo.getSnapshotPolicy() );
|
||||
repo.setUrl( settingsRepo.getUrl() );
|
||||
|
||||
return repo;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
<component-set>
|
||||
<components>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.settings.MavenSettingsBuilder</role>
|
||||
<implementation>org.apache.maven.settings.DefaultMavenSettingsBuilder</implementation>
|
||||
<configuration>
|
||||
<globalSettingsPath>${maven.home}/settings.xml</globalSettingsPath>
|
||||
<userSettingsPath>${user.home}/.m2/settings.xml</userSettingsPath>
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
</components>
|
||||
</component-set>
|
Loading…
Reference in New Issue