You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by jv...@apache.org on 2009/05/12 02:35:19 UTC
svn commit: r773740 - in
/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven:
DefaultMaven.java ReactorArtifactRepository.java plugin/MojoExecution.java
project/artifact/MavenMetadataSource.java
Author: jvanzyl
Date: Tue May 12 00:35:18 2009
New Revision: 773740
URL: http://svn.apache.org/viewvc?rev=773740&view=rev
Log:
o the newly gutted system bootstraps, i think i'm happy about the state of 3.x now :-)
Modified:
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultMaven.java?rev=773740&r1=773739&r2=773740&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultMaven.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/DefaultMaven.java Tue May 12 00:35:18 2009
@@ -26,7 +26,6 @@
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 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() ) );
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java?rev=773740&r1=773739&r2=773740&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/ReactorArtifactRepository.java Tue May 12 00:35:18 2009
@@ -14,22 +14,7 @@
* @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 @@
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 );
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java?rev=773740&r1=773739&r2=773740&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/plugin/MojoExecution.java Tue May 12 00:35:18 2009
@@ -36,6 +36,12 @@
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 @@
return sb.toString();
}
+
+ public String getLifecyclePhase()
+ {
+ return lifecyclePhase;
+ }
+
+ public void setLifecyclePhase( String lifecyclePhase )
+ {
+ this.lifecyclePhase = lifecyclePhase;
+ }
}
Modified: maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=773740&r1=773739&r2=773740&view=diff
==============================================================================
--- maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/branches/MNG-2766/maven-core/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Tue May 12 00:35:18 2009
@@ -49,7 +49,6 @@
/**
* @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 @@
artifacts = new LinkedHashSet<Artifact>();
for ( Dependency d : project.getDependencies() )
- {
+ {
String effectiveScope = getEffectiveScope( d.getScope(), artifact.getScope() );
if ( effectiveScope != null )
@@ -118,26 +117,6 @@
return new ResolutionGroup( pomArtifact, artifacts, remoteRepositories );
}
- /*
- private Set<Artifact> createArtifacts( List<Dependency> dependencies )
- {
- Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
-
- 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 @@
private List<ArtifactVersion> retrieveAvailableVersionsFromMetadata( Metadata repoMetadata )
{
List<ArtifactVersion> versions;
-
+
if ( ( repoMetadata != null ) && ( repoMetadata.getVersioning() != null ) )
{
List<String> metadataVersions = repoMetadata.getVersioning().getVersions();
-
+
versions = new ArrayList<ArtifactVersion>( metadataVersions.size() );
-
+
for ( String version : metadataVersions )
{
versions.add( new DefaultArtifactVersion( version ) );
@@ -234,21 +213,29 @@
return versions;
}
-
- /*
+
// USED BY MAVEN ASSEMBLY PLUGIN
@Deprecated
public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> 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<Artifact> createArtifacts( ArtifactFactory factory, List<Dependency> dependencies, ArtifactFilter filter )
+ {
+ Set<Artifact> artifacts = new LinkedHashSet<Artifact>();
+
+ 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;
+ }
}