Skip to content

Commit

Permalink
fix ClassCastException
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/maven/continuum/trunk@594091 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
olamy committed Nov 12, 2007
1 parent 425b90d commit 28e69ae
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Properties;

/**
Expand Down Expand Up @@ -349,23 +350,28 @@ private static Collection<Artifact> downloadArtifact( PlexusContainer container,
remoteRepositories.add(
factory.createArtifactRepository( "central", "http://repo1.maven.org/maven2", layout, null, null ) );
//Load extra repositories from active profile
List<Profile> profiles = getSettings( container ).getActiveProfiles();
if ( profiles != null && !profiles.isEmpty() )

Settings settings = getSettings( container );
List<String> profileIds = settings.getActiveProfiles();
List<Profile> profiles = settings.getProfiles();
Map<String, Profile> profilesAsMap = settings.getProfilesAsMap();
if ( profileIds != null && !profileIds.isEmpty() )
{
for ( Profile p : profiles )
for ( String profileId : profileIds )
{
List<Repository> repos = p.getRepositories();
Profile profile = profilesAsMap.get( profileId );
List<Repository> repos = profile.getRepositories();
if ( repos != null && !repos.isEmpty() )
{
for ( Repository repo : repos )
{
remoteRepositories.add(
factory.createArtifactRepository( repo.getId(), repo.getUrl(), layout, null, null ) );
remoteRepositories.add( factory.createArtifactRepository( repo.getId(), repo
.getUrl(), layout, null, null ) );
}
}
}
}

ArtifactFactory artifactFactory = (ArtifactFactory) container.lookup( ArtifactFactory.ROLE );
Artifact artifact =
artifactFactory.createArtifact( groupId, artifactId, version, Artifact.SCOPE_RUNTIME, "jar" );
Expand Down

0 comments on commit 28e69ae

Please sign in to comment.