o Restored API backward compat with 2.x and polished some code

git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@1054693 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Benjamin Bentmann 2011-01-03 17:51:24 +00:00
parent acd646e4a4
commit 8cbfa31252
2 changed files with 40 additions and 37 deletions

View File

@ -192,7 +192,12 @@ public class LegacyRepositorySystem
VersionRange versionRange; VersionRange versionRange;
try try
{ {
versionRange = VersionRange.createFromVersionSpec( plugin.getVersion() ); String version = plugin.getVersion();
if ( StringUtils.isEmpty( version ) )
{
version = "RELEASE";
}
versionRange = VersionRange.createFromVersionSpec( version );
} }
catch ( InvalidVersionSpecificationException e ) catch ( InvalidVersionSpecificationException e )
{ {

View File

@ -209,6 +209,10 @@ public class MavenProject
@Deprecated @Deprecated
public MavenProject( MavenProject project ) public MavenProject( MavenProject project )
{ {
repositorySystem = project.repositorySystem;
logger = project.logger;
mavenProjectBuilder = project.mavenProjectBuilder;
projectBuilderConfiguration = project.projectBuilderConfiguration;
deepCopy( project ); deepCopy( project );
} }
@ -1113,49 +1117,47 @@ public class MavenProject
return artifactMap; return artifactMap;
} }
public void setPluginArtifacts( Set<Artifact> pluginArtifacts )
{
this.pluginArtifacts = pluginArtifacts;
this.pluginArtifactMap = null;
}
public Set<Artifact> getPluginArtifacts() public Set<Artifact> getPluginArtifacts()
{ {
if ( pluginArtifacts != null ) if ( pluginArtifacts != null )
{ {
return pluginArtifacts; return pluginArtifacts;
} }
pluginArtifacts = new HashSet<Artifact>(); pluginArtifacts = new HashSet<Artifact>();
if ( repositorySystem != null ) if ( repositorySystem != null )
{ {
List<Plugin> plugins = getBuildPlugins(); for ( Plugin p : getBuildPlugins() )
for ( Iterator<Plugin> i = plugins.iterator(); i.hasNext(); )
{ {
Plugin p = (Plugin) i.next();
String version;
if ( StringUtils.isEmpty( p.getVersion() ) )
{
version = "RELEASE";
}
else
{
version = p.getVersion();
}
Artifact artifact = repositorySystem.createPluginArtifact( p ); Artifact artifact = repositorySystem.createPluginArtifact( p );
if ( artifact == null ) if ( artifact != null )
{
return pluginArtifacts;
}
else
{ {
pluginArtifacts.add( artifact ); pluginArtifacts.add( artifact );
} }
} }
} }
pluginArtifactMap = null; pluginArtifactMap = null;
return pluginArtifacts; return pluginArtifacts;
} }
public Map<String, Artifact> getPluginArtifactMap() public Map<String, Artifact> getPluginArtifactMap()
{
if ( pluginArtifactMap == null )
{ {
pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() ); pluginArtifactMap = ArtifactUtils.artifactMapByVersionlessId( getPluginArtifacts() );
}
return pluginArtifactMap; return pluginArtifactMap;
} }
@ -1176,27 +1178,16 @@ public class MavenProject
} }
reportArtifacts = new HashSet<Artifact>(); reportArtifacts = new HashSet<Artifact>();
List<ReportPlugin> reports = getReportPlugins();
if ( reports != null )
{
for ( Iterator<ReportPlugin> i = reports.iterator(); i.hasNext(); )
{
ReportPlugin p = (ReportPlugin) i.next();
String version; if ( repositorySystem != null )
if ( StringUtils.isEmpty( p.getVersion() ) )
{ {
version = "RELEASE"; for ( ReportPlugin p : getReportPlugins() )
}
else
{ {
version = p.getVersion();
}
Plugin pp = new Plugin(); Plugin pp = new Plugin();
pp.setGroupId( p.getGroupId() ); pp.setGroupId( p.getGroupId() );
pp.setArtifactId( p.getArtifactId() ); pp.setArtifactId( p.getArtifactId() );
pp.setVersion( version ); pp.setVersion( p.getVersion() );
Artifact artifact = repositorySystem.createPluginArtifact( pp ); Artifact artifact = repositorySystem.createPluginArtifact( pp );
if ( artifact != null ) if ( artifact != null )
@ -1205,7 +1196,9 @@ public class MavenProject
} }
} }
} }
reportArtifactMap = null; reportArtifactMap = null;
return reportArtifacts; return reportArtifacts;
} }
@ -1934,6 +1927,11 @@ public class MavenProject
parentFile = new File( project.getParentFile().getAbsolutePath() ); parentFile = new File( project.getParentFile().getAbsolutePath() );
} }
if ( project.getPluginArtifacts() != null )
{
setPluginArtifacts( Collections.unmodifiableSet( project.getPluginArtifacts() ) );
}
if ( project.getReportArtifacts() != null ) if ( project.getReportArtifacts() != null )
{ {
setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) ); setReportArtifacts( Collections.unmodifiableSet( project.getReportArtifacts() ) );