From 3504931b373ed3d3168dab706153e7bb73a34f66 Mon Sep 17 00:00:00 2001 From: Jason van Zyl Date: Tue, 12 May 2009 00:35:18 +0000 Subject: [PATCH] o the newly gutted system bootstraps, i think i'm happy about the state of 3.x now :-) git-svn-id: https://svn.apache.org/repos/asf/maven/components/branches/MNG-2766@773740 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/maven/DefaultMaven.java | 3 +- .../maven/ReactorArtifactRepository.java | 36 +++++------ .../apache/maven/plugin/MojoExecution.java | 16 +++++ .../project/artifact/MavenMetadataSource.java | 63 ++++++++----------- 4 files changed, 58 insertions(+), 60 deletions(-) diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java index 1781b73229..2199f93f9d 100644 --- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java +++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java @@ -26,7 +26,6 @@ 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.versioning.DefaultArtifactVersion; import org.apache.maven.exception.DefaultExceptionHandler; import org.apache.maven.exception.ExceptionHandler; @@ -78,7 +77,7 @@ public class DefaultMaven public MavenExecutionResult execute( MavenExecutionRequest request ) { - // Need a general way to inject standard properties + //TODO: Need a general way to inject standard properties if ( request.getStartTime() != null ) { request.getProperties().put( "${build.timestamp}", new SimpleDateFormat( "yyyyMMdd-hhmm" ).format( request.getStartTime() ) ); diff --git a/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java b/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java index df9092b176..9c768331c6 100644 --- a/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java +++ b/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java @@ -14,22 +14,7 @@ import org.apache.maven.project.MavenProject; * @author Jason van Zyl */ -// maven-compat -// target/classes -// maven-core -// target/classes -// maven-embedder -// target/classes -// maven-model -// target/classes -// maven-model-builder -// target/classes -// maven-plugin-api -// target/classes -// maven-repository -// target/classes -// maven-toolchain -// target/classes +//TODO: need phase information here to determine whether to hand back the classes/ or archive. public class ReactorArtifactRepository extends LocalArtifactRepository { @@ -49,14 +34,25 @@ public class ReactorArtifactRepository if ( project != null ) { - //TODO: determine if we want to pass the artifact produced by the project if it - // is present and under what conditions we will do such a thing. - if ( artifact.getType().equals( "jar" ) ) { + File artifactFile = new File( project.getBuild().getDirectory(), project.getArtifactId() + "-" + project.getVersion() + "."+ artifact.getArtifactHandler().getExtension() ); + File classesDirectory = new File( project.getBuild().getOutputDirectory() ); - if ( classesDirectory.exists() ) + //TODO: This is really completely wrong and should probably be based on the phase that is currently being executed. + // If we are running before the packaging phase there is going to be no archive anyway, but if we are running prior to package + // we shouldn't even take the archive anyway. + + if ( artifactFile.exists() ) + { + artifact.setFile( artifactFile ); + + artifact.setFromAuthoritativeRepository( true ); + + artifact.setResolved( true ); + } + else if ( classesDirectory.exists() ) { artifact.setFile( classesDirectory ); diff --git a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java index 0fc9204651..a88bf77f02 100644 --- a/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java +++ b/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java @@ -36,6 +36,12 @@ public class MojoExecution private Xpp3Dom configuration; + /** + * The phase may or may not have been bound to a phase but once the plan has been calculated we know what phase + * this mojo execution is going to run in. + */ + private String lifecyclePhase; + public MojoExecution( MojoDescriptor mojoDescriptor ) { this.mojoDescriptor = mojoDescriptor; @@ -86,4 +92,14 @@ public class MojoExecution return sb.toString(); } + + public String getLifecyclePhase() + { + return lifecyclePhase; + } + + public void setLifecyclePhase( String lifecyclePhase ) + { + this.lifecyclePhase = lifecyclePhase; + } } diff --git a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java index e434f08d57..40ff2b02b4 100644 --- a/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java +++ b/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java @@ -49,7 +49,6 @@ import org.codehaus.plexus.logging.Logger; /** * @author Jason van Zyl */ -//TODO: we don't need the repository metadata thing really, we can retrieve files independendently and parse @Component(role = ArtifactMetadataSource.class) public class MavenMetadataSource implements ArtifactMetadataSource @@ -95,7 +94,7 @@ public class MavenMetadataSource artifacts = new LinkedHashSet(); for ( Dependency d : project.getDependencies() ) - { + { String effectiveScope = getEffectiveScope( d.getScope(), artifact.getScope() ); if ( effectiveScope != null ) @@ -118,26 +117,6 @@ public class MavenMetadataSource return new ResolutionGroup( pomArtifact, artifacts, remoteRepositories ); } - /* - private Set createArtifacts( List dependencies ) - { - Set artifacts = new LinkedHashSet(); - - for ( Dependency d : dependencies ) - { - String effectiveScope = getEffectiveScope( d.getScope(), artifact.getScope() ); - - if ( effectiveScope != null ) - { - Artifact dependencyArtifact = repositorySystem.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), effectiveScope, d.getType() ); - - artifacts.add( dependencyArtifact ); - } - } - - } - */ - private String getEffectiveScope( String originalScope, String inheritedScope ) { String effectiveScope = Artifact.SCOPE_RUNTIME; @@ -215,13 +194,13 @@ public class MavenMetadataSource private List retrieveAvailableVersionsFromMetadata( Metadata repoMetadata ) { List versions; - + if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null ) ) { List metadataVersions = repoMetadata.getVersioning().getVersions(); - + versions = new ArrayList( metadataVersions.size() ); - + for ( String version : metadataVersions ) { versions.add( new DefaultArtifactVersion( version ) ); @@ -234,21 +213,29 @@ public class MavenMetadataSource return versions; } - - /* + // USED BY MAVEN ASSEMBLY PLUGIN @Deprecated public static Set createArtifacts( ArtifactFactory artifactFactory, List dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project ) throws InvalidDependencyVersionException - { - try - { - return repositorySystem.createArtifacts( artifactFactory, dependencies, inheritedScope, dependencyFilter, project ); - } - catch ( VersionNotFoundException e ) - { - throw new InvalidDependencyVersionException( e.getProjectId(), e.getDependency(), e.getPomFile, e.getCauseException() ); - } - } - */ + { + return createArtifacts( artifactFactory, dependencies, dependencyFilter ); + } + + private static Set createArtifacts( ArtifactFactory factory, List dependencies, ArtifactFilter filter ) + { + Set artifacts = new LinkedHashSet(); + + for ( Dependency d : dependencies ) + { + Artifact dependencyArtifact = factory.createArtifact( d.getGroupId(), d.getArtifactId(), d.getVersion(), d.getScope(), d.getType() ); + + if ( filter.include( dependencyArtifact ) ) + { + artifacts.add( dependencyArtifact ); + } + } + + return artifacts; + } }