Author: bentmann Date: Tue Sep 1 19:03:27 2009 New Revision: 810174 URL: http://svn.apache.org/viewvc?rev=810174&view=rev Log: o Collected repo settings in request
Added: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/SettingsAdapter.java - copied, changed from r809890, maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/SettingsAdapter.java Removed: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/SettingsAdapter.java Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java?rev=810174&r1=810173&r2=810174&view=diff ============================================================================== --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java (original) +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/DefaultMavenExecutionRequest.java Tue Sep 1 19:03:27 2009 @@ -26,6 +26,9 @@ import org.apache.maven.model.Profile; import org.apache.maven.project.DefaultProjectBuildingRequest; import org.apache.maven.project.ProjectBuildingRequest; +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.wagon.events.TransferListener; @@ -46,11 +49,11 @@ private boolean interactiveMode = true; - private List proxies; + private List<Proxy> proxies; - private List servers; + private List<Server> servers; - private List mirrors; + private List<Mirror> mirrors; private List<Profile> profiles; @@ -619,20 +622,20 @@ // Settings equivalents // ---------------------------------------------------------------------------- - public List getProxies() + public List<Proxy> getProxies() { if ( proxies == null ) { - proxies = new ArrayList(); + proxies = new ArrayList<Proxy>(); } return proxies; } - public MavenExecutionRequest setProxies( List proxies ) + public MavenExecutionRequest setProxies( List<Proxy> proxies ) { if ( proxies != null ) { - this.proxies = new ArrayList( proxies ); + this.proxies = new ArrayList<Proxy>( proxies ); } else { @@ -642,20 +645,40 @@ return this; } - public List getServers() + public MavenExecutionRequest addProxy( Proxy proxy ) + { + if ( proxy == null ) + { + throw new IllegalArgumentException( "proxy missing" ); + } + + for ( Proxy p : getProxies() ) + { + if ( p.getId() != null && p.getId().equals( proxy.getId() ) ) + { + return this; + } + } + + getProxies().add( proxy ); + + return this; + } + + public List<Server> getServers() { if ( servers == null ) { - servers = new ArrayList(); + servers = new ArrayList<Server>(); } return servers; } - public MavenExecutionRequest setServers( List servers ) + public MavenExecutionRequest setServers( List<Server> servers ) { if ( servers != null ) { - this.servers = new ArrayList( servers ); + this.servers = new ArrayList<Server>( servers ); } else { @@ -665,20 +688,40 @@ return this; } - public List getMirrors() + public MavenExecutionRequest addServer( Server server ) + { + if ( server == null ) + { + throw new IllegalArgumentException( "server missing" ); + } + + for ( Server p : getServers() ) + { + if ( p.getId() != null && p.getId().equals( server.getId() ) ) + { + return this; + } + } + + getServers().add( server ); + + return this; + } + + public List<Mirror> getMirrors() { if ( mirrors == null ) { - mirrors = new ArrayList(); + mirrors = new ArrayList<Mirror>(); } return mirrors; } - public MavenExecutionRequest setMirrors( List mirrors ) + public MavenExecutionRequest setMirrors( List<Mirror> mirrors ) { if ( mirrors != null ) { - this.mirrors = new ArrayList( mirrors ); + this.mirrors = new ArrayList<Mirror>( mirrors ); } else { @@ -688,6 +731,26 @@ return this; } + public MavenExecutionRequest addMirror( Mirror mirror ) + { + if ( mirror == null ) + { + throw new IllegalArgumentException( "mirror missing" ); + } + + for ( Mirror p : getMirrors() ) + { + if ( p.getId() != null && p.getId().equals( mirror.getId() ) ) + { + return this; + } + } + + getMirrors().add( mirror ); + + return this; + } + public List<Profile> getProfiles() { if ( profiles == null ) Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java?rev=810174&r1=810173&r2=810174&view=diff ============================================================================== --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java (original) +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenExecutionRequest.java Tue Sep 1 19:03:27 2009 @@ -29,6 +29,9 @@ import org.apache.maven.artifact.repository.RepositoryCache; import org.apache.maven.model.Profile; import org.apache.maven.project.ProjectBuildingRequest; +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.wagon.events.TransferListener; import org.codehaus.plexus.logging.Logger; @@ -207,16 +210,19 @@ List<String> getInactiveProfiles(); // Proxies - List getProxies(); - MavenExecutionRequest setProxies( List proxies ); + List<Proxy> getProxies(); + MavenExecutionRequest setProxies( List<Proxy> proxies ); + MavenExecutionRequest addProxy( Proxy proxy ); // Servers - List getServers(); - MavenExecutionRequest setServers( List servers ); + List<Server> getServers(); + MavenExecutionRequest setServers( List<Server> servers ); + MavenExecutionRequest addServer( Server server ); // Mirrors - List getMirrors(); - MavenExecutionRequest setMirrors( List mirrors ); + List<Mirror> getMirrors(); + MavenExecutionRequest setMirrors( List<Mirror> mirrors ); + MavenExecutionRequest addMirror( Mirror mirror ); // Plugin groups List<String> getPluginGroups(); Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java?rev=810174&r1=810173&r2=810174&view=diff ============================================================================== --- maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java (original) +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/MavenSession.java Tue Sep 1 19:03:27 2009 @@ -48,6 +48,8 @@ private MavenExecutionResult result; + private final Settings settings; + private Properties executionProperties; private MavenProject currentProject; @@ -76,7 +78,8 @@ this.container = container; this.request = request; this.result = result; - setProjects( projects ); + this.settings = new SettingsAdapter( request ); + setProjects( projects ); } public MavenSession( PlexusContainer container, MavenExecutionRequest request, MavenExecutionResult result ) @@ -84,6 +87,7 @@ this.container = container; this.request = request; this.result = result; + this.settings = new SettingsAdapter( request ); } public void setProjects( List<MavenProject> projects ) @@ -118,14 +122,14 @@ } @Deprecated - public List lookupList( String role ) + public List<Object> lookupList( String role ) throws ComponentLookupException { return container.lookupList( role ); } @Deprecated - public Map lookupMap( String role ) + public Map<String, Object> lookupMap( String role ) throws ComponentLookupException { return container.lookupMap( role ); @@ -187,7 +191,7 @@ public Settings getSettings() { - return request.getSettings(); + return settings; } public List<MavenProject> getProjects() Copied: maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/SettingsAdapter.java (from r809890, maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/SettingsAdapter.java) URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/SettingsAdapter.java?p2=maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/SettingsAdapter.java&p1=maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/SettingsAdapter.java&r1=809890&r2=810174&rev=810174&view=diff ============================================================================== --- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/SettingsAdapter.java (original) +++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/execution/SettingsAdapter.java Tue Sep 1 19:03:27 2009 @@ -1,4 +1,4 @@ -package org.apache.maven.embedder.execution; +package org.apache.maven.execution; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -21,8 +21,11 @@ import java.util.List; -import org.apache.maven.execution.MavenExecutionRequest; +import org.apache.maven.settings.Mirror; +import org.apache.maven.settings.Profile; +import org.apache.maven.settings.Proxy; import org.apache.maven.settings.RuntimeInfo; +import org.apache.maven.settings.Server; import org.apache.maven.settings.Settings; /** @@ -33,74 +36,83 @@ * * @author Jason van Zyl */ -public class SettingsAdapter +class SettingsAdapter extends Settings { + private MavenExecutionRequest request; - private Settings settings; + private RuntimeInfo runtimeInfo; - - public SettingsAdapter( MavenExecutionRequest request, Settings settings ) + + public SettingsAdapter( MavenExecutionRequest request ) { this.request = request; - this.settings = settings; this.runtimeInfo = new RuntimeInfo( request.getUserSettingsFile() ); } + @Override public String getLocalRepository() { if ( request.getLocalRepositoryPath() != null ) { return request.getLocalRepositoryPath().getAbsolutePath(); } - - return settings.getLocalRepository(); + + return null; } + @Override public boolean isInteractiveMode() - { - return request.isInteractiveMode(); + { + return request.isInteractiveMode(); } + @Override public boolean isOffline() { return request.isOffline(); } - // These we are not setting in the execution request currently - - public List getProxies() + @Override + public List<Proxy> getProxies() { - return settings.getProxies(); + return request.getProxies(); } - public List getServers() + @Override + public List<Server> getServers() { - return settings.getServers(); + return request.getServers(); } - public List getMirrors() + @Override + public List<Mirror> getMirrors() { - return settings.getMirrors(); + return request.getMirrors(); } - public List getProfiles() + @Override + public List<Profile> getProfiles() { - return settings.getProfiles(); + return request.getSettings().getProfiles(); } - public List getActiveProfiles() + @Override + public List<String> getActiveProfiles() { - return settings.getActiveProfiles(); + return request.getActiveProfiles(); } - public List getPluginGroups() + @Override + public List<String> getPluginGroups() { - return settings.getPluginGroups(); + return request.getPluginGroups(); } - + + @Override public RuntimeInfo getRuntimeInfo() { return runtimeInfo; } + } Modified: maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java?rev=810174&r1=810173&r2=810174&view=diff ============================================================================== --- maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java (original) +++ maven/components/trunk/maven-embedder/src/main/java/org/apache/maven/embedder/execution/DefaultMavenExecutionRequestPopulator.java Tue Sep 1 19:03:27 2009 @@ -101,8 +101,6 @@ populateDefaultPluginGroups( request ); - List<org.apache.maven.settings.Profile> settingsProfiles = settings.getProfiles(); - // We just need to keep track of what profiles are being activated by the settings. We don't need to process // them here. This should be taken care of by the project builder. // @@ -111,6 +109,8 @@ // We only need to take the profiles and make sure they are available when the calculation of the active profiles // is determined. // + List<org.apache.maven.settings.Profile> settingsProfiles = settings.getProfiles(); + if ( ( settingsProfiles != null ) && !settingsProfiles.isEmpty() ) { for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() ) @@ -194,30 +194,51 @@ // </proxy> // </proxies> - Proxy proxy = settings.getActiveProxy(); + Proxy activeProxy = settings.getActiveProxy(); - if ( proxy != null ) + if ( activeProxy != null ) { - if ( proxy.getHost() == null ) + if ( activeProxy.getHost() == null ) { throw new MavenEmbedderException( "Proxy in settings.xml has no host" ); } + String password = decrypt( activeProxy.getPassword(), "password for proxy " + activeProxy.getId() ); + + repositorySystem.addProxy( activeProxy.getProtocol(), activeProxy.getHost(), activeProxy.getPort(), + activeProxy.getUsername(), password, activeProxy.getNonProxyHosts() ); + } + + for ( Proxy proxy : settings.getProxies() ) + { + proxy = proxy.clone(); + String password = decrypt( proxy.getPassword(), "password for proxy " + proxy.getId() ); - repositorySystem.addProxy( proxy.getProtocol(), proxy.getHost(), proxy.getPort(), proxy.getUsername(), - password, proxy.getNonProxyHosts() ); + proxy.setPassword( password ); + + request.addProxy( proxy ); } for ( Server server : settings.getServers() ) { + server = server.clone(); + String password = decrypt( server.getPassword(), "password for server " + server.getId() ); + server.setPassword( password ); + + request.addServer( server ); + repositorySystem.addAuthenticationForArtifactRepository( server.getId(), server.getUsername(), password ); } for ( Mirror mirror : settings.getMirrors() ) { + mirror = mirror.clone(); + + request.addMirror( mirror ); + repositorySystem.addMirror( mirror.getId(), mirror.getMirrorOf(), mirror.getUrl() ); } @@ -294,11 +315,11 @@ { Settings settings = settingsBuilder.buildSettings( request ); - request.setSettings( new SettingsAdapter( request, settings ) ); + request.setSettings( settings ); } catch ( Exception e ) { - request.setSettings( new SettingsAdapter( request, new Settings() ) ); + request.setSettings( new Settings() ); } } }