You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by be...@apache.org on 2010/08/25 00:46:12 UTC
svn commit: r988749 [5/9] - in /maven/maven-3/trunk: ./ apache-maven/
maven-aether-provider/ maven-aether-provider/src/
maven-aether-provider/src/main/ maven-aether-provider/src/main/java/
maven-aether-provider/src/main/java/org/ maven-aether-provider/...
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/DefaultLifecycleExecutionPlanCalculator.java Tue Aug 24 22:46:07 2010
@@ -1,25 +1,19 @@
-package org.apache.maven.lifecycle.internal;
-
/*
- * 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
+ * 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
+ * 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.
+ * 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.
*/
+package org.apache.maven.lifecycle.internal;
-import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.DefaultLifecycles;
import org.apache.maven.lifecycle.DefaultSchedules;
@@ -147,9 +141,10 @@ public class DefaultLifecycleExecutionPl
if ( mojoDescriptor == null )
{
- mojoDescriptor = pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
- DefaultRepositoryRequest.getRepositoryRequest(
- session, project ) );
+ mojoDescriptor =
+ pluginManager.getMojoDescriptor( mojoExecution.getPlugin(), mojoExecution.getGoal(),
+ project.getRemotePluginRepositories(),
+ session.getRepositorySession() );
mojoExecution.setMojoDescriptor( mojoDescriptor );
}
@@ -251,10 +246,11 @@ public class DefaultLifecycleExecutionPl
if ( lifecycle == null )
{
- throw new LifecyclePhaseNotFoundException( "Unknown lifecycle phase \"" + lifecyclePhase
- + "\". You must specify a valid lifecycle phase" + " or a goal in the format <plugin-prefix>:<goal> or"
- + " <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: "
- + defaultLifeCycles.getLifecyclePhaseList() + ".", lifecyclePhase );
+ throw new LifecyclePhaseNotFoundException(
+ "Unknown lifecycle phase \"" + lifecyclePhase + "\". You must specify a valid lifecycle phase" +
+ " or a goal in the format <plugin-prefix>:<goal> or" +
+ " <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: " +
+ defaultLifeCycles.getLifecyclePhaseList() + ".", lifecyclePhase );
}
/*
@@ -309,9 +305,8 @@ public class DefaultLifecycleExecutionPl
for ( String goal : execution.getGoals() )
{
MojoDescriptor mojoDescriptor =
- pluginManager.getMojoDescriptor( plugin, goal,
- DefaultRepositoryRequest.getRepositoryRequest( session,
- project ) );
+ pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(),
+ session.getRepositorySession() );
Map<Integer, List<MojoExecution>> phaseBindings = mappings.get( mojoDescriptor.getPhase() );
if ( phaseBindings != null )
@@ -464,8 +459,8 @@ public class DefaultLifecycleExecutionPl
{
parameterConfiguration = new Xpp3Dom( parameterConfiguration, parameter.getName() );
- if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) )
- && StringUtils.isNotEmpty( parameter.getImplementation() ) )
+ if ( StringUtils.isEmpty( parameterConfiguration.getAttribute( "implementation" ) ) &&
+ StringUtils.isNotEmpty( parameter.getImplementation() ) )
{
parameterConfiguration.setAttribute( "implementation", parameter.getImplementation() );
}
@@ -488,7 +483,8 @@ public class DefaultLifecycleExecutionPl
PluginDescriptorParsingException, NoPluginFoundForPrefixException, InvalidPluginDescriptorException,
LifecyclePhaseNotFoundException, LifecycleNotFoundException, PluginVersionResolutionException
{
- calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet<MojoDescriptor>() );
+ calculateForkedExecutions( mojoExecution, session, session.getCurrentProject(), new HashSet<MojoDescriptor>() );
+
}
@@ -556,8 +552,8 @@ public class DefaultLifecycleExecutionPl
{
MojoDescriptor forkedMojoDescriptor =
pluginManager.getMojoDescriptor( forkedExecution.getPlugin(), forkedExecution.getGoal(),
- DefaultRepositoryRequest.getRepositoryRequest( session,
- project ) );
+ project.getRemotePluginRepositories(),
+ session.getRepositorySession() );
forkedExecution.setMojoDescriptor( forkedMojoDescriptor );
}
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecycleDependencyResolver.java Tue Aug 24 22:46:07 2010
@@ -1,39 +1,41 @@
package org.apache.maven.lifecycle.internal;
/*
- * 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
+ * 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
+ * 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.
+ * 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 org.apache.maven.ProjectDependenciesResolver;
+import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.factory.ArtifactFactory;
-import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
-import org.apache.maven.artifact.resolver.ArtifactResolutionException;
-import org.apache.maven.artifact.resolver.MultipleArtifactsNotFoundException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.lifecycle.LifecycleExecutionException;
import org.apache.maven.lifecycle.MavenExecutionPlan;
+import org.apache.maven.project.DefaultDependencyResolutionRequest;
+import org.apache.maven.project.DependencyResolutionException;
+import org.apache.maven.project.DependencyResolutionResult;
import org.apache.maven.project.MavenProject;
+import org.apache.maven.project.ProjectDependenciesResolver;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
+import org.sonatype.aether.graph.Dependency;
+import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.graph.DependencyNode;
+import org.sonatype.aether.util.filter.AndDependencyFilter;
+import org.sonatype.aether.util.filter.ScopeDependencyFilter;
import java.util.*;
@@ -47,11 +49,12 @@ import java.util.*;
* <p/>
* NOTE: This class is not part of any public api and can be changed or deleted without prior notice.
*/
-@Component( role = LifecycleDependencyResolver.class )
+@Component(role = LifecycleDependencyResolver.class)
public class LifecycleDependencyResolver
{
+
@Requirement
- private ProjectDependenciesResolver projectDependenciesResolver;
+ private ProjectDependenciesResolver dependenciesResolver;
@Requirement
private Logger logger;
@@ -59,14 +62,14 @@ public class LifecycleDependencyResolver
@Requirement
private ArtifactFactory artifactFactory;
- @SuppressWarnings( { "UnusedDeclaration" } )
+ @SuppressWarnings({"UnusedDeclaration"})
public LifecycleDependencyResolver()
{
}
public LifecycleDependencyResolver( ProjectDependenciesResolver projectDependenciesResolver, Logger logger )
{
- this.projectDependenciesResolver = projectDependenciesResolver;
+ this.dependenciesResolver = projectDependenciesResolver;
this.logger = logger;
}
@@ -136,87 +139,112 @@ public class LifecycleDependencyResolver
}
Set<Artifact> artifacts =
- getProjectDependencies( project, scopesToCollect, scopesToResolve, session, aggregating,
- projectArtifacts );
+ getDependencies( project, scopesToCollect, scopesToResolve, session, aggregating, projectArtifacts );
project.setResolvedArtifacts( artifacts );
- }
- private Set<Artifact> getProjectDependencies( MavenProject project, Collection<String> scopesToCollect,
- Collection<String> scopesToResolve, MavenSession session,
- boolean aggregating, Set<Artifact> projectArtifacts )
- throws LifecycleExecutionException
- {
- Set<Artifact> artifacts;
- try
+ Map<String, Artifact> map = new HashMap<String, Artifact>();
+ for ( Artifact artifact : artifacts )
{
- try
- {
- artifacts = projectDependenciesResolver.resolve( project , scopesToCollect,
- scopesToResolve, session, projectArtifacts );
- }
- catch ( MultipleArtifactsNotFoundException e )
+ map.put( artifact.getId(), artifact );
+ }
+ for ( Artifact artifact : project.getDependencyArtifacts() )
+ {
+ if ( artifact.getFile() == null )
{
- /*
- * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
- * plugins that require dependency resolution although they usually run in phases of the build where
- * project artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
- */
- artifacts = handleException( session, aggregating, e );
+ Artifact resolved = map.get( artifact.getId() );
+ if ( resolved != null )
+ {
+ artifact.setFile( resolved.getFile() );
+ artifact.setDependencyTrail( resolved.getDependencyTrail() );
+ artifact.setResolvedVersion( resolved.getVersion() );
+ artifact.setResolved( true );
+ }
}
+ }
+ }
- return artifacts;
+ private Set<Artifact> getDependencies( MavenProject project, Collection<String> scopesToCollect,
+ Collection<String> scopesToResolve, MavenSession session,
+ boolean aggregating, Set<Artifact> projectArtifacts )
+ throws LifecycleExecutionException
+ {
+ if ( scopesToCollect == null )
+ {
+ scopesToCollect = Collections.emptySet();
}
- catch ( ArtifactResolutionException e )
+ if ( scopesToResolve == null )
{
- throw new LifecycleExecutionException( null, project, e );
+ scopesToResolve = Collections.emptySet();
}
- catch ( ArtifactNotFoundException e )
+
+ if ( scopesToCollect.isEmpty() && scopesToResolve.isEmpty() )
{
- throw new LifecycleExecutionException( null, project, e );
+ return new LinkedHashSet<Artifact>();
}
- }
+ scopesToCollect = new HashSet<String>( scopesToCollect );
+ scopesToCollect.addAll( scopesToResolve );
+ DependencyFilter collectionFilter = new ScopeDependencyFilter( null, negate( scopesToCollect ) );
+ DependencyFilter resolutionFilter = new ScopeDependencyFilter( null, negate( scopesToResolve ) );
+ resolutionFilter = AndDependencyFilter.newInstance( collectionFilter, resolutionFilter );
+ resolutionFilter =
+ AndDependencyFilter.newInstance( resolutionFilter, new ReactorDependencyFilter( projectArtifacts ) );
- private Set<Artifact> handleException( MavenSession session, boolean aggregating,
- MultipleArtifactsNotFoundException e )
- throws MultipleArtifactsNotFoundException
- {
- Set<Artifact> artifacts;
- /*
- * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
- * plugins that require dependency resolution although they usually run in phases of the build where project
- * artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
- */
- if ( aggregating && areAllArtifactsInReactor( session.getProjects(), e.getMissingArtifacts() ) )
+ DependencyResolutionResult result;
+ try
{
- logger.warn( "The following artifacts could not be resolved at this point of the build"
- + " but seem to be part of the reactor:" );
-
- for ( Artifact artifact : e.getMissingArtifacts() )
+ DefaultDependencyResolutionRequest request =
+ new DefaultDependencyResolutionRequest( project, session.getRepositorySession() );
+ request.setResolutionFilter( resolutionFilter );
+
+ result = dependenciesResolver.resolve( request );
+ }
+ catch ( DependencyResolutionException e )
+ {
+ result = e.getResult();
+
+ /*
+ * MNG-2277, the check below compensates for our bad plugin support where we ended up with aggregator
+ * plugins that require dependency resolution although they usually run in phases of the build where project
+ * artifacts haven't been assembled yet. The prime example of this is "mvn release:prepare".
+ */
+ if ( aggregating && areAllDependenciesInReactor( session.getProjects(), result.getUnresolvedDependencies() ) )
{
- logger.warn( "o " + artifact.getId() );
- }
+ logger.warn( "The following dependencies could not be resolved at this point of the build"
+ + " but seem to be part of the reactor:" );
- logger.warn( "Try running the build up to the lifecycle phase \"package\"" );
+ for ( Dependency dependency : result.getUnresolvedDependencies() )
+ {
+ logger.warn( "o " + dependency );
+ }
- artifacts = new LinkedHashSet<Artifact>( e.getResolvedArtifacts() );
+ logger.warn( "Try running the build up to the lifecycle phase \"package\"" );
+ }
+ else
+ {
+ throw new LifecycleExecutionException( null, project, e );
+ }
}
- else
+
+ Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+ if ( result.getDependencyGraph() != null && !result.getDependencyGraph().getChildren().isEmpty() )
{
- throw e;
+ RepositoryUtils.toArtifacts( artifacts, result.getDependencyGraph().getChildren(),
+ Collections.singletonList( project.getArtifact().getId() ), collectionFilter );
}
return artifacts;
}
- private boolean areAllArtifactsInReactor( Collection<MavenProject> projects, Collection<Artifact> artifacts )
+ private boolean areAllDependenciesInReactor( Collection<MavenProject> projects, Collection<Dependency> dependencies )
{
Set<String> projectKeys = getReactorProjectKeys( projects );
- for ( Artifact artifact : artifacts )
+ for ( Dependency dependency : dependencies )
{
- String key = ArtifactUtils.key( artifact );
+ org.sonatype.aether.artifact.Artifact a = dependency.getArtifact();
+ String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() );
if ( !projectKeys.contains( key ) )
{
return false;
@@ -237,4 +265,73 @@ public class LifecycleDependencyResolver
return projectKeys;
}
+ private Collection<String> negate( Collection<String> scopes )
+ {
+ Collection<String> result = new HashSet<String>();
+ Collections.addAll( result, "system", "compile", "provided", "runtime", "test" );
+
+ for ( String scope : scopes )
+ {
+ if ( "compile".equals( scope ) )
+ {
+ result.remove( "compile" );
+ result.remove( "system" );
+ result.remove( "provided" );
+ }
+ else if ( "runtime".equals( scope ) )
+ {
+ result.remove( "compile" );
+ result.remove( "runtime" );
+ }
+ else if ( "compile+runtime".equals( scope ) )
+ {
+ result.remove( "compile" );
+ result.remove( "system" );
+ result.remove( "provided" );
+ result.remove( "runtime" );
+ }
+ else if ( "runtime+system".equals( scope ) )
+ {
+ result.remove( "compile" );
+ result.remove( "system" );
+ result.remove( "runtime" );
+ }
+ else if ( "test".equals( scope ) )
+ {
+ result.clear();
+ }
+ }
+
+ return result;
+ }
+
+ private static class ReactorDependencyFilter
+ implements DependencyFilter
+ {
+
+ private Set<String> keys = new HashSet<String>();
+
+ public ReactorDependencyFilter( Collection<Artifact> artifacts )
+ {
+ for ( Artifact artifact : artifacts )
+ {
+ String key = ArtifactUtils.key( artifact );
+ keys.add( key );
+ }
+ }
+
+ public boolean accept( DependencyNode node, List<DependencyNode> parents )
+ {
+ Dependency dependency = node.getDependency();
+ if ( dependency != null )
+ {
+ org.sonatype.aether.artifact.Artifact a = dependency.getArtifact();
+ String key = ArtifactUtils.key( a.getGroupId(), a.getArtifactId(), a.getVersion() );
+ return !keys.contains( key );
+ }
+ return false;
+ }
+
+ }
+
}
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/LifecyclePluginResolver.java Tue Aug 24 22:46:07 2010
@@ -66,7 +66,9 @@ public class LifecyclePluginResolver
{
if ( plugin.getVersion() == null )
{
- PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session );
+ PluginVersionRequest request =
+ new DefaultPluginVersionRequest( plugin, session.getRepositorySession(),
+ project.getRemotePluginRepositories() );
plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() );
}
versions.put( plugin.getKey(), plugin.getVersion() );
@@ -82,7 +84,9 @@ public class LifecyclePluginResolver
plugin.setVersion( versions.get( plugin.getKey() ) );
if ( plugin.getVersion() == null )
{
- PluginVersionRequest request = new DefaultPluginVersionRequest( plugin, session );
+ PluginVersionRequest request =
+ new DefaultPluginVersionRequest( plugin, session.getRepositorySession(),
+ project.getRemotePluginRepositories() );
plugin.setVersion( pluginVersionResolver.resolve( request ).getVersion() );
}
}
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/lifecycle/internal/MojoDescriptorCreator.java Tue Aug 24 22:46:07 2010
@@ -19,8 +19,6 @@ package org.apache.maven.lifecycle.inter
* under the License.
*/
-import org.apache.maven.artifact.repository.DefaultRepositoryRequest;
-import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Plugin;
@@ -202,17 +200,16 @@ public class MojoDescriptorCreator
injectPluginDeclarationFromProject( plugin, project );
- RepositoryRequest repositoryRequest = DefaultRepositoryRequest.getRepositoryRequest( session, project );
-
// If there is no version to be found then we need to look in the repository metadata for
// this plugin and see what's specified as the latest release.
//
if ( plugin.getVersion() == null )
{
- resolvePluginVersion( plugin, repositoryRequest );
+ resolvePluginVersion( plugin, session, project );
}
- return pluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
+ return pluginManager.getMojoDescriptor( plugin, goal, project.getRemotePluginRepositories(),
+ session.getRepositorySession() );
}
// TODO: take repo mans into account as one may be aggregating prefixes of many
@@ -234,10 +231,12 @@ public class MojoDescriptorCreator
return plugin;
}
- private void resolvePluginVersion( Plugin plugin, RepositoryRequest repositoryRequest )
+ private void resolvePluginVersion( Plugin plugin, MavenSession session, MavenProject project )
throws PluginVersionResolutionException
{
- PluginVersionRequest versionRequest = new DefaultPluginVersionRequest( plugin, repositoryRequest );
+ PluginVersionRequest versionRequest =
+ new DefaultPluginVersionRequest( plugin, session.getRepositorySession(),
+ project.getRemotePluginRepositories() );
plugin.setVersion( pluginVersionResolver.resolve( versionRequest ).getVersion() );
}
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/model/plugin/DefaultLifecycleBindingsInjector.java Tue Aug 24 22:46:07 2010
@@ -27,7 +27,7 @@ import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
-import org.apache.maven.lifecycle.LifecycleExecutor;
+import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer;
import org.apache.maven.model.Build;
import org.apache.maven.model.Model;
import org.apache.maven.model.Plugin;
@@ -54,7 +54,7 @@ public class DefaultLifecycleBindingsInj
private LifecycleBindingsMerger merger = new LifecycleBindingsMerger();
@Requirement
- private LifecycleExecutor lifecycle;
+ private LifeCyclePluginAnalyzer lifecycle;
public void injectLifecycleBindings( Model model, ModelBuildingRequest request, ModelProblemCollector problems )
{
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/BuildPluginManager.java Tue Aug 24 22:46:07 2010
@@ -1,30 +1,29 @@
package org.apache.maven.plugin;
/*
- * 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 org.apache.maven.artifact.repository.RepositoryRequest;
+import java.util.List;
+
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
/**
* @author Jason van Zyl
@@ -32,12 +31,13 @@ import org.codehaus.plexus.classworlds.r
public interface BuildPluginManager
{
// igorf: Way too many declared exceptions!
- PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
+ PluginDescriptor loadPlugin( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
InvalidPluginDescriptorException;
// igorf: Way too many declared exceptions!
- MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest repositoryRequest )
+ MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
MojoNotFoundException, InvalidPluginDescriptorException;
Added: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java?rev=988749&view=auto
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java (added)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java Tue Aug 24 22:46:07 2010
@@ -0,0 +1,211 @@
+package org.apache.maven.plugin;
+
+/*
+ * 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.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.model.Dependency;
+import org.apache.maven.model.Exclusion;
+import org.apache.maven.model.Plugin;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
+import org.sonatype.aether.repository.RepositoryPolicy;
+import org.sonatype.aether.repository.WorkspaceReader;
+import org.sonatype.aether.repository.WorkspaceRepository;
+
+/**
+ * @author Benjamin Bentmann
+ */
+class CacheUtils
+{
+
+ public static <T> boolean eq( T s1, T s2 )
+ {
+ return s1 != null ? s1.equals( s2 ) : s2 == null;
+ }
+
+ public static int hash( Object obj )
+ {
+ return obj != null ? obj.hashCode() : 0;
+ }
+
+ public static int repositoriesHashCode( List<RemoteRepository> repositories )
+ {
+ int result = 17;
+ for ( RemoteRepository repository : repositories )
+ {
+ result = 31 * result + repositoryHashCode( repository );
+ }
+ return result;
+ }
+
+ private static int repositoryHashCode( RemoteRepository repository )
+ {
+ int result = 17;
+ result = 31 * result + hash( repository.getUrl() );
+ return result;
+ }
+
+ private static boolean repositoryEquals( RemoteRepository r1, RemoteRepository r2 )
+ {
+ if ( r1 == r2 )
+ {
+ return true;
+ }
+
+ return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() )
+ && policyEquals( r1.getPolicy( false ), r2.getPolicy( false ) )
+ && policyEquals( r1.getPolicy( true ), r2.getPolicy( true ) );
+ }
+
+ private static boolean policyEquals( RepositoryPolicy p1, RepositoryPolicy p2 )
+ {
+ if ( p1 == p2 )
+ {
+ return true;
+ }
+ // update policy doesn't affect contents
+ return p1.isEnabled() == p2.isEnabled() && eq( p1.getChecksumPolicy(), p2.getChecksumPolicy() );
+ }
+
+ public static boolean repositoriesEquals( List<RemoteRepository> r1, List<RemoteRepository> r2 )
+ {
+ if ( r1.size() != r2.size() )
+ {
+ return false;
+ }
+
+ for ( Iterator<RemoteRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); )
+ {
+ if ( !repositoryEquals( it1.next(), it2.next() ) )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static int pluginHashCode( Plugin plugin )
+ {
+ int hash = 17;
+
+ hash = hash * 31 + hash( plugin.getGroupId() );
+ hash = hash * 31 + hash( plugin.getArtifactId() );
+ hash = hash * 31 + hash( plugin.getVersion() );
+
+ hash = hash * 31 + ( plugin.isExtensions() ? 1 : 0 );
+
+ for ( Dependency dependency : plugin.getDependencies() )
+ {
+ hash = hash * 31 + hash( dependency.getGroupId() );
+ hash = hash * 31 + hash( dependency.getArtifactId() );
+ hash = hash * 31 + hash( dependency.getVersion() );
+ hash = hash * 31 + hash( dependency.getType() );
+ hash = hash * 31 + hash( dependency.getClassifier() );
+ hash = hash * 31 + hash( dependency.getScope() );
+
+ for ( Exclusion exclusion : dependency.getExclusions() )
+ {
+ hash = hash * 31 + hash( exclusion.getGroupId() );
+ hash = hash * 31 + hash( exclusion.getArtifactId() );
+ }
+ }
+
+ return hash;
+ }
+
+ public static boolean pluginEquals( Plugin a, Plugin b )
+ {
+ return eq( a.getArtifactId(), b.getArtifactId() ) //
+ && eq( a.getGroupId(), b.getGroupId() ) //
+ && eq( a.getVersion(), b.getVersion() ) //
+ && a.isExtensions() == b.isExtensions() //
+ && dependenciesEquals( a.getDependencies(), b.getDependencies() );
+ }
+
+ private static boolean dependenciesEquals( List<Dependency> a, List<Dependency> b )
+ {
+ if ( a.size() != b.size() )
+ {
+ return false;
+ }
+
+ Iterator<Dependency> aI = a.iterator();
+ Iterator<Dependency> bI = b.iterator();
+
+ while ( aI.hasNext() )
+ {
+ Dependency aD = aI.next();
+ Dependency bD = bI.next();
+
+ boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
+ && eq( aD.getArtifactId(), bD.getArtifactId() ) //
+ && eq( aD.getVersion(), bD.getVersion() ) //
+ && eq( aD.getType(), bD.getType() ) //
+ && eq( aD.getClassifier(), bD.getClassifier() ) //
+ && eq( aD.getScope(), bD.getScope() );
+
+ r &= exclusionsEquals( aD.getExclusions(), bD.getExclusions() );
+
+ if ( !r )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ private static boolean exclusionsEquals( List<Exclusion> a, List<Exclusion> b )
+ {
+ if ( a.size() != b.size() )
+ {
+ return false;
+ }
+
+ Iterator<Exclusion> aI = a.iterator();
+ Iterator<Exclusion> bI = b.iterator();
+
+ while ( aI.hasNext() )
+ {
+ Exclusion aD = aI.next();
+ Exclusion bD = bI.next();
+
+ boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
+ && eq( aD.getArtifactId(), bD.getArtifactId() );
+
+ if ( !r )
+ {
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ public static WorkspaceRepository getWorkspace( RepositorySystemSession session )
+ {
+ WorkspaceReader reader = session.getWorkspaceReader();
+ return ( reader != null ) ? reader.getRepository() : null;
+ }
+
+}
Propchange: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/CacheUtils.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultBuildPluginManager.java Tue Aug 24 22:46:07 2010
@@ -1,28 +1,24 @@
package org.apache.maven.plugin;
/*
- * 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.ByteArrayOutputStream;
import java.io.PrintStream;
+import java.util.List;
-import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
@@ -32,11 +28,13 @@ import org.codehaus.plexus.PlexusContain
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
// TODO: the antrun plugin has its own configurator, the only plugin that does. might need to think about how that works
// TODO: remove the coreArtifactFilterManager
-@Component( role = BuildPluginManager.class )
+@Component(role = BuildPluginManager.class)
public class DefaultBuildPluginManager
implements BuildPluginManager
{
@@ -51,19 +49,18 @@ public class DefaultBuildPluginManager
private LegacySupport legacySupport;
/**
- *
+ *
* @param plugin
* @param repositoryRequest
* @return PluginDescriptor The component descriptor for the Maven plugin.
* @throws PluginNotFoundException The plugin could not be found in any repositories.
* @throws PluginResolutionException The plugin could be found but could not be resolved.
- * @throws InvalidPluginDescriptorException
+ * @throws InvalidPluginDescriptorException
*/
- public PluginDescriptor loadPlugin( Plugin plugin, RepositoryRequest repositoryRequest )
- throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
- InvalidPluginDescriptorException
+ public PluginDescriptor loadPlugin( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
+ throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException
{
- return mavenPluginManager.getPluginDescriptor( plugin, repositoryRequest );
+ return mavenPluginManager.getPluginDescriptor( plugin, repositories, session );
}
// ----------------------------------------------------------------------
@@ -175,9 +172,9 @@ public class DefaultBuildPluginManager
/**
* TODO pluginDescriptor classRealm and artifacts are set as a side effect of this
* call, which is not nice.
- * @throws PluginResolutionException
+ * @throws PluginResolutionException
*/
- public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor )
+ public ClassRealm getPluginRealm( MavenSession session, PluginDescriptor pluginDescriptor )
throws PluginResolutionException, PluginManagerException
{
ClassRealm pluginRealm = pluginDescriptor.getClassRealm();
@@ -192,11 +189,12 @@ public class DefaultBuildPluginManager
return pluginDescriptor.getClassRealm();
}
- public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest repositoryRequest )
+ public MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
throws PluginNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
MojoNotFoundException, InvalidPluginDescriptorException
{
- return mavenPluginManager.getMojoDescriptor( plugin, goal, repositoryRequest );
+ return mavenPluginManager.getMojoDescriptor( plugin, goal, repositories, session );
}
}
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultExtensionRealmCache.java Tue Aug 24 22:46:07 2010
@@ -25,11 +25,11 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.ExtensionDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
+import org.sonatype.aether.artifact.Artifact;
/**
* Default extension realm cache implementation. Assumes cached data does not change.
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginArtifactsCache.java Tue Aug 24 22:46:07 2010
@@ -22,19 +22,18 @@ package org.apache.maven.plugin;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.annotations.Component;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.repository.LocalRepository;
+import org.sonatype.aether.repository.RemoteRepository;
+import org.sonatype.aether.repository.WorkspaceRepository;
/**
* @author Igor Fedorenko
@@ -46,36 +45,67 @@ public class DefaultPluginArtifactsCache
{
private static class CacheKey
+ implements Key
{
private final Plugin plugin;
- private final List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>();
+ private final WorkspaceRepository workspace;
- private final ArtifactFilter extensionArtifactFilter;
+ private final LocalRepository localRepo;
+
+ private final List<RemoteRepository> repositories;
+
+ private final DependencyFilter filter;
private final int hashCode;
- public CacheKey( Plugin plugin, RepositoryRequest repositoryRequest, ArtifactFilter extensionArtifactFilter )
+ public CacheKey( Plugin plugin, DependencyFilter extensionFilter, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
{
this.plugin = plugin.clone();
- this.repositories.add( repositoryRequest.getLocalRepository() );
- this.repositories.addAll( repositoryRequest.getRemoteRepositories() );
- this.extensionArtifactFilter = extensionArtifactFilter;
+ workspace = CacheUtils.getWorkspace( session );
+ this.localRepo = session.getLocalRepository();
+ this.repositories = new ArrayList<RemoteRepository>( repositories.size() );
+ for ( RemoteRepository repository : repositories )
+ {
+ if ( repository.isRepositoryManager() )
+ {
+ this.repositories.addAll( repository.getMirroredRepositories() );
+ }
+ else
+ {
+ this.repositories.add( repository );
+ }
+ }
+ this.filter = extensionFilter;
int hash = 17;
- hash = hash * 31 + pluginHashCode( plugin );
- hash = hash * 31 + repositories.hashCode();
- hash = hash * 31 + ( extensionArtifactFilter != null ? extensionArtifactFilter.hashCode() : 0 );
+ hash = hash * 31 + CacheUtils.pluginHashCode( plugin );
+ hash = hash * 31 + hash( workspace );
+ hash = hash * 31 + hash( localRepo );
+ hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
+ hash = hash * 31 + hash( extensionFilter );
this.hashCode = hash;
}
@Override
+ public String toString()
+ {
+ return plugin.getId();
+ }
+
+ @Override
public int hashCode()
{
return hashCode;
}
+ private static int hash( Object obj )
+ {
+ return obj != null ? obj.hashCode() : 0;
+ }
+
@Override
public boolean equals( Object o )
{
@@ -89,34 +119,43 @@ public class DefaultPluginArtifactsCache
return false;
}
- CacheKey other = (CacheKey) o;
+ CacheKey that = (CacheKey) o;
- return pluginEquals( plugin, other.plugin ) && eq( repositories, other.repositories )
- && eq( extensionArtifactFilter, other.extensionArtifactFilter );
+ return CacheUtils.pluginEquals( plugin, that.plugin ) && eq( workspace, that.workspace )
+ && eq( localRepo, that.localRepo ) && CacheUtils.repositoriesEquals( repositories, that.repositories )
+ && eq( filter, that.filter );
+ }
+
+ private static <T> boolean eq( T s1, T s2 )
+ {
+ return s1 != null ? s1.equals( s2 ) : s2 == null;
}
}
- protected final Map<CacheKey, CacheRecord> cache = new HashMap<CacheKey, CacheRecord>();
+ protected final Map<Key, CacheRecord> cache = new HashMap<Key, CacheRecord>();
- public CacheRecord get( Plugin plugin, RepositoryRequest repositoryRequest, ArtifactFilter extensionArtifactFilter )
+ public Key createKey( Plugin plugin, DependencyFilter extensionFilter, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
{
- return cache.get( new CacheKey( plugin, repositoryRequest, extensionArtifactFilter ) );
+ return new CacheKey( plugin, extensionFilter, repositories, session );
}
- public CacheRecord put( Plugin plugin, RepositoryRequest repositoryRequest, ArtifactFilter extensionArtifactFilter,
- List<Artifact> pluginArtifacts )
+ public CacheRecord get( Key key )
+ {
+ return cache.get( key );
+ }
+
+ public CacheRecord put( Key key, List<Artifact> pluginArtifacts )
{
if ( pluginArtifacts == null )
{
throw new NullPointerException();
}
- CacheKey key = new CacheKey( plugin, repositoryRequest, extensionArtifactFilter );
-
if ( cache.containsKey( key ) )
{
- throw new IllegalStateException( "Duplicate artifact resolution result for plugin " + plugin.getId() );
+ throw new IllegalStateException( "Duplicate artifact resolution result for plugin " + key );
}
CacheRecord record =
@@ -134,102 +173,12 @@ public class DefaultPluginArtifactsCache
protected static int pluginHashCode( Plugin plugin )
{
- int hash = 17;
-
- hash = hash * 31 + plugin.getGroupId().hashCode();
- hash = hash * 31 + plugin.getArtifactId().hashCode();
- hash = hash * 31 + plugin.getVersion().hashCode();
-
- for ( Dependency dependency : plugin.getDependencies() )
- {
- hash = hash * 31 + dependency.getGroupId().hashCode();
- hash = hash * 31 + dependency.getArtifactId().hashCode();
- hash = hash * 31 + dependency.getVersion().hashCode();
- hash = hash * 31 + dependency.getType().hashCode();
- hash = hash * 31 + ( dependency.getClassifier() != null ? dependency.getClassifier().hashCode() : 0 );
- hash = hash * 31 + ( dependency.getScope() != null ? dependency.getScope().hashCode() : 0 );
-
- for ( Exclusion exclusion : dependency.getExclusions() )
- {
- hash = hash * 31 + exclusion.getGroupId().hashCode();
- hash = hash * 31 + exclusion.getArtifactId().hashCode();
- }
- }
-
- return hash;
+ return CacheUtils.pluginHashCode( plugin );
}
protected static boolean pluginEquals( Plugin a, Plugin b )
{
- return eq( a.getGroupId(), b.getGroupId() ) //
- && eq( a.getArtifactId(), b.getArtifactId() ) //
- && eq( a.getVersion(), b.getVersion() ) //
- && dependenciesEquals( a.getDependencies(), b.getDependencies() );
- }
-
- private static boolean dependenciesEquals( List<Dependency> a, List<Dependency> b )
- {
- if ( a.size() != b.size() )
- {
- return false;
- }
-
- Iterator<Dependency> aI = a.iterator();
- Iterator<Dependency> bI = b.iterator();
-
- while ( aI.hasNext() )
- {
- Dependency aD = aI.next();
- Dependency bD = bI.next();
-
- boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
- && eq( aD.getArtifactId(), bD.getArtifactId() ) //
- && eq( aD.getVersion(), bD.getVersion() ) //
- && eq( aD.getType(), bD.getType() ) //
- && eq( aD.getClassifier(), bD.getClassifier() ) //
- && eq( aD.getScope(), bD.getScope() );
-
- r &= exclusionsEquals( aD.getExclusions(), bD.getExclusions() );
-
- if ( !r )
- {
- return false;
- }
- }
-
- return true;
- }
-
- private static boolean exclusionsEquals( List<Exclusion> a, List<Exclusion> b )
- {
- if ( a.size() != b.size() )
- {
- return false;
- }
-
- Iterator<Exclusion> aI = a.iterator();
- Iterator<Exclusion> bI = b.iterator();
-
- while ( aI.hasNext() )
- {
- Exclusion aD = aI.next();
- Exclusion bD = bI.next();
-
- boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
- && eq( aD.getArtifactId(), bD.getArtifactId() );
-
- if ( !r )
- {
- return false;
- }
- }
-
- return true;
- }
-
- private static <T> boolean eq( T s1, T s2 )
- {
- return s1 != null ? s1.equals( s2 ) : s2 == null;
+ return CacheUtils.pluginEquals( a, b );
}
public void register( MavenProject project, CacheRecord record )
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginDescriptorCache.java Tue Aug 24 22:46:07 2010
@@ -21,19 +21,19 @@ package org.apache.maven.plugin;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.apache.maven.artifact.ArtifactUtils;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.repository.ArtifactRepositoryPolicy;
-import org.apache.maven.artifact.repository.RepositoryRequest;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.repository.ComponentDescriptor;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.LocalRepository;
+import org.sonatype.aether.repository.RemoteRepository;
+import org.sonatype.aether.repository.WorkspaceRepository;
/**
* Caches raw plugin descriptors. A raw plugin descriptor is a descriptor that has just been extracted from the plugin
@@ -57,19 +57,19 @@ public class DefaultPluginDescriptorCach
descriptors.clear();
}
- public Key createKey( Plugin plugin, RepositoryRequest repositoryRequest )
+ public Key createKey( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
{
- return new CacheKey( plugin, repositoryRequest );
+ return new CacheKey( plugin, repositories, session );
}
- public void put( Key cacheKey, PluginDescriptor pluginDescriptor )
+ public PluginDescriptor get( Key cacheKey )
{
- descriptors.put( cacheKey, clone( pluginDescriptor ) );
+ return clone( descriptors.get( cacheKey ) );
}
- public PluginDescriptor get( Key cacheKey )
+ public void put( Key cacheKey, PluginDescriptor pluginDescriptor )
{
- return clone( descriptors.get( cacheKey ) );
+ descriptors.put( cacheKey, clone( pluginDescriptor ) );
}
private static PluginDescriptor clone( PluginDescriptor original )
@@ -129,25 +129,42 @@ public class DefaultPluginDescriptorCach
private final String version;
- private final List<ArtifactRepository> repositories;
+ private final WorkspaceRepository workspace;
+
+ private final LocalRepository localRepo;
+
+ private final List<RemoteRepository> repositories;
private final int hashCode;
- public CacheKey( Plugin plugin, RepositoryRequest repositoryRequest )
+ public CacheKey( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
{
groupId = plugin.getGroupId();
artifactId = plugin.getArtifactId();
version = plugin.getVersion();
- repositories = new ArrayList<ArtifactRepository>( repositoryRequest.getRemoteRepositories().size() + 1 );
- repositories.add( repositoryRequest.getLocalRepository() );
- repositories.addAll( repositoryRequest.getRemoteRepositories() );
+ workspace = CacheUtils.getWorkspace( session );
+ localRepo = session.getLocalRepository();
+ this.repositories = new ArrayList<RemoteRepository>( repositories.size() );
+ for ( RemoteRepository repository : repositories )
+ {
+ if ( repository.isRepositoryManager() )
+ {
+ this.repositories.addAll( repository.getMirroredRepositories() );
+ }
+ else
+ {
+ this.repositories.add( repository );
+ }
+ }
int hash = 17;
hash = hash * 31 + groupId.hashCode();
hash = hash * 31 + artifactId.hashCode();
hash = hash * 31 + version.hashCode();
- hash = hash * 31 + repositoriesHashCode( repositories );
+ hash = hash * 31 + hash( workspace );
+ hash = hash * 31 + localRepo.hashCode();
+ hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
this.hashCode = hash;
}
@@ -172,8 +189,10 @@ public class DefaultPluginDescriptorCach
CacheKey that = (CacheKey) obj;
- return this.artifactId.equals( that.artifactId ) && this.groupId.equals( that.groupId )
- && this.version.equals( that.version ) && repositoriesEquals( this.repositories, that.repositories );
+ return eq( this.artifactId, that.artifactId ) && eq( this.groupId, that.groupId )
+ && eq( this.version, that.version ) && eq( this.localRepo, that.localRepo )
+ && eq( this.workspace, that.workspace )
+ && CacheUtils.repositoriesEquals( this.repositories, that.repositories );
}
@Override
@@ -182,61 +201,9 @@ public class DefaultPluginDescriptorCach
return groupId + ':' + artifactId + ':' + version;
}
- private static int repositoryHashCode( ArtifactRepository repository )
- {
- int result = 17;
- result = 31 * result + ( repository.getId() != null ? repository.getId().hashCode() : 0 );
- return result;
- }
-
- private static int repositoriesHashCode( List<ArtifactRepository> repositories )
- {
- int result = 17;
- for ( ArtifactRepository repository : repositories )
- {
- result = 31 * result + repositoryHashCode( repository );
- }
- return result;
- }
-
- private static boolean repositoryEquals( ArtifactRepository r1, ArtifactRepository r2 )
+ private static int hash( Object obj )
{
- if ( r1 == r2 )
- {
- return true;
- }
-
- return eq( r1.getId(), r2.getId() ) && eq( r1.getUrl(), r2.getUrl() )
- && repositoryPolicyEquals( r1.getReleases(), r2.getReleases() )
- && repositoryPolicyEquals( r1.getSnapshots(), r2.getSnapshots() );
- }
-
- private static boolean repositoryPolicyEquals( ArtifactRepositoryPolicy p1, ArtifactRepositoryPolicy p2 )
- {
- if ( p1 == p2 )
- {
- return true;
- }
-
- return p1.isEnabled() == p2.isEnabled() && eq( p1.getUpdatePolicy(), p2.getUpdatePolicy() );
- }
-
- private static boolean repositoriesEquals( List<ArtifactRepository> r1, List<ArtifactRepository> r2 )
- {
- if ( r1.size() != r2.size() )
- {
- return false;
- }
-
- for ( Iterator<ArtifactRepository> it1 = r1.iterator(), it2 = r2.iterator(); it1.hasNext(); )
- {
- if ( !repositoryEquals( it1.next(), it2.next() ) )
- {
- return false;
- }
- }
-
- return true;
+ return obj != null ? obj.hashCode() : 0;
}
private static <T> boolean eq( T s1, T s2 )
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginRealmCache.java Tue Aug 24 22:46:07 2010
@@ -21,20 +21,20 @@ package org.apache.maven.plugin;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.ArtifactRepository;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.Exclusion;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
import org.codehaus.plexus.component.annotations.Component;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.repository.LocalRepository;
+import org.sonatype.aether.repository.RemoteRepository;
+import org.sonatype.aether.repository.WorkspaceRepository;
/**
* Default PluginCache implementation. Assumes cached data does not change.
@@ -45,45 +45,76 @@ public class DefaultPluginRealmCache
{
protected static class CacheKey
+ implements Key
{
+
private final Plugin plugin;
- private final List<ArtifactRepository> repositories = new ArrayList<ArtifactRepository>();
+ private final WorkspaceRepository workspace;
+
+ private final LocalRepository localRepo;
+
+ private final List<RemoteRepository> repositories;
private final ClassLoader parentRealm;
private final List<String> parentImports;
- private final ArtifactFilter filter;
+ private final DependencyFilter filter;
private final int hashCode;
public CacheKey( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
- ArtifactFilter dependencyFilter, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepositories )
+ DependencyFilter dependencyFilter, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
{
this.plugin = plugin.clone();
- this.repositories.add( localRepository );
- this.repositories.addAll( remoteRepositories );
+ this.workspace = CacheUtils.getWorkspace( session );
+ this.localRepo = session.getLocalRepository();
+ this.repositories = new ArrayList<RemoteRepository>( repositories.size() );
+ for ( RemoteRepository repository : repositories )
+ {
+ if ( repository.isRepositoryManager() )
+ {
+ this.repositories.addAll( repository.getMirroredRepositories() );
+ }
+ else
+ {
+ this.repositories.add( repository );
+ }
+ }
this.parentRealm = parentRealm;
this.parentImports = ( parentImports != null ) ? parentImports : Collections.<String> emptyList();
this.filter = dependencyFilter;
int hash = 17;
- hash = hash * 31 + pluginHashCode( plugin );
- hash = hash * 31 + repositories.hashCode();
- hash = hash * 31 + ( parentRealm != null ? parentRealm.hashCode() : 0 );
+ hash = hash * 31 + CacheUtils.pluginHashCode( plugin );
+ hash = hash * 31 + hash( workspace );
+ hash = hash * 31 + hash( localRepo );
+ hash = hash * 31 + CacheUtils.repositoriesHashCode( repositories );
+ hash = hash * 31 + hash( parentRealm );
hash = hash * 31 + this.parentImports.hashCode();
- hash = hash * 31 + ( dependencyFilter != null ? dependencyFilter.hashCode() : 0 );
+ hash = hash * 31 + hash( dependencyFilter );
this.hashCode = hash;
}
@Override
+ public String toString()
+ {
+ return plugin.getId();
+ }
+
+ @Override
public int hashCode()
{
return hashCode;
}
+ private static int hash( Object obj )
+ {
+ return obj != null ? obj.hashCode() : 0;
+ }
+
@Override
public boolean equals( Object o )
{
@@ -97,40 +128,45 @@ public class DefaultPluginRealmCache
return false;
}
- CacheKey other = (CacheKey) o;
+ CacheKey that = (CacheKey) o;
- return parentRealm == other.parentRealm && pluginEquals( plugin, other.plugin )
- && eq( repositories, other.repositories ) && eq( filter, other.filter )
- && eq( parentImports, other.parentImports );
+ return parentRealm == that.parentRealm && CacheUtils.pluginEquals( plugin, that.plugin )
+ && eq( workspace, that.workspace ) && eq( localRepo, that.localRepo )
+ && CacheUtils.repositoriesEquals( this.repositories, that.repositories ) && eq( filter, that.filter )
+ && eq( parentImports, that.parentImports );
}
+
+ private static <T> boolean eq( T s1, T s2 )
+ {
+ return s1 != null ? s1.equals( s2 ) : s2 == null;
+ }
+
}
- protected final Map<CacheKey, CacheRecord> cache = new ConcurrentHashMap<CacheKey, CacheRecord>();
+ protected final Map<Key, CacheRecord> cache = new ConcurrentHashMap<Key, CacheRecord>();
- public CacheRecord get( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
- ArtifactFilter dependencyFilter, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepositories )
+ public Key createKey( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
+ DependencyFilter dependencyFilter, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
{
- return cache.get( new CacheKey( plugin, parentRealm, parentImports, dependencyFilter, localRepository,
- remoteRepositories ) );
+ return new CacheKey( plugin, parentRealm, parentImports, dependencyFilter, repositories, session );
}
- public CacheRecord put( Plugin plugin, ClassLoader parentRealm, List<String> parentImports,
- ArtifactFilter dependencyFilter, ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepositories, ClassRealm pluginRealm,
- List<Artifact> pluginArtifacts )
+ public CacheRecord get( Key key )
+ {
+ return cache.get( key );
+ }
+
+ public CacheRecord put( Key key, ClassRealm pluginRealm, List<Artifact> pluginArtifacts )
{
if ( pluginRealm == null || pluginArtifacts == null )
{
- throw new NullPointerException();
+ throw new IllegalArgumentException();
}
- CacheKey key =
- new CacheKey( plugin, parentRealm, parentImports, dependencyFilter, localRepository, remoteRepositories );
-
if ( cache.containsKey( key ) )
{
- throw new IllegalStateException( "Duplicate plugin realm for plugin " + plugin.getId() );
+ throw new IllegalStateException( "Duplicate plugin realm for plugin " + key );
}
CacheRecord record = new CacheRecord( pluginRealm, pluginArtifacts );
@@ -147,105 +183,12 @@ public class DefaultPluginRealmCache
protected static int pluginHashCode( Plugin plugin )
{
- int hash = 17;
-
- hash = hash * 31 + plugin.getGroupId().hashCode();
- hash = hash * 31 + plugin.getArtifactId().hashCode();
- hash = hash * 31 + plugin.getVersion().hashCode();
-
- hash = hash * 31 + ( plugin.isExtensions() ? 1 : 0 );
-
- for ( Dependency dependency : plugin.getDependencies() )
- {
- hash = hash * 31 + dependency.getGroupId().hashCode();
- hash = hash * 31 + dependency.getArtifactId().hashCode();
- hash = hash * 31 + dependency.getVersion().hashCode();
- hash = hash * 31 + dependency.getType().hashCode();
- hash = hash * 31 + ( dependency.getClassifier() != null ? dependency.getClassifier().hashCode() : 0 );
- hash = hash * 31 + ( dependency.getScope() != null ? dependency.getScope().hashCode() : 0 );
-
- for ( Exclusion exclusion : dependency.getExclusions() )
- {
- hash = hash * 31 + exclusion.getGroupId().hashCode();
- hash = hash * 31 + exclusion.getArtifactId().hashCode();
- }
- }
-
- return hash;
+ return CacheUtils.pluginHashCode( plugin );
}
protected static boolean pluginEquals( Plugin a, Plugin b )
{
- return eq( a.getGroupId(), b.getGroupId() ) //
- && eq( a.getArtifactId(), b.getArtifactId() ) //
- && eq( a.getVersion(), b.getVersion() ) //
- && a.isExtensions() == b.isExtensions() //
- && dependenciesEquals( a.getDependencies(), b.getDependencies() );
- }
-
- private static boolean dependenciesEquals( List<Dependency> a, List<Dependency> b )
- {
- if ( a.size() != b.size() )
- {
- return false;
- }
-
- Iterator<Dependency> aI = a.iterator();
- Iterator<Dependency> bI = b.iterator();
-
- while ( aI.hasNext() )
- {
- Dependency aD = aI.next();
- Dependency bD = bI.next();
-
- boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
- && eq( aD.getArtifactId(), bD.getArtifactId() ) //
- && eq( aD.getVersion(), bD.getVersion() ) //
- && eq( aD.getType(), bD.getType() ) //
- && eq( aD.getClassifier(), bD.getClassifier() ) //
- && eq( aD.getScope(), bD.getScope() );
-
- r &= exclusionsEquals( aD.getExclusions(), bD.getExclusions() );
-
- if ( !r )
- {
- return false;
- }
- }
-
- return true;
- }
-
- private static boolean exclusionsEquals( List<Exclusion> a, List<Exclusion> b )
- {
- if ( a.size() != b.size() )
- {
- return false;
- }
-
- Iterator<Exclusion> aI = a.iterator();
- Iterator<Exclusion> bI = b.iterator();
-
- while ( aI.hasNext() )
- {
- Exclusion aD = aI.next();
- Exclusion bD = bI.next();
-
- boolean r = eq( aD.getGroupId(), bD.getGroupId() ) //
- && eq( aD.getArtifactId(), bD.getArtifactId() );
-
- if ( !r )
- {
- return false;
- }
- }
-
- return true;
- }
-
- private static <T> boolean eq( T s1, T s2 )
- {
- return s1 != null ? s1.equals( s2 ) : s2 == null;
+ return CacheUtils.pluginEquals( a, b );
}
public void register( MavenProject project, CacheRecord record )
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/ExtensionRealmCache.java Tue Aug 24 22:46:07 2010
@@ -21,10 +21,10 @@ package org.apache.maven.plugin;
import java.util.List;
-import org.apache.maven.artifact.Artifact;
import org.apache.maven.project.ExtensionDescriptor;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.classworlds.realm.ClassRealm;
+import org.sonatype.aether.artifact.Artifact;
/**
* Caches extension class realms. <strong>Warning:</strong> This is an internal utility interface that is only public
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginDescriptorException.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginDescriptorException.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginDescriptorException.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/InvalidPluginDescriptorException.java Tue Aug 24 22:46:07 2010
@@ -24,12 +24,10 @@ import java.util.List;
public class InvalidPluginDescriptorException
extends Exception
{
- private List<String> errors;
public InvalidPluginDescriptorException( String message, List<String> errors )
{
super( toMessage( message, errors ) );
- this.errors = errors;
}
private static String toMessage( String message, List<String> errors )
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/LegacySupport.java Tue Aug 24 22:46:07 2010
@@ -20,6 +20,7 @@ package org.apache.maven.plugin;
*/
import org.apache.maven.execution.MavenSession;
+import org.sonatype.aether.RepositorySystemSession;
/**
* Helps to provide backward-compatibility with plugins that use legacy components. <strong>Warning:</strong> This is an
@@ -48,4 +49,11 @@ public interface LegacySupport
*/
MavenSession getSession();
+ /**
+ * Gets the currently active repository session.
+ *
+ * @return The currently active repository session or {@code null} if none.
+ */
+ RepositorySystemSession getRepositorySession();
+
}
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/MavenPluginManager.java Tue Aug 24 22:46:07 2010
@@ -21,12 +21,13 @@ package org.apache.maven.plugin;
import java.util.List;
-import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.MojoDescriptor;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.repository.RemoteRepository;
/**
* Provides basic services to manage Maven plugins and their mojos. This component is kept general in its design such
@@ -43,11 +44,12 @@ public interface MavenPluginManager
* Retrieves the descriptor for the specified plugin from its main artifact.
*
* @param plugin The plugin whose descriptor should be retrieved, must not be {@code null}.
- * @param repositoryRequest The repository request to use for resolving the plugin's main artifact, must not be
- * {@code null}.
+ * @param repositories The plugin repositories to use for resolving the plugin's main artifact, must not be {@code
+ * null}.
+ * @param session The repository session to use for resolving the plugin's main artifact, must not be {@code null}.
* @return The plugin descriptor, never {@code null}.
*/
- PluginDescriptor getPluginDescriptor( Plugin plugin, RepositoryRequest repositoryRequest )
+ PluginDescriptor getPluginDescriptor( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session )
throws PluginResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException;
/**
@@ -55,11 +57,13 @@ public interface MavenPluginManager
*
* @param plugin The plugin whose mojo descriptor should be retrieved, must not be {@code null}.
* @param goal The simple name of the mojo whose descriptor should be retrieved, must not be {@code null}.
- * @param repositoryRequest The repository request to use for resolving the plugin's main artifact, must not be
- * {@code null}.
+ * @param repositories The plugin repositories to use for resolving the plugin's main artifact, must not be {@code
+ * null}.
+ * @param session The repository session to use for resolving the plugin's main artifact, must not be {@code null}.
* @return The mojo descriptor, never {@code null}.
*/
- MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, RepositoryRequest repositoryRequest )
+ MojoDescriptor getMojoDescriptor( Plugin plugin, String goal, List<RemoteRepository> repositories,
+ RepositorySystemSession session )
throws MojoNotFoundException, PluginResolutionException, PluginDescriptorParsingException,
InvalidPluginDescriptorException;
@@ -76,7 +80,7 @@ public interface MavenPluginManager
* @param filter The filter used to exclude certain plugin dependencies, may be {@code null}.
*/
void setupPluginRealm( PluginDescriptor pluginDescriptor, MavenSession session, ClassLoader parent,
- List<String> imports, ArtifactFilter filter )
+ List<String> imports, DependencyFilter filter )
throws PluginResolutionException, PluginContainerException;
/**
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginArtifactsCache.java Tue Aug 24 22:46:07 2010
@@ -21,11 +21,12 @@ package org.apache.maven.plugin;
import java.util.List;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.repository.RepositoryRequest;
-import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
import org.apache.maven.model.Plugin;
import org.apache.maven.project.MavenProject;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.artifact.Artifact;
+import org.sonatype.aether.graph.DependencyFilter;
+import org.sonatype.aether.repository.RemoteRepository;
/**
* Caches plugin artifacts. <strong>Warning:</strong> This is an internal utility interface that is only public for
@@ -38,6 +39,14 @@ import org.apache.maven.project.MavenPro
public interface PluginArtifactsCache
{
+ /**
+ * A cache key.
+ */
+ interface Key
+ {
+ // marker interface for cache keys
+ }
+
public static class CacheRecord
{
@@ -50,10 +59,12 @@ public interface PluginArtifactsCache
}
- CacheRecord get( Plugin plugin, RepositoryRequest repositoryRequest, ArtifactFilter extensionArtifactFilter );
+ Key createKey( Plugin plugin, DependencyFilter extensionFilter, List<RemoteRepository> repositories,
+ RepositorySystemSession session );
+
+ CacheRecord get( Key key );
- CacheRecord put( Plugin plugin, RepositoryRequest repositoryRequest, ArtifactFilter extensionArtifactFilter,
- List<Artifact> pluginArtifacts );
+ CacheRecord put( Key key, List<Artifact> pluginArtifacts );
void flush();
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorCache.java Tue Aug 24 22:46:07 2010
@@ -19,9 +19,12 @@ package org.apache.maven.plugin;
* under the License.
*/
-import org.apache.maven.artifact.repository.RepositoryRequest;
+import java.util.List;
+
import org.apache.maven.model.Plugin;
import org.apache.maven.plugin.descriptor.PluginDescriptor;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
/**
* Caches raw plugin descriptors. A raw plugin descriptor is a descriptor that has just been extracted from the plugin
@@ -44,11 +47,11 @@ public interface PluginDescriptorCache
// marker interface for cache keys
}
- Key createKey( Plugin plugin, RepositoryRequest repositoryRequest );
+ Key createKey( Plugin plugin, List<RemoteRepository> repositories, RepositorySystemSession session );
- void put( Key cacheKey, PluginDescriptor pluginDescriptor );
+ void put( Key key, PluginDescriptor pluginDescriptor );
- PluginDescriptor get( Key cacheKey );
+ PluginDescriptor get( Key key );
void flush();
Modified: maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java
URL: http://svn.apache.org/viewvc/maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java?rev=988749&r1=988748&r2=988749&view=diff
==============================================================================
--- maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java (original)
+++ maven/maven-3/trunk/maven-core/src/main/java/org/apache/maven/plugin/PluginDescriptorParsingException.java Tue Aug 24 22:46:07 2010
@@ -28,12 +28,9 @@ public class PluginDescriptorParsingExce
extends Exception
{
- private Plugin plugin;
-
public PluginDescriptorParsingException( Plugin plugin, String descriptorLocation, Throwable e )
{
super( createMessage( plugin, descriptorLocation, e ), e );
- this.plugin = plugin;
}
private static String createMessage( Plugin plugin, String descriptorLocation, Throwable e )