You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by si...@apache.org on 2008/09/12 05:45:46 UTC
svn commit: r694598 - in /maven/components/trunk:
maven-core/src/main/java/org/apache/maven/plugin/
maven-project/src/main/java/org/apache/maven/project/
Author: sisbell
Date: Thu Sep 11 20:45:45 2008
New Revision: 694598
URL: http://svn.apache.org/viewvc?rev=694598&view=rev
Log:
Cleanup of code. Removed last of dynamic/concrete code.
Modified:
maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Modified: maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java?rev=694598&r1=694597&r2=694598&view=diff
==============================================================================
--- maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java (original)
+++ maven/components/trunk/maven-core/src/main/java/org/apache/maven/plugin/DefaultPluginManager.java Thu Sep 11 20:45:45 2008
@@ -517,19 +517,9 @@
getLogger().warn( "Mojo: " + mojoDescriptor.getGoal() + " is deprecated.\n" + mojoDescriptor.getDeprecated() );
}
- if ( !project.isConcrete() )
- {
- Model model = ModelUtils.cloneModel( project.getModel() );
-
- File basedir = project.getBasedir();
-
- Model model2 = ModelUtils.cloneModel( model );
- pathTranslator.alignToBaseDirectory( model, basedir );
- project.preserveBuild( model2.getBuild() );
-
- project.setBuild( model.getBuild() );
- project.setConcrete( true );
- }
+ Model model = ModelUtils.cloneModel( project.getModel() );
+ pathTranslator.alignToBaseDirectory( model, project.getBasedir() );
+ project.setBuild( model.getBuild() );
if ( mojoDescriptor.isDependencyResolutionRequired() != null )
{
@@ -738,8 +728,6 @@
Thread.currentThread().setContextClassLoader( oldClassLoader );
}
-
- project.setConcrete( false );
}
private Plugin createDummyPlugin( PluginDescriptor pluginDescriptor )
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java?rev=694598&r1=694597&r2=694598&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/DefaultMavenProjectBuilder.java Thu Sep 11 20:45:45 2008
@@ -70,39 +70,6 @@
import java.util.List;
import java.util.Map;
-/*:apt
-
- -----
- POM lifecycle
- -----
-
-POM Lifecycle
-
- Order of operations when building a POM
-
- * inheritance
- * path translation
- * interpolation
- * defaults injection
-
- Current processing is:
-
- * inheritance
- * interpolation
- * defaults injection
- * path translation
-
- I'm not sure how this is working at all ... i think i have a case where this is failing but i need to
- encapsulate as a test so i can fix it. Also need to think of the in working build directory versus looking
- things up from the repository i.e buildFromSource vs buildFromRepository.
-
-Notes
-
- * when the model is read it may not have a groupId, as it must be inherited
-
- * the inheritance assembler must use models that are unadulterated!
-
-*/
/**
* @version $Id$
Modified: maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=694598&r1=694597&r2=694598&view=diff
==============================================================================
--- maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java (original)
+++ maven/components/trunk/maven-project/src/main/java/org/apache/maven/project/MavenProject.java Thu Sep 11 20:45:45 2008
@@ -246,117 +246,6 @@
deepCopy( project );
}
- private void deepCopy( MavenProject project )
- {
- // disown the parent
-
- // copy fields
- setFile( project.getFile() );
-
- // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be
- // sure!
- if ( project.getDependencyArtifacts() != null )
- {
- setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) );
- }
-
- if ( project.getArtifacts() != null )
- {
- setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) );
- }
-
- if ( project.getParentFile() != null )
- {
- parentFile = new File( project.getParentFile().getAbsolutePath() );
- }
-
- if ( project.getReportArtifacts() != null )
- {
- setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) );
- }
-
- if ( project.getExtensionArtifacts() != null )
- {
- setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) );
- }
-
- setParentArtifact( ( project.getParentArtifact() ) );
-
- if ( project.getRemoteArtifactRepositories() != null )
- {
- setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) );
- }
-
- if ( project.getPluginArtifactRepositories() != null )
- {
- setPluginArtifactRepositories(
- ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) );
- }
-
- if ( project.getCollectedProjects() != null )
- {
- setCollectedProjects( ( Collections.unmodifiableList( project.getCollectedProjects() ) ) );
- }
-
- if ( project.getActiveProfiles() != null )
- {
- setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) );
- }
-
- if ( project.getAttachedArtifacts() != null )
- {
- // clone properties modifyable by plugins in a forked lifecycle
- setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) );
- }
-
- if ( project.getCompileSourceRoots() != null )
- {
- // clone source roots
- setCompileSourceRoots( ( new ArrayList( project.getCompileSourceRoots() ) ) );
- }
-
- if ( project.getTestCompileSourceRoots() != null )
- {
- setTestCompileSourceRoots( ( new ArrayList( project.getTestCompileSourceRoots() ) ) );
- }
-
- if ( project.getScriptSourceRoots() != null )
- {
- setScriptSourceRoots( ( new ArrayList( project.getScriptSourceRoots() ) ) );
- }
-
- setModel( ( ModelUtils.cloneModel( project.getModel() ) ) );
-
- if ( project.getOriginalModel() != null )
- {
- setOriginalModel( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) );
- }
-
- setExecutionRoot( project.isExecutionRoot() );
-
- if ( project.getArtifact() != null )
- {
- setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) );
- }
-
- if ( project.getManagedVersionMap() != null )
- {
- setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) );
- }
-
- if ( project.getReleaseArtifactRepository() != null )
- {
- setReleaseArtifactRepository( project.getReleaseArtifactRepository() );
- }
-
- if ( project.getSnapshotArtifactRepository() != null )
- {
- setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() );
- }
-
- setConcrete( project.isConcrete() );
- }
-
// TODO: Find a way to use <relativePath/> here...it's tricky, because the moduleProject
// usually doesn't have a file associated with it yet.
public String getModulePathAdjustment( MavenProject moduleProject )
@@ -694,13 +583,6 @@
if ( a.getArtifactHandler().isAddedToClasspath() )
{
- // TODO: let the scope handler deal with this
- // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
- // this check...
- // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
- // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
- // {
- // }
File file = a.getFile();
if ( file == null )
{
@@ -723,15 +605,6 @@
// TODO: classpath check doesn't belong here - that's the other method
if ( a.getArtifactHandler().isAddedToClasspath() )
{
- // TODO: let the scope handler deal with this
- // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
- // this check...
- // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
- // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
- // {
- // list.add( a );
- // }
-
list.add( a );
}
}
@@ -753,14 +626,6 @@
{
Artifact a = (Artifact) i.next();
- // TODO: let the scope handler deal with this
- // NOTE: [jc] scope == 'test' is the widest possible scope, so we don't really need to perform
- // this check...
- // if ( Artifact.SCOPE_TEST.equals( a.getScope() ) || Artifact.SCOPE_COMPILE.equals( a.getScope() ) ||
- // Artifact.SCOPE_RUNTIME.equals( a.getScope() ) )
- // {
- // }
-
Dependency dependency = new Dependency();
dependency.setArtifactId( a.getArtifactId() );
@@ -1830,11 +1695,6 @@
getProjectReferenceId( project.getGroupId(), project.getArtifactId(), project.getVersion() ), project );
}
- private static String getProjectReferenceId( String groupId, String artifactId, String version )
- {
- return groupId + ":" + artifactId + ":" + version;
- }
-
/**
* @deprecated Use MavenProjectHelper.attachArtifact(..) instead.
*/
@@ -1873,42 +1733,6 @@
return getBuild() != null ? getBuild().getDefaultGoal() : null;
}
-
- protected void setModel( Model model )
- {
- this.model = model;
- }
-
- protected void setAttachedArtifacts( List attachedArtifacts )
- {
- this.attachedArtifacts = attachedArtifacts;
- }
-
- protected void setCompileSourceRoots( List compileSourceRoots )
- {
- this.compileSourceRoots = compileSourceRoots;
- }
-
- protected void setTestCompileSourceRoots( List testCompileSourceRoots )
- {
- this.testCompileSourceRoots = testCompileSourceRoots;
- }
-
- protected void setScriptSourceRoots( List scriptSourceRoots )
- {
- this.scriptSourceRoots = scriptSourceRoots;
- }
-
- protected ArtifactRepository getReleaseArtifactRepository()
- {
- return releaseArtifactRepository;
- }
-
- protected ArtifactRepository getSnapshotArtifactRepository()
- {
- return snapshotArtifactRepository;
- }
-
public Artifact replaceWithActiveArtifact( Artifact pluginArtifact )
{
if ( ( getProjectReferences() != null ) && !getProjectReferences().isEmpty() )
@@ -1975,41 +1799,6 @@
return pluginArtifact;
}
- private void addArtifactPath( Artifact a, List list )
- throws DependencyResolutionRequiredException
- {
- String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
- MavenProject project = (MavenProject) projectReferences.get( refId );
-
- boolean projectDirFound = false;
- if ( project != null )
- {
- if ( a.getType().equals( "test-jar" ) )
- {
- File testOutputDir = new File( project.getBuild().getTestOutputDirectory() );
- if ( testOutputDir.exists() )
- {
- list.add( testOutputDir.getAbsolutePath() );
- projectDirFound = true;
- }
- }
- else
- {
- list.add( project.getBuild().getOutputDirectory() );
- projectDirFound = true;
- }
- }
- if ( !projectDirFound )
- {
- File file = a.getFile();
- if ( file == null )
- {
- throw new DependencyResolutionRequiredException( a );
- }
- list.add( file.getPath() );
- }
- }
-
public void clearExecutionProject()
{
if ( !previousExecutionProjects.isEmpty() )
@@ -2067,28 +1856,187 @@
return clone;
}
-// ----------------------------------------------------------------------------
-// CODE BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
-// ----------------------------------------------------------------------------
+ protected void setModel( Model model )
+ {
+ this.model = model;
+ }
+
+ protected void setAttachedArtifacts( List attachedArtifacts )
+ {
+ this.attachedArtifacts = attachedArtifacts;
+ }
+
+ protected void setCompileSourceRoots( List compileSourceRoots )
+ {
+ this.compileSourceRoots = compileSourceRoots;
+ }
- private Build originalInterpolatedBuild;
+ protected void setTestCompileSourceRoots( List testCompileSourceRoots )
+ {
+ this.testCompileSourceRoots = testCompileSourceRoots;
+ }
- private boolean isConcrete = false;
+ protected void setScriptSourceRoots( List scriptSourceRoots )
+ {
+ this.scriptSourceRoots = scriptSourceRoots;
+ }
- public boolean isConcrete()
+ protected ArtifactRepository getReleaseArtifactRepository()
{
- return isConcrete;
+ return releaseArtifactRepository;
}
- public void setConcrete( boolean concrete )
+ protected ArtifactRepository getSnapshotArtifactRepository()
{
- isConcrete = concrete;
+ return snapshotArtifactRepository;
}
- public void preserveBuild( Build originalInterpolatedBuild )
+ private void deepCopy( MavenProject project )
{
- this.originalInterpolatedBuild = originalInterpolatedBuild;
- this.originalInterpolatedBuild.setPluginManagement( null );
- this.originalInterpolatedBuild.setPlugins( null );
+ // disown the parent
+
+ // copy fields
+ setFile( project.getFile() );
+
+ // don't need a deep copy, they don't get modified or added/removed to/from - but make them unmodifiable to be
+ // sure!
+ if ( project.getDependencyArtifacts() != null )
+ {
+ setDependencyArtifacts( Collections.unmodifiableSet( project.getDependencyArtifacts() ) );
+ }
+
+ if ( project.getArtifacts() != null )
+ {
+ setArtifacts( Collections.unmodifiableSet( project.getArtifacts() ) );
+ }
+
+ if ( project.getParentFile() != null )
+ {
+ parentFile = new File( project.getParentFile().getAbsolutePath() );
+ }
+
+ if ( project.getReportArtifacts() != null )
+ {
+ setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) );
+ }
+
+ if ( project.getExtensionArtifacts() != null )
+ {
+ setExtensionArtifacts( Collections.unmodifiableSet( project.getExtensionArtifacts() ) );
+ }
+
+ setParentArtifact( ( project.getParentArtifact() ) );
+
+ if ( project.getRemoteArtifactRepositories() != null )
+ {
+ setRemoteArtifactRepositories( Collections.unmodifiableList( project.getRemoteArtifactRepositories() ) );
+ }
+
+ if ( project.getPluginArtifactRepositories() != null )
+ {
+ setPluginArtifactRepositories(
+ ( Collections.unmodifiableList( project.getPluginArtifactRepositories() ) ) );
+ }
+
+ if ( project.getCollectedProjects() != null )
+ {
+ setCollectedProjects( ( Collections.unmodifiableList( project.getCollectedProjects() ) ) );
+ }
+
+ if ( project.getActiveProfiles() != null )
+ {
+ setActiveProfiles( ( Collections.unmodifiableList( project.getActiveProfiles() ) ) );
+ }
+
+ if ( project.getAttachedArtifacts() != null )
+ {
+ // clone properties modifyable by plugins in a forked lifecycle
+ setAttachedArtifacts( new ArrayList( project.getAttachedArtifacts() ) );
+ }
+
+ if ( project.getCompileSourceRoots() != null )
+ {
+ // clone source roots
+ setCompileSourceRoots( ( new ArrayList( project.getCompileSourceRoots() ) ) );
+ }
+
+ if ( project.getTestCompileSourceRoots() != null )
+ {
+ setTestCompileSourceRoots( ( new ArrayList( project.getTestCompileSourceRoots() ) ) );
+ }
+
+ if ( project.getScriptSourceRoots() != null )
+ {
+ setScriptSourceRoots( ( new ArrayList( project.getScriptSourceRoots() ) ) );
+ }
+
+ setModel( ( ModelUtils.cloneModel( project.getModel() ) ) );
+
+ if ( project.getOriginalModel() != null )
+ {
+ setOriginalModel( ( ModelUtils.cloneModel( project.getOriginalModel() ) ) );
+ }
+
+ setExecutionRoot( project.isExecutionRoot() );
+
+ if ( project.getArtifact() != null )
+ {
+ setArtifact( ArtifactUtils.copyArtifact( project.getArtifact() ) );
+ }
+
+ if ( project.getManagedVersionMap() != null )
+ {
+ setManagedVersionMap( new ManagedVersionMap( project.getManagedVersionMap() ) );
+ }
+
+ if ( project.getReleaseArtifactRepository() != null )
+ {
+ setReleaseArtifactRepository( project.getReleaseArtifactRepository() );
+ }
+
+ if ( project.getSnapshotArtifactRepository() != null )
+ {
+ setSnapshotArtifactRepository( project.getSnapshotArtifactRepository() );
+ }
+ }
+
+ private void addArtifactPath( Artifact a, List list )
+ throws DependencyResolutionRequiredException
+ {
+ String refId = getProjectReferenceId( a.getGroupId(), a.getArtifactId(), a.getVersion() );
+ MavenProject project = (MavenProject) projectReferences.get( refId );
+
+ boolean projectDirFound = false;
+ if ( project != null )
+ {
+ if ( a.getType().equals( "test-jar" ) )
+ {
+ File testOutputDir = new File( project.getBuild().getTestOutputDirectory() );
+ if ( testOutputDir.exists() )
+ {
+ list.add( testOutputDir.getAbsolutePath() );
+ projectDirFound = true;
+ }
+ }
+ else
+ {
+ list.add( project.getBuild().getOutputDirectory() );
+ projectDirFound = true;
+ }
+ }
+ if ( !projectDirFound )
+ {
+ File file = a.getFile();
+ if ( file == null )
+ {
+ throw new DependencyResolutionRequiredException( a );
+ }
+ list.add( file.getPath() );
+ }
+ }
+
+ private static String getProjectReferenceId( String groupId, String artifactId, String version )
+ {
+ return groupId + ":" + artifactId + ":" + version;
}
}