You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ol...@apache.org on 2007/11/11 23:15:40 UTC

svn commit: r593974 - /maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureAppearanceAction.java

Author: olamy
Date: Sun Nov 11 14:15:39 2007
New Revision: 593974

URL: http://svn.apache.org/viewvc?rev=593974&view=rev
Log:
[CONTINUUM-1559] use repositories declared in settings.xml to load company pom

Modified:
    maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureAppearanceAction.java

Modified: maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureAppearanceAction.java
URL: http://svn.apache.org/viewvc/maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureAppearanceAction.java?rev=593974&r1=593973&r2=593974&view=diff
==============================================================================
--- maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureAppearanceAction.java (original)
+++ maven/continuum/trunk/continuum-webapp/src/main/java/org/apache/maven/continuum/web/action/admin/ConfigureAppearanceAction.java Sun Nov 11 14:15:39 2007
@@ -1,27 +1,29 @@
 package org.apache.maven.continuum.web.action.admin;
 
 /*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you 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.
+ * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
+ * agreements. See the NOTICE file distributed with this work for additional information regarding
+ * copyright ownership. The ASF licenses this file to you 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.
  */
 
 import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
 
 import org.apache.maven.artifact.metadata.ArtifactMetadataRetrievalException;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.repository.ArtifactRepositoryFactory;
+import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 import org.apache.maven.continuum.execution.maven.m2.MavenBuilderHelper;
 import org.apache.maven.continuum.execution.maven.m2.SettingsConfigurationException;
 import org.apache.maven.continuum.security.ContinuumRoleConstants;
@@ -29,6 +31,10 @@
 import org.apache.maven.continuum.web.appareance.AppareanceConfiguration;
 import org.apache.maven.model.Model;
 import org.apache.maven.project.ProjectBuildingException;
+import org.apache.maven.settings.MavenSettingsBuilder;
+import org.apache.maven.settings.Profile;
+import org.apache.maven.settings.Repository;
+import org.apache.maven.settings.Settings;
 import org.apache.maven.shared.app.company.CompanyPomHandler;
 import org.apache.maven.shared.app.configuration.Configuration;
 import org.apache.maven.shared.app.configuration.MavenAppConfiguration;
@@ -37,6 +43,7 @@
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionBundle;
 import org.codehaus.plexus.redback.xwork.interceptor.SecureActionException;
 import org.codehaus.plexus.registry.RegistryException;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
 
 import com.opensymphony.xwork.ModelDriven;
 
@@ -70,13 +77,27 @@
      * @plexus.requirement
      */
     private MavenBuilderHelper helper;
-    
 
     /**
      * @plexus.requirement
-     */    
+     */
+    private MavenSettingsBuilder mavenSettingsBuilder;
+
+    /**
+     * @plexus.requirement
+     */
+    private ArtifactRepositoryFactory artifactRepositoryFactory;
+
+    /**
+     * @plexus.requirement role-hint="default"
+     */
+    private ArtifactRepositoryLayout layout;
+
+    /**
+     * @plexus.requirement
+     */
     private AppareanceConfiguration appareanceConfiguration;
-    
+
     public String execute()
         throws IOException, RegistryException
     {
@@ -90,20 +111,45 @@
     {
         return INPUT;
     }
-    
+
     public Object getModel()
     {
         return configuration;
     }
 
     public void prepare()
-        throws ProjectBuildingException, ArtifactMetadataRetrievalException, SettingsConfigurationException
+        throws ProjectBuildingException, ArtifactMetadataRetrievalException, SettingsConfigurationException,
+        XmlPullParserException, IOException
     {
+
+        Settings settings = mavenSettingsBuilder.buildSettings( false );
+
+        // Load extra repositories from active profiles
+        List<String> profileIds = settings.getActiveProfiles();
+        List<Profile> profiles = settings.getProfiles();
+        List<ArtifactRepository> remoteRepositories = new ArrayList<ArtifactRepository>();
+        Map<String, Profile> profilesAsMap = settings.getProfilesAsMap();
+        if ( profileIds != null && !profileIds.isEmpty() )
+        {
+            for ( String profileId : profileIds )
+            {
+                Profile profile = profilesAsMap.get( profileId );
+                List<Repository> repos = profile.getRepositories();
+                if ( repos != null && !repos.isEmpty() )
+                {
+                    for ( Repository repo : repos )
+                    {
+                        remoteRepositories.add( artifactRepositoryFactory.createArtifactRepository( repo.getId(), repo
+                            .getUrl(), layout, null, null ) );
+                    }
+                }
+            }
+        }
         configuration = appConfiguration.getConfiguration();
 
-        companyModel =
-            companyPomHandler.getCompanyPomModel( configuration.getCompanyPom(), helper.getLocalRepository() );
-        
+        companyModel = companyPomHandler.getCompanyPomModel( configuration.getCompanyPom(),
+                                                             helper.getLocalRepository(), remoteRepositories );
+
         this.setFooter( appareanceConfiguration.getFooter() );
     }