You are viewing a plain text version of this content. The canonical link for it is here.
Posted to m2-dev@maven.apache.org by mi...@apache.org on 2004/06/27 19:02:17 UTC
cvs commit: maven-components/maven-core/src/test/resources/projects fully-populated-child.xml project.xml
michal 2004/06/27 10:02:17
Modified: maven-core/src/main/java/org/apache/maven/artifact/deployer
DefaultArtifactDeployer.java
maven-core/src/main/java/org/apache/maven/lifecycle/phase
DependencyDownloadPhase.java
DependencyResolutionPhase.java
GoalAttainmentPhase.java GoalResolutionPhase.java
PluginDependencyDownloadPhase.java
PluginDependencyResolutionPhase.java
maven-core/src/main/java/org/apache/maven/lifecycle
MavenLifecycleContext.java
maven-core/src/test/java/org/apache/maven/project/inheritance/t00
ProjectInheritanceTest.java
maven-core/src/test/resources/projects
fully-populated-child.xml project.xml
Log:
trying to pair up lookup and release methods
Revision Changes Path
1.7 +5 -7 maven-components/maven-core/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java
Index: DefaultArtifactDeployer.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/artifact/deployer/DefaultArtifactDeployer.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DefaultArtifactDeployer.java 24 Jun 2004 16:27:22 -0000 1.6
+++ DefaultArtifactDeployer.java 27 Jun 2004 17:02:17 -0000 1.7
@@ -19,18 +19,16 @@
import org.apache.maven.project.MavenProject;
import org.apache.maven.artifact.factory.MavenArtifactFactory;
import org.apache.maven.artifact.MavenArtifact;
-import org.apache.maven.artifact.installer.ArtifactInstaller;
import org.apache.maven.artifact.snapshot.SnapshotUtils;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.DistributionManagement;
import org.apache.maven.wagon.manager.WagonManager;
import org.apache.maven.wagon.Wagon;
import org.apache.maven.wagon.ConnectionException;
-import org.apache.maven.wagon.PathUtils;
import org.apache.maven.wagon.WagonUtils;
import org.apache.maven.wagon.observers.ChecksumObserver;
import org.apache.maven.wagon.repository.Repository;
-import org.codehaus.plexus.util.FileUtils;
+
import java.io.File;
@@ -59,7 +57,7 @@
if ( distributionManagement == null )
{
- String msg = "distributionManagment element is missing in the POM: "
+ String msg = "distributionManagement element is missing in the POM: "
+ project.getId();
throw new Exception( msg );
@@ -70,7 +68,7 @@
if ( distributionManagement.getRepository() == null )
{
- String msg = "distributionManagment/repository element is missing in the POM: "
+ String msg = "distributionManagement/repository element is missing in the POM: "
+ project.getId();
throw new Exception( msg );
@@ -83,7 +81,7 @@
if ( url == null )
{
- String msg = "distributionManagment/repository/url element is missing in the POM: "
+ String msg = "distributionManagement/repository/url element is missing in the POM: "
+ project.getId();
throw new Exception( msg );
1.3 +24 -12 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/DependencyDownloadPhase.java
Index: DependencyDownloadPhase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/DependencyDownloadPhase.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DependencyDownloadPhase.java 24 Jun 2004 16:27:23 -0000 1.2
+++ DependencyDownloadPhase.java 27 Jun 2004 17:02:17 -0000 1.3
@@ -30,25 +30,37 @@
* @version $Id$
*/
public class DependencyDownloadPhase
- extends AbstractMavenLifecyclePhase
+ extends AbstractMavenLifecyclePhase
{
public void execute( MavenLifecycleContext context )
- throws Exception
+ throws Exception
{
- ArtifactResolver artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
+ ArtifactResolver artifactResolver = null;
- List repositories = context.getProject().getRepositories();
- String mavenRepoLocal = context.getProject().getProperty( MavenConstants.MAVEN_REPO_LOCAL );
+ try
+ {
+ artifactResolver = ( ArtifactResolver ) context.lookup( ArtifactResolver.ROLE );
+
+ List repositories = context.getProject().getRepositories();
+
+ String mavenRepoLocal = context.getProject().getProperty( MavenConstants.MAVEN_REPO_LOCAL );
- for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
+ for ( Iterator it = context.getProject().getArtifacts().iterator(); it.hasNext(); )
+ {
+ MavenArtifact artifact = ( MavenArtifact ) it.next();
+
+ artifactResolver.getArtifact( artifact.getDependency(),
+ artifact.getDependency().getType(),
+ mavenRepoLocal,
+ repositories );
+ }
+ }
+ finally
{
- MavenArtifact artifact = (MavenArtifact) it.next();
+ context.release( artifactResolver );
- artifactResolver.getArtifact( artifact.getDependency(),
- artifact.getDependency().getType(),
- mavenRepoLocal,
- repositories );
}
}
+
}
1.8 +20 -6 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/DependencyResolutionPhase.java
Index: DependencyResolutionPhase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/DependencyResolutionPhase.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DependencyResolutionPhase.java 27 Jun 2004 07:39:08 -0000 1.7
+++ DependencyResolutionPhase.java 27 Jun 2004 17:02:17 -0000 1.8
@@ -51,14 +51,28 @@
private void resolveTransitiveDependencies( MavenLifecycleContext context )
throws Exception
{
- MavenProject project = context.getProject();
+ ArtifactCollector artifactCollector = null;
- ArtifactCollector artifactCollector = (ArtifactCollector) context.lookup( ArtifactCollector.ROLE );
+ MavenProjectBuilder builder = null;
+
+ try
+ {
+ MavenProject project = context.getProject();
- MavenProjectBuilder builder = (MavenProjectBuilder) context.lookup( MavenProjectBuilder.ROLE );
+ artifactCollector = (ArtifactCollector) context.lookup( ArtifactCollector.ROLE );
- ArtifactCollectionResult result = artifactCollector.collect( project.getArtifacts(), project.getLocalRepository(), project.getRepositories(), builder );
+ builder = (MavenProjectBuilder) context.lookup( MavenProjectBuilder.ROLE );
- project.getArtifacts().addAll( result.getArtifacts().values() );
+ ArtifactCollectionResult result = artifactCollector.collect( project.getArtifacts(), project.getLocalRepository(), project.getRepositories(), builder );
+
+ project.getArtifacts().addAll( result.getArtifacts().values() );
+ }
+ finally
+ {
+ context.release( artifactCollector );
+
+ context.release( builder );
+
+ }
}
}
1.11 +45 -6 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalAttainmentPhase.java
Index: GoalAttainmentPhase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalAttainmentPhase.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- GoalAttainmentPhase.java 24 Jun 2004 16:27:23 -0000 1.10
+++ GoalAttainmentPhase.java 27 Jun 2004 17:02:17 -0000 1.11
@@ -58,16 +58,28 @@
response = new PluginExecutionResponse();
- Plugin plugin = (Plugin) context.lookup( Plugin.ROLE, context.getPluginId( mojoDescriptor ) );
+ Plugin plugin = null;
- plugin.execute( request, response );
+ try
+ {
+ plugin = (Plugin) context.lookup( Plugin.ROLE, context.getPluginId( mojoDescriptor ) );
+
+ plugin.execute( request, response );
+
+ if ( response.isExecutionFailure() )
+ {
+ context.setExecutionFailure( mojoDescriptor.getId(), response.getFailureResponse() );
- if ( response.isExecutionFailure() )
+ break;
+ }
+ }
+ finally
{
- context.setExecutionFailure( mojoDescriptor.getId(), response.getFailureResponse() );
+ releaseComponents( mojoDescriptor, request, context );
- break;
+ context.release( plugin );
}
+
}
}
@@ -101,5 +113,32 @@
}
return map;
+ }
+
+
+
+ private void releaseComponents( MojoDescriptor goal, PluginExecutionRequest request, MavenLifecycleContext context )
+ {
+
+ if ( request != null && request.getParameters() != null )
+ {
+
+ for ( Iterator iterator = goal.getParameters().iterator(); iterator.hasNext(); )
+ {
+ Parameter parameter = (Parameter) iterator.next();
+
+ String key = parameter.getName();
+
+ String expression = parameter.getExpression();
+
+ if ( expression != null & expression.startsWith( "#component" ) )
+ {
+ Object component = request.getParameter( key );
+
+ context.release( component );
+ }
+ }
+ }
+
}
}
1.6 +24 -14 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalResolutionPhase.java
Index: GoalResolutionPhase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/GoalResolutionPhase.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- GoalResolutionPhase.java 24 Jun 2004 16:27:23 -0000 1.5
+++ GoalResolutionPhase.java 27 Jun 2004 17:02:17 -0000 1.6
@@ -32,22 +32,32 @@
public void execute( MavenLifecycleContext context )
throws Exception
{
- // Here will will end up getting information about preGoals and postGoals and
- // the calculation here will get more sophisticated.
- PluginManager pluginManager = (PluginManager) context.getContainer().lookup( PluginManager.ROLE );
+ PluginManager pluginManager = null;
- List goals = pluginManager.getGoals( context.getMojoDescriptor().getId() );
+ try
+ {
+ // Here will will end up getting information about preGoals and postGoals and
+ // the calculation here will get more sophisticated.
- // Once we have the list of goals that the user has specified then we must process
- // this list and determine the decorations, then for each of the decorations we
- // must calculate the goal chain it produces. Then we mesh together all the graphs
- // and we can probably optimize.
- //
- // We will most likely have goals like "clean" which are executed regardless of whether
- // it has been executed or not and we may have goals for which duplicate execution can
- // be eliminated.
+ pluginManager = (PluginManager) context.getContainer().lookup( PluginManager.ROLE );
- context.setResolvedGoals( goals );
+ List goals = pluginManager.getGoals( context.getMojoDescriptor().getId() );
+
+ // Once we have the list of goals that the user has specified then we must process
+ // this list and determine the decorations, then for each of the decorations we
+ // must calculate the goal chain it produces. Then we mesh together all the graphs
+ // and we can probably optimize.
+ //
+ // We will most likely have goals like "clean" which are executed regardless of whether
+ // it has been executed or not and we may have goals for which duplicate execution can
+ // be eliminated.
+
+ context.setResolvedGoals( goals );
+ }
+ finally
+ {
+ context.release( pluginManager );
+ }
}
}
1.2 +20 -11 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/PluginDependencyDownloadPhase.java
Index: PluginDependencyDownloadPhase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/PluginDependencyDownloadPhase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PluginDependencyDownloadPhase.java 27 Jun 2004 07:39:08 -0000 1.1
+++ PluginDependencyDownloadPhase.java 27 Jun 2004 17:02:17 -0000 1.2
@@ -35,20 +35,29 @@
public void execute( MavenLifecycleContext context )
throws Exception
{
- ArtifactResolver artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
+ ArtifactResolver artifactResolver = null;
- String mavenRepoLocal = context.getProject().getProperty( MavenConstants.MAVEN_REPO_LOCAL );
+ try
+ {
+ artifactResolver = (ArtifactResolver) context.lookup( ArtifactResolver.ROLE );
- List repositories = context.getProject().getRepositories();
+ String mavenRepoLocal = context.getProject().getProperty( MavenConstants.MAVEN_REPO_LOCAL );
- for ( Iterator it = context.getPluginDependencies().iterator(); it.hasNext(); )
- {
- MavenArtifact artifact = (MavenArtifact) it.next();
+ List repositories = context.getProject().getRepositories();
- artifactResolver.getArtifact( artifact.getDependency(),
- artifact.getDependency().getType(),
- mavenRepoLocal,
- repositories );
+ for ( Iterator it = context.getPluginDependencies().iterator(); it.hasNext(); )
+ {
+ MavenArtifact artifact = (MavenArtifact) it.next();
+
+ artifactResolver.getArtifact( artifact.getDependency(),
+ artifact.getDependency().getType(),
+ mavenRepoLocal,
+ repositories );
+ }
+ }
+ finally
+ {
+ context.release( artifactResolver );
}
}
}
1.2 +38 -14 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/PluginDependencyResolutionPhase.java
Index: PluginDependencyResolutionPhase.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/phase/PluginDependencyResolutionPhase.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- PluginDependencyResolutionPhase.java 27 Jun 2004 07:39:08 -0000 1.1
+++ PluginDependencyResolutionPhase.java 27 Jun 2004 17:02:17 -0000 1.2
@@ -43,37 +43,61 @@
public void execute( MavenLifecycleContext context )
throws Exception
{
- PluginManager pluginManager = (PluginManager) context.lookup( PluginManager.ROLE );
+ PluginManager pluginManager = null;
- Set dependencies = context.getPluginDependencies();
-
- for ( Iterator plugins = pluginManager.getPluginDescriptors().values().iterator(); plugins.hasNext(); )
+ try
{
- PluginDescriptor plugin = (PluginDescriptor) plugins.next();
+ pluginManager = (PluginManager) context.lookup( PluginManager.ROLE );
+
+ Set dependencies = context.getPluginDependencies();
- for ( Iterator it = plugin.getDependencies().iterator(); it.hasNext(); )
+ for ( Iterator plugins = pluginManager.getPluginDescriptors().values().iterator(); plugins.hasNext(); )
{
- Dependency dependency = (Dependency) it.next();
+ PluginDescriptor plugin = (PluginDescriptor) plugins.next();
- dependencies.add( createArtifact( dependency ) );
+ for ( Iterator it = plugin.getDependencies().iterator(); it.hasNext(); )
+ {
+ Dependency dependency = (Dependency) it.next();
+
+ dependencies.add( createArtifact( dependency ) );
+ }
}
+
+ resolveTransitiveDependencies( context, new ArrayList( dependencies ) );
}
+ finally
+ {
- resolveTransitiveDependencies( context, new ArrayList( dependencies ) );
+ context.release( pluginManager );
+ }
}
private void resolveTransitiveDependencies( MavenLifecycleContext context, List dependencies )
throws Exception
{
+ ArtifactCollector artifactCollector = null;
+
+ MavenProjectBuilder builder = null;
+
MavenProject project = context.getProject();
- ArtifactCollector artifactCollector = (ArtifactCollector) context.lookup( ArtifactCollector.ROLE );
+ try
+ {
+ artifactCollector = (ArtifactCollector) context.lookup( ArtifactCollector.ROLE );
- MavenProjectBuilder builder = (MavenProjectBuilder) context.lookup( MavenProjectBuilder.ROLE );
+ builder = (MavenProjectBuilder) context.lookup( MavenProjectBuilder.ROLE );
- ArtifactCollectionResult result = artifactCollector.collect( dependencies, project.getLocalRepository(), project.getRepositories(), builder );
+ ArtifactCollectionResult result = artifactCollector.collect( dependencies, project.getLocalRepository(), project.getRepositories(), builder );
- dependencies.addAll( result.getArtifacts().values() );
+ dependencies.addAll( result.getArtifacts().values() );
+ }
+ finally
+ {
+
+ context.release( artifactCollector );
+
+ context.release( builder);
+ }
}
private MavenArtifact createArtifact( Dependency dependency )
1.10 +18 -1 maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecycleContext.java
Index: MavenLifecycleContext.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/main/java/org/apache/maven/lifecycle/MavenLifecycleContext.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- MavenLifecycleContext.java 27 Jun 2004 07:39:08 -0000 1.9
+++ MavenLifecycleContext.java 27 Jun 2004 17:02:17 -0000 1.10
@@ -83,6 +83,23 @@
return container.lookup( role, roleHint );
}
+
+ public void release( Object component )
+ {
+ if ( component != null )
+ {
+ try
+ {
+ container.release( component );
+ }
+ catch ( Exception e )
+ {
+ //@todo what to do here?
+ }
+ }
+
+ }
+
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
1.4 +4 -1 maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java
Index: ProjectInheritanceTest.java
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/test/java/org/apache/maven/project/inheritance/t00/ProjectInheritanceTest.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- ProjectInheritanceTest.java 24 Jun 2004 00:27:38 -0000 1.3
+++ ProjectInheritanceTest.java 27 Jun 2004 17:02:17 -0000 1.4
@@ -69,5 +69,8 @@
// ----------------------------------------------------------------------
assertEquals( "4.0.0", p4.getModelVersion() );
+
+
+ assertEquals( "4.0.0", p4.getModelVersion() );
}
}
1.3 +2 -2 maven-components/maven-core/src/test/resources/projects/fully-populated-child.xml
Index: fully-populated-child.xml
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/test/resources/projects/fully-populated-child.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- fully-populated-child.xml 23 Jun 2004 18:04:17 -0000 1.2
+++ fully-populated-child.xml 27 Jun 2004 17:02:17 -0000 1.3
@@ -18,7 +18,7 @@
<shortDescription>shortDescription</shortDescription>
<url>http://maven.apache.org/</url>
<issueTrackingUrl>issueTrackingUrl</issueTrackingUrl>
- <distributionManagment>
+ <distributionManagement>
<repository>
<id>childDistributionRepositoryId</id>
<name>childDistributionRepositoryName</name>
@@ -29,7 +29,7 @@
<name>childSiteDistributionName</name>
<url>childSiteDistributionUrl</url>
</site>
- </distributionManagment>
+ </distributionManagement>
<organization>
<name>Apache Software Foundation</name>
1.3 +2 -2 maven-components/maven-core/src/test/resources/projects/project.xml
Index: project.xml
===================================================================
RCS file: /home/cvs/maven-components/maven-core/src/test/resources/projects/project.xml,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- project.xml 23 Jun 2004 18:04:17 -0000 1.2
+++ project.xml 27 Jun 2004 17:02:17 -0000 1.3
@@ -12,7 +12,7 @@
<shortDescription>shortDescription</shortDescription>
<url>http://maven.apache.org/</url>
<issueTrackingUrl>issueTrackingUrl</issueTrackingUrl>
- <distributionManagment>
+ <distributionManagement>
<repository>
<id>distributionRepositoryId</id>
<name>distributionRepositoryName</name>
@@ -23,7 +23,7 @@
<name>siteDistributionName</name>
<url>siteDistributionUrl</url>
</site>
- </distributionManagment>
+ </distributionManagement>
<organization>
<name>Apache Software Foundation</name>