Author: nicolas
Date: Mon May 4 12:54:57 2009
New Revision: 771294
URL: http://svn.apache.org/viewvc?rev=771294&view=rev
Log:
[MNG-4151] fix error in managedVersionMap generic type (eclipse quick fix is
not as clever as I expected)
Modified:
maven/components/branches/maven-2.2.0-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Modified:
maven/components/branches/maven-2.2.0-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
URL:
http://svn.apache.org/viewvc/maven/components/branches/maven-2.2.0-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java?rev=771294&r1=771293&r2=771294&view=diff
==============================================================================
---
maven/components/branches/maven-2.2.0-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
(original)
+++
maven/components/branches/maven-2.2.0-RC/maven-project/src/main/java/org/apache/maven/project/MavenProject.java
Mon May 4 12:54:57 2009
@@ -39,7 +39,6 @@
import org.apache.maven.artifact.factory.ArtifactFactory;
import org.apache.maven.artifact.repository.ArtifactRepository;
import org.apache.maven.artifact.resolver.filter.ArtifactFilter;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.ManagedVersionMap;
import org.apache.maven.model.Build;
import org.apache.maven.model.CiManagement;
@@ -58,6 +57,7 @@
import org.apache.maven.model.PluginExecution;
import org.apache.maven.model.PluginManagement;
import org.apache.maven.model.Prerequisites;
+import org.apache.maven.model.Profile;
import org.apache.maven.model.ReportPlugin;
import org.apache.maven.model.ReportSet;
import org.apache.maven.model.Reporting;
@@ -88,11 +88,11 @@
implements Cloneable
{
public static final String EMPTY_PROJECT_GROUP_ID = "unknown";
-
+
public static final String EMPTY_PROJECT_ARTIFACT_ID = "empty-project";
-
+
public static final String EMPTY_PROJECT_VERSION = "0";
-
+
private Model model;
private MavenProject parent;
@@ -125,7 +125,7 @@
private ArtifactRepository snapshotArtifactRepository;
- private List<String> activeProfiles = new ArrayList<String>();
+ private List<Profile> activeProfiles = new ArrayList<Profile>();
private Set<Artifact> dependencyArtifacts;
@@ -146,28 +146,28 @@
private Map<String, Artifact> extensionArtifactMap;
- private Map<String, ArtifactVersion> managedVersionMap;
+ private Map<String, Artifact> managedVersionMap;
private Map<String, MavenProject> projectReferences = new HashMap<String, MavenProject>();
private boolean executionRoot;
-
+
private Map<String, String> moduleAdjustments;
private File basedir;
-
+
private Logger logger;
-
+
private ProjectBuilderConfiguration projectBuilderConfiguration;
-
+
public MavenProject()
{
Model model = new Model();
-
+
model.setGroupId( EMPTY_PROJECT_GROUP_ID );
model.setArtifactId( EMPTY_PROJECT_ARTIFACT_ID );
model.setVersion( EMPTY_PROJECT_VERSION );
-
+
this.setModel( model );
}
@@ -285,12 +285,12 @@
{
setManagedVersionMap( new ManagedVersionMap(
project.getManagedVersionMap() ) );
}
-
+
if ( project.getReleaseArtifactRepository() != null )
{
setReleaseArtifactRepository(
project.getReleaseArtifactRepository() );
}
-
+
if ( project.getSnapshotArtifactRepository() != null )
{
setSnapshotArtifactRepository(
project.getSnapshotArtifactRepository() );
@@ -327,31 +327,31 @@
preservedBasedir = project.preservedBasedir;
setConcrete( project.isConcrete() );
}
-
+
public String getModulePathAdjustment( MavenProject moduleProject ) throws
IOException
{
// FIXME: This is hacky. What if module directory doesn't match
artifactid, and parent
// is coming from the repository??
-
- // FIXME: If there is a hierarchy of three projects, with the url specified at the top,
+
+ // FIXME: If there is a hierarchy of three projects, with the url
specified at the top,
// and the top two projects are referenced from copies that are in the
repository, the
// middle-level POM doesn't have a File associated with it (or the
file's directory is
// of an unexpected name), and module path adjustments fail.
String module = moduleProject.getArtifactId();
-
+
File moduleFile = moduleProject.getFile();
-
+
if ( moduleFile != null )
{
File moduleDir = moduleFile.getCanonicalFile().getParentFile();
-
+
module = moduleDir.getName();
}
-
+
if ( moduleAdjustments == null )
{
moduleAdjustments = new HashMap<String, String>();
-
+
List<String> modules = getModules();
if ( modules != null )
{
@@ -359,21 +359,21 @@
{
String modulePath = (String) it.next();
String moduleName = modulePath;
-
+
if ( moduleName.endsWith( "/" ) || moduleName.endsWith(
"\\" ) )
{
moduleName = moduleName.substring( 0,
moduleName.length() - 1 );
}
-
+
int lastSlash = moduleName.lastIndexOf( '/' );
-
+
if ( lastSlash < 0 )
{
lastSlash = moduleName.lastIndexOf( '\\' );
}
-
+
String adjustment = null;
-
+
if ( lastSlash > -1 )
{
moduleName = moduleName.substring( lastSlash + 1 );
@@ -384,7 +384,7 @@
}
}
}
-
+
return (String) moduleAdjustments.get( module );
}
@@ -444,15 +444,15 @@
{
return;
}
-
+
if ( basedir == null )
{
basedir = file.getParentFile();
}
-
+
this.file = file;
}
-
+
public void setBasedir( File basedir )
{
this.basedir = basedir;
@@ -630,7 +630,7 @@
list.add( getBuild().getTestOutputDirectory() );
list.add( getBuild().getOutputDirectory() );
-
+
for ( Iterator<Artifact> i = getArtifacts().iterator(); i.hasNext(); )
{
Artifact a = (Artifact) i.next();
@@ -909,7 +909,7 @@
{
groupId = getModel().getParent().getGroupId();
}
-
+
return groupId;
}
@@ -954,7 +954,7 @@
{
version = getModel().getParent().getVersion();
}
-
+
return version;
}
@@ -1162,9 +1162,10 @@
}
/**
- * All dependencies that this project has, including transitive ones.
- * Contents are lazily populated, so depending on what phases have run
dependencies in some scopes won't be included.
- * eg. if only compile phase has run, dependencies with scope test won't be included.
+ * All dependencies that this project has, including transitive ones. Contents are lazily populated, so depending on
+ * what phases have run dependencies in some scopes won't be included. eg.
if only compile phase has run,
+ * dependencies with scope test won't be included.
+ *
* @return {...@link Set} < {...@link Artifact} >
* @see #getDependencyArtifacts() to get only direct dependencies
*/
@@ -1304,7 +1305,7 @@
return pluginMgmt;
}
-
+
private Build getModelBuild()
{
Build build = getModel().getBuild();
@@ -1315,7 +1316,7 @@
getModel().setBuild( build );
}
-
+
return build;
}
@@ -1331,7 +1332,7 @@
build.flushPluginMap();
}
}
-
+
public void injectPluginManagementInfo( Plugin plugin )
{
PluginManagement pm = getModelBuild().getPluginManagement();
@@ -1386,12 +1387,12 @@
return getModel().getPluginRepositories();
}
- public void setActiveProfiles( List<String> activeProfiles )
+ public void setActiveProfiles( List<Profile> activeProfiles )
{
this.activeProfiles.addAll( activeProfiles );
}
- public List<String> getActiveProfiles()
+ public List<Profile> getActiveProfiles()
{
return activeProfiles;
}
@@ -1448,7 +1449,7 @@
}
}
}
-
+
// PluginManagement pluginManagement = getBuild().getPluginManagement();
// if ( pluginManagement != null && pluginManagement.getPlugins() !=
null )
// {
@@ -1473,7 +1474,7 @@
// }
// }
// }
-//
+ //
// dom = Xpp3Dom.mergeXpp3Dom( dom, managedDom );
// break;
// }
@@ -1597,12 +1598,12 @@
return originalModel;
}
- public void setManagedVersionMap( Map<String, ArtifactVersion> map )
+ public void setManagedVersionMap( Map<String, Artifact> map )
{
this.managedVersionMap = map;
}
- public Map<String, ArtifactVersion> getManagedVersionMap()
+ public Map<String, Artifact> getManagedVersionMap()
{
return this.managedVersionMap;
}
@@ -1737,7 +1738,7 @@
{
return snapshotArtifactRepository;
}
-
+
public void resolveActiveArtifacts()
{
Set<Artifact> depArtifacts = getDependencyArtifacts();
@@ -1745,23 +1746,23 @@
{
return;
}
-
+
Set<Artifact> updated = new LinkedHashSet<Artifact>(
depArtifacts.size() );
int updatedCount = 0;
-
+
for ( Iterator<Artifact> it = depArtifacts.iterator(); it.hasNext(); )
{
Artifact depArtifact = (Artifact) it.next();
Artifact replaced = replaceWithActiveArtifact( depArtifact );
-
+
if ( depArtifact != replaced )
{
updatedCount++;
}
-
+
updated.add( replaced );
}
-
+
if ( updatedCount > 0 )
{
setDependencyArtifacts( updated );
@@ -1882,7 +1883,7 @@
{
return;
}
-
+
if ( logger.isDebugEnabled() )
{
StringBuffer message = new StringBuffer();
@@ -1892,7 +1893,7 @@
message.append( "\nRequested Dependency: " ).append(
artifact.getId() );
message.append( "\n\nNOTE: You may need to run this build to the
'compile' lifecycle phase, or farther, in order to build the dependency artifact." );
message.append( "\n" );
-
+
logger.debug( message.toString() );
}
else
@@ -1910,7 +1911,7 @@
}
list.add( file.getPath() );
}
-
+
/**
* Default toString
*/
@@ -1924,8 +1925,8 @@
sb.append( ":" );
sb.append( this.getVersion() );
sb.append( " @ " );
-
- try
+
+ try
{
sb.append( this.getFile().getPath() );
}
@@ -1933,10 +1934,10 @@
{
//don't log it.
}
-
- return sb.toString();
+
+ return sb.toString();
}
-
+
/**
* @throws CloneNotSupportedException
* @since 2.0.9
@@ -1952,7 +1953,7 @@
// ----------------------------------------------------------------------------
// CODE BELOW IS USED TO PRESERVE DYNAMISM IN THE BUILD SECTION OF THE POM.
// ----------------------------------------------------------------------------
-
+
private Build dynamicBuild;
private Build originalInterpolatedBuild;
@@ -1971,7 +1972,7 @@
private boolean isConcrete = false;
- public boolean isConcrete()
+ public boolean isConcrete()
{
return isConcrete;
}
@@ -2103,9 +2104,9 @@
{
this.originalInterpolatedScriptSourceRoots =
originalInterpolatedScriptSourceRoots;
}
-
+
private Properties preservedProperties;
-
+
public Properties getPreservedProperties()
{
return preservedProperties;
@@ -2124,9 +2125,9 @@
}
}
}
-
+
private File preservedBasedir;
-
+
public File getPreservedBasedir()
{
return preservedBasedir;