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 2008/09/18 13:10:00 UTC
svn commit: r696629 [5/7] - in /maven/components/branches/jvz: ./
maven-core-it-runner/ maven-core/ maven-core/src/main/aspect/
maven-core/src/main/java/org/apache/maven/
maven-core/src/main/java/org/apache/maven/errors/
maven-core/src/main/java/org/ap...
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ModelUtils.java Thu Sep 18 04:09:54 2008
@@ -19,107 +19,27 @@
* under the License.
*/
-import org.apache.maven.model.Activation;
-import org.apache.maven.model.ActivationFile;
-import org.apache.maven.model.ActivationProperty;
-import org.apache.maven.model.Build;
-import org.apache.maven.model.BuildBase;
-import org.apache.maven.model.Dependency;
-import org.apache.maven.model.DependencyManagement;
-import org.apache.maven.model.DeploymentRepository;
-import org.apache.maven.model.DistributionManagement;
-import org.apache.maven.model.Exclusion;
-import org.apache.maven.model.Extension;
-import org.apache.maven.model.Model;
-import org.apache.maven.model.Parent;
-import org.apache.maven.model.Plugin;
-import org.apache.maven.model.PluginContainer;
-import org.apache.maven.model.PluginExecution;
-import org.apache.maven.model.PluginManagement;
-import org.apache.maven.model.Profile;
-import org.apache.maven.model.Relocation;
-import org.apache.maven.model.ReportPlugin;
-import org.apache.maven.model.ReportSet;
-import org.apache.maven.model.Reporting;
-import org.apache.maven.model.Repository;
-import org.apache.maven.model.RepositoryBase;
-import org.apache.maven.model.RepositoryPolicy;
-import org.apache.maven.model.Resource;
-import org.apache.maven.model.Site;
-import org.apache.maven.project.inheritance.DefaultModelInheritanceAssembler;
-import org.apache.maven.project.inheritance.ModelInheritanceAssembler;
+import org.apache.maven.model.*;
+import org.apache.maven.project.builder.PomClassicDomainModel;
import org.codehaus.plexus.util.xml.Xpp3Dom;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.TreeMap;
+import java.io.IOException;
+import java.util.*;
public final class ModelUtils
{
/**
- * Given this plugin list:
- *
- * A1 -> B -> C -> A2 -> D
- *
- * Rearrange it to this:
- *
- * A(A1 + A2) -> B -> C -> D
- *
- * In cases of overlapping definitions, A1 is overridden by A2
- *
- */
- public static void mergeDuplicatePluginDefinitions( PluginContainer pluginContainer )
- {
- if ( pluginContainer == null )
- {
- return;
- }
-
- List originalPlugins = pluginContainer.getPlugins();
-
- if ( ( originalPlugins == null ) || originalPlugins.isEmpty() )
- {
- return;
- }
-
- List normalized = new ArrayList( originalPlugins.size() );
-
- for ( Iterator it = originalPlugins.iterator(); it.hasNext(); )
- {
- Plugin currentPlugin = (Plugin) it.next();
-
- if ( normalized.contains( currentPlugin ) )
- {
- int idx = normalized.indexOf( currentPlugin );
- Plugin firstPlugin = (Plugin) normalized.get( idx );
-
- mergePluginDefinitions( firstPlugin, currentPlugin, false );
- }
- else
- {
- normalized.add( currentPlugin );
- }
- }
-
- pluginContainer.setPlugins( normalized );
- }
-
- /**
* This should be the resulting ordering of plugins after merging:
- *
+ * <p/>
* Given:
- *
- * parent: X -> A -> B -> D -> E
- * child: Y -> A -> C -> D -> F
- *
+ * <p/>
+ * parent: X -> A -> B -> D -> E
+ * child: Y -> A -> C -> D -> F
+ * <p/>
* Result:
- *
- * X -> Y -> A -> B -> C -> D -> E -> F
+ * <p/>
+ * X -> Y -> A -> B -> C -> D -> E -> F
*/
public static void mergePluginLists( PluginContainer childContainer, PluginContainer parentContainer,
boolean handleAsInheritance )
@@ -194,9 +114,8 @@
// very important to use the parentPlugins List, rather than parentContainer.getPlugins()
// since this list is a local one, and may have been modified during processing.
- List results = ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins,
- childContainer.getPlugins() );
-
+ List results =
+ ModelUtils.orderAfterMerge( assembledPlugins, parentPlugins, childContainer.getPlugins() );
childContainer.setPlugins( results );
@@ -262,67 +181,6 @@
return results;
}
- public static void mergeReportPluginLists( Reporting child, Reporting parent, boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
- // nothing to do.
- return;
- }
-
- List parentPlugins = parent.getPlugins();
-
- if ( ( parentPlugins != null ) && !parentPlugins.isEmpty() )
- {
- Map assembledPlugins = new TreeMap();
-
- Map childPlugins = child.getReportPluginsAsMap();
-
- for ( Iterator it = parentPlugins.iterator(); it.hasNext(); )
- {
- ReportPlugin parentPlugin = (ReportPlugin) it.next();
-
- String parentInherited = parentPlugin.getInherited();
-
- if ( !handleAsInheritance || ( parentInherited == null ) ||
- Boolean.valueOf( parentInherited ).booleanValue() )
- {
-
- ReportPlugin assembledPlugin = parentPlugin;
-
- ReportPlugin childPlugin = (ReportPlugin) childPlugins.get( parentPlugin.getKey() );
-
- if ( childPlugin != null )
- {
- assembledPlugin = childPlugin;
-
- mergeReportPluginDefinitions( childPlugin, parentPlugin, handleAsInheritance );
- }
-
- if ( handleAsInheritance && ( parentInherited == null ) )
- {
- assembledPlugin.unsetInheritanceApplied();
- }
-
- assembledPlugins.put( assembledPlugin.getKey(), assembledPlugin );
- }
- }
-
- for ( Iterator it = childPlugins.values().iterator(); it.hasNext(); )
- {
- ReportPlugin childPlugin = (ReportPlugin) it.next();
-
- if ( !assembledPlugins.containsKey( childPlugin.getKey() ) )
- {
- assembledPlugins.put( childPlugin.getKey(), childPlugin );
- }
- }
-
- child.setPlugins( new ArrayList( assembledPlugins.values() ) );
-
- child.flushReportPluginMap();
- }
- }
public static void mergePluginDefinitions( Plugin child, Plugin parent, boolean handleAsInheritance )
{
@@ -372,7 +230,8 @@
String inherited = parentExecution.getInherited();
- boolean parentExecInherited = parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() );
+ boolean parentExecInherited =
+ parentIsInherited && ( ( inherited == null ) || Boolean.valueOf( inherited ).booleanValue() );
if ( !handleAsInheritance || parentExecInherited )
{
@@ -392,98 +251,27 @@
}
assembledExecutions.put( assembled.getId(), assembled );
- mergedExecutions.add(assembled);
+ mergedExecutions.add( assembled );
}
}
for ( Iterator it = child.getExecutions().iterator(); it.hasNext(); )
{
- PluginExecution childExecution = (PluginExecution)it.next();
+ PluginExecution childExecution = (PluginExecution) it.next();
if ( !assembledExecutions.containsKey( childExecution.getId() ) )
{
- mergedExecutions.add(childExecution);
+ mergedExecutions.add( childExecution );
}
}
- child.setExecutions(mergedExecutions);
+ child.setExecutions( mergedExecutions );
child.flushExecutionMap();
}
}
- public static void mergeReportPluginDefinitions( ReportPlugin child, ReportPlugin parent,
- boolean handleAsInheritance )
- {
- if ( ( child == null ) || ( parent == null ) )
- {
- // nothing to do.
- return;
- }
-
- if ( ( child.getVersion() == null ) && ( parent.getVersion() != null ) )
- {
- child.setVersion( parent.getVersion() );
- }
-
- // from here to the end of the method is dealing with merging of the <executions/> section.
- String parentInherited = parent.getInherited();
-
- boolean parentIsInherited = ( parentInherited == null ) || Boolean.valueOf( parentInherited ).booleanValue();
-
- List parentReportSets = parent.getReportSets();
-
- if ( ( parentReportSets != null ) && !parentReportSets.isEmpty() )
- {
- Map assembledReportSets = new TreeMap();
-
- Map childReportSets = child.getReportSetsAsMap();
-
- for ( Iterator it = parentReportSets.iterator(); it.hasNext(); )
- {
- ReportSet parentReportSet = (ReportSet) it.next();
-
- if ( !handleAsInheritance || parentIsInherited )
- {
- ReportSet assembledReportSet = parentReportSet;
-
- ReportSet childReportSet = (ReportSet) childReportSets.get( parentReportSet.getId() );
-
- if ( childReportSet != null )
- {
- mergeReportSetDefinitions( childReportSet, parentReportSet );
-
- assembledReportSet = childReportSet;
- }
- else if ( handleAsInheritance && ( parentInherited == null ) )
- {
- parentReportSet.unsetInheritanceApplied();
- }
-
- assembledReportSets.put( assembledReportSet.getId(), assembledReportSet );
- }
- }
-
- for ( Iterator it = childReportSets.entrySet().iterator(); it.hasNext(); )
- {
- Map.Entry entry = (Map.Entry) it.next();
-
- String id = (String) entry.getKey();
-
- if ( !assembledReportSets.containsKey( id ) )
- {
- assembledReportSets.put( id, entry.getValue() );
- }
- }
-
- child.setReportSets( new ArrayList( assembledReportSets.values() ) );
-
- child.flushReportSetMap();
- }
-
- }
-
private static void mergePluginExecutionDefinitions( PluginExecution child, PluginExecution parent )
{
if ( child.getPhase() == null )
@@ -524,581 +312,14 @@
child.setConfiguration( childConfiguration );
}
- private static void mergeReportSetDefinitions( ReportSet child, ReportSet parent )
- {
- List parentReports = parent.getReports();
- List childReports = child.getReports();
-
- List reports = new ArrayList();
-
- if ( ( childReports != null ) && !childReports.isEmpty() )
- {
- reports.addAll( childReports );
- }
-
- if ( parentReports != null )
- {
- for ( Iterator i = parentReports.iterator(); i.hasNext(); )
- {
- String report = (String) i.next();
-
- if ( !reports.contains( report ) )
- {
- reports.add( report );
- }
- }
- }
-
- child.setReports( reports );
-
- Xpp3Dom childConfiguration = (Xpp3Dom) child.getConfiguration();
- Xpp3Dom parentConfiguration = (Xpp3Dom) parent.getConfiguration();
-
- childConfiguration = Xpp3Dom.mergeXpp3Dom( childConfiguration, parentConfiguration );
-
- child.setConfiguration( childConfiguration );
- }
-
public static Model cloneModel( Model model )
{
- // TODO: would be nice for the modello:java code to generate this as a copy constructor
- // FIXME: Fix deep cloning issues with existing plugin instances (setting
- // a version when resolved will pollute the original model instance)
- Model newModel = new Model();
- ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
- newModel.setModelVersion( model.getModelVersion() );
- newModel.setName( model.getName() );
- newModel.setParent( cloneParent( model.getParent() ) );
- newModel.setVersion( model.getVersion() );
- newModel.setArtifactId( model.getArtifactId() );
- newModel.setProperties( new Properties( model.getProperties() ) );
- newModel.setGroupId( model.getGroupId() );
- newModel.setPackaging( model.getPackaging() );
- newModel.setModules( cloneModules( model.getModules() ) );
-
- newModel.setProfiles( cloneProfiles( model.getProfiles() ) );
-
- assembler.copyModel( newModel, model );
-
- return newModel;
- }
-
- public static Build cloneBuild( Build build )
- {
- ModelInheritanceAssembler assembler = new DefaultModelInheritanceAssembler();
-
- Build clone = new Build();
-
- assembler.assembleBuildInheritance( clone, build, false );
-
- return clone;
- }
-
- private static List cloneProfiles( List profiles )
- {
- if ( profiles == null )
- {
- return profiles;
+ try {
+ return new PomClassicDomainModel(model).getModel();
+ } catch (IOException e) {
+ e.printStackTrace();
+ return model;
}
-
- List newProfiles = new ArrayList( profiles.size() );
-
- for ( Iterator it = profiles.iterator(); it.hasNext(); )
- {
- Profile profile = (Profile) it.next();
-
- Profile newProfile = new Profile();
-
- newProfile.setId( profile.getId() );
-
- newProfile.setActivation( cloneProfileActivation( profile.getActivation() ) );
-
- newProfile.setBuild( cloneProfileBuild( profile.getBuild() ) );
-
- newProfile.setDependencies( cloneProfileDependencies( profile.getDependencies() ) );
-
- DependencyManagement dm = profile.getDependencyManagement();
-
- if ( dm != null )
- {
- DependencyManagement newDM = new DependencyManagement();
-
- newDM.setDependencies( cloneProfileDependencies( dm.getDependencies() ) );
-
- newProfile.setDependencyManagement( newDM );
- }
-
- newProfile.setDistributionManagement( cloneProfileDistributionManagement( profile
- .getDistributionManagement() ) );
-
- List modules = profile.getModules();
-
- if ( ( modules != null ) && !modules.isEmpty() )
- {
- newProfile.setModules( new ArrayList( modules ) );
- }
-
-// newProfile.setPluginRepositories( cloneProfileRepositories( profile.getPluginRepositories() ) );
-
- Properties props = profile.getProperties();
-
- if ( props != null )
- {
- Properties newProps = new Properties();
- newProps.putAll( props );
-
- newProfile.setProperties( newProps );
- }
-
- newProfile.setReporting( cloneProfileReporting( profile.getReporting() ) );
-
- newProfile.setReports( profile.getReports() );
-
- newProfile.setRepositories( cloneProfileRepositories( profile.getRepositories() ) );
-
- newProfile.setSource( profile.getSource() );
-
- newProfiles.add( newProfile );
- }
-
- return newProfiles;
- }
-
- private static Reporting cloneProfileReporting( Reporting reporting )
- {
- Reporting newR = null;
-
- if ( reporting != null )
- {
- newR = new Reporting();
-
- newR.setOutputDirectory( reporting.getOutputDirectory() );
-
- List plugins = reporting.getPlugins();
-
- if ( plugins != null )
- {
- List newP = new ArrayList( plugins.size() );
-
- for ( Iterator it = plugins.iterator(); it.hasNext(); )
- {
- ReportPlugin plugin = (ReportPlugin) it.next();
-
- ReportPlugin newPlugin = new ReportPlugin();
-
- newPlugin.setArtifactId( plugin.getArtifactId() );
- newPlugin.setGroupId( plugin.getGroupId() );
- newPlugin.setVersion( plugin.getVersion() );
- newPlugin.setInherited( plugin.getInherited() );
- newPlugin.setReportSets( cloneReportSets( plugin.getReportSets() ) );
-
- // TODO: Implement deep-copy of configuration.
- newPlugin.setConfiguration( plugin.getConfiguration() );
-
- newP.add( newPlugin );
- }
-
- newR.setPlugins( newP );
- }
- }
-
- return newR;
- }
-
- private static List cloneReportSets( List sets )
- {
- List newSets = null;
-
- if ( sets != null )
- {
- newSets = new ArrayList( sets.size() );
-
- for ( Iterator it = sets.iterator(); it.hasNext(); )
- {
- ReportSet set = (ReportSet) it.next();
-
- ReportSet newSet = new ReportSet();
-
- // TODO: Deep-copy config.
- newSet.setConfiguration( set.getConfiguration() );
-
- newSet.setId( set.getId() );
- newSet.setInherited( set.getInherited() );
-
- newSet.setReports( new ArrayList( set.getReports() ) );
-
- newSets.add( newSet );
- }
- }
-
- return newSets;
- }
-
- private static List cloneProfileRepositories( List repos )
- {
- List newRepos = null;
-
- if ( repos != null )
- {
- newRepos = new ArrayList( repos.size() );
-
- for ( Iterator it = repos.iterator(); it.hasNext(); )
- {
- Repository repo = (Repository) it.next();
-
- Repository newRepo = new Repository();
-
- newRepo.setId( repo.getId() );
- newRepo.setLayout( repo.getLayout() );
- newRepo.setName( repo.getName() );
-
- RepositoryPolicy releasePolicy = repo.getReleases();
-
- if ( releasePolicy != null )
- {
- RepositoryPolicy newPolicy = new RepositoryPolicy();
- newPolicy.setEnabled( releasePolicy.isEnabled() );
- newPolicy.setChecksumPolicy( releasePolicy.getChecksumPolicy() );
- newPolicy.setUpdatePolicy( releasePolicy.getUpdatePolicy() );
-
- newRepo.setReleases( newPolicy );
- }
-
- RepositoryPolicy snapPolicy = repo.getSnapshots();
-
- if ( snapPolicy != null )
- {
- RepositoryPolicy newPolicy = new RepositoryPolicy();
- newPolicy.setEnabled( snapPolicy.isEnabled() );
- newPolicy.setChecksumPolicy( snapPolicy.getChecksumPolicy() );
- newPolicy.setUpdatePolicy( snapPolicy.getUpdatePolicy() );
-
- newRepo.setSnapshots( newPolicy );
- }
-
- newRepo.setUrl( repo.getUrl() );
-
- newRepos.add( newRepo );
- }
- }
-
- return newRepos;
- }
-
- private static DistributionManagement cloneProfileDistributionManagement( DistributionManagement dm )
- {
- DistributionManagement newDM = null;
-
- if ( dm != null )
- {
- newDM = new DistributionManagement();
-
- newDM.setDownloadUrl( dm.getDownloadUrl() );
- newDM.setStatus( dm.getStatus() );
-
- Relocation relocation = dm.getRelocation();
-
- if ( relocation != null )
- {
- Relocation newR = new Relocation();
-
- newR.setArtifactId( relocation.getArtifactId() );
- newR.setGroupId( relocation.getGroupId() );
- newR.setMessage( relocation.getMessage() );
- newR.setVersion( relocation.getVersion() );
-
- newDM.setRelocation( newR );
- }
-
- RepositoryBase repo = dm.getRepository();
-
- if ( repo != null )
- {
- DeploymentRepository newRepo = new DeploymentRepository();
-
- newRepo.setId( repo.getId() );
- newRepo.setLayout( repo.getLayout() );
- newRepo.setName( repo.getName() );
- newRepo.setUrl( repo.getUrl() );
-
- newDM.setRepository( newRepo );
- }
-
- Site site = dm.getSite();
-
- if ( site != null )
- {
- Site newSite = new Site();
-
- newSite.setId( site.getId() );
- newSite.setName( site.getName() );
- newSite.setUrl( site.getUrl() );
-
- newDM.setSite( newSite );
- }
-
- RepositoryBase sRepo = dm.getSnapshotRepository();
-
- if ( sRepo != null )
- {
- DeploymentRepository newRepo = new DeploymentRepository();
-
- newRepo.setId( sRepo.getId() );
- newRepo.setLayout( sRepo.getLayout() );
- newRepo.setName( sRepo.getName() );
- newRepo.setUrl( sRepo.getUrl() );
-
- newDM.setSnapshotRepository( newRepo );
- }
- }
-
- return newDM;
- }
-
- private static List cloneProfileDependencies( List dependencies )
- {
- List newDependencies = null;
-
- if ( dependencies != null )
- {
- newDependencies = new ArrayList( dependencies.size() );
-
- for ( Iterator it = dependencies.iterator(); it.hasNext(); )
- {
- Dependency dep = (Dependency) it.next();
-
- Dependency newDep = new Dependency();
-
- newDep.setArtifactId( dep.getArtifactId() );
- newDep.setClassifier( dep.getClassifier() );
- newDep.setExclusions( cloneDependencyExclusions( dep.getExclusions() ) );
- newDep.setGroupId( dep.getGroupId() );
- newDep.setScope( dep.getScope() );
- newDep.setSystemPath( dep.getSystemPath() );
- newDep.setType( dep.getType() );
- newDep.setVersion( dep.getVersion() );
-
- newDependencies.add( newDep );
- }
- }
-
- return newDependencies;
- }
-
- private static List cloneDependencyExclusions( List ex )
- {
- List newEx = null;
-
- if ( ex != null )
- {
- newEx = new ArrayList( ex.size() );
-
- for ( Iterator it = ex.iterator(); it.hasNext(); )
- {
- Exclusion exclusion = (Exclusion) it.next();
-
- Exclusion newExclusion = new Exclusion();
-
- newExclusion.setArtifactId( exclusion.getArtifactId() );
- newExclusion.setGroupId( exclusion.getGroupId() );
-
- newEx.add( newExclusion );
- }
- }
-
- return newEx;
- }
-
- private static BuildBase cloneProfileBuild( BuildBase build )
- {
- BuildBase newBuild = null;
- if ( build != null )
- {
- newBuild = new BuildBase();
-
- newBuild.setDefaultGoal( build.getDefaultGoal() );
- newBuild.setDirectory( build.getDirectory() );
- newBuild.setFinalName( build.getFinalName() );
-
- newBuild.setPluginManagement( cloneProfilePluginManagement( build.getPluginManagement() ) );
- newBuild.setPlugins( cloneProfilePlugins( build.getPlugins() ) );
- newBuild.setResources( cloneProfileResources( build.getResources() ) );
- newBuild.setTestResources( cloneProfileResources( build.getTestResources() ) );
- }
-
- return newBuild;
- }
-
- private static List cloneProfileResources( List resources )
- {
- List newResources = null;
-
- if ( resources != null )
- {
- newResources = new ArrayList( resources.size() );
-
- for ( Iterator it = resources.iterator(); it.hasNext(); )
- {
- Resource resource = (Resource) it.next();
-
- Resource newResource = new Resource();
-
- newResource.setDirectory( resource.getDirectory() );
- newResource.setExcludes( new ArrayList( resource.getExcludes() ) );
- newResource.setFiltering( resource.isFiltering() );
- newResource.setIncludes( new ArrayList( resource.getIncludes() ) );
- newResource.setTargetPath( resource.getTargetPath() );
-
- newResources.add( newResource );
- }
- }
-
- return newResources;
- }
-
- private static PluginManagement cloneProfilePluginManagement( PluginManagement pluginManagement )
- {
- PluginManagement newPM = null;
-
- if ( pluginManagement != null )
- {
- newPM = new PluginManagement();
-
- List plugins = pluginManagement.getPlugins();
-
- newPM.setPlugins( cloneProfilePlugins( plugins ) );
- }
-
- return newPM;
- }
-
- private static List cloneProfilePlugins( List plugins )
- {
- List newPlugins = null;
-
- if ( plugins != null )
- {
- newPlugins = new ArrayList( plugins.size() );
-
- for ( Iterator it = plugins.iterator(); it.hasNext(); )
- {
- Plugin plugin = (Plugin) it.next();
-
- Plugin newPlugin = new Plugin();
-
- newPlugin.setArtifactId( plugin.getArtifactId() );
- newPlugin.setExtensions( plugin.isExtensions() );
- newPlugin.setGroupId( plugin.getGroupId() );
- newPlugin.setInherited( plugin.getInherited() );
- newPlugin.setVersion( plugin.getVersion() );
-
- // TODO: Deep-copy this!
- newPlugin.setConfiguration( plugin.getConfiguration() );
-
- newPlugin.setExecutions( cloneExecutions( plugin.getExecutions() ) );
-
- newPlugins.add( newPlugin );
- }
- }
-
- return newPlugins;
- }
-
- private static List cloneExecutions( List executions )
- {
- List newExecs = null;
-
- if ( executions != null )
- {
- newExecs = new ArrayList( executions.size() );
-
- for ( Iterator it = executions.iterator(); it.hasNext(); )
- {
- PluginExecution exec = (PluginExecution) it.next();
-
- PluginExecution newExec = new PluginExecution();
-
- // TODO: Deep-copy configs.
- newExec.setConfiguration( exec.getConfiguration() );
-
- newExec.setId( exec.getId() );
- newExec.setInherited( exec.getInherited() );
- newExec.setPhase( exec.getPhase() );
-
- List goals = exec.getGoals();
-
- if ( ( goals != null ) && !goals.isEmpty() )
- {
- newExec.setGoals( new ArrayList( goals ) );
- }
-
- newExecs.add( newExec );
- }
- }
-
- return newExecs;
- }
-
- private static Activation cloneProfileActivation( Activation activation )
- {
- Activation newActivation = null;
- if ( activation != null )
- {
- newActivation = new Activation();
-
- newActivation.setActiveByDefault( activation.isActiveByDefault() );
-
- ActivationFile af = activation.getFile();
-
- if ( af != null )
- {
- ActivationFile afNew = new ActivationFile();
- afNew.setExists( af.getExists() );
- afNew.setMissing( af.getMissing() );
-
- newActivation.setFile( afNew );
- }
-
- newActivation.setJdk( activation.getJdk() );
-
- ActivationProperty ap = activation.getProperty();
-
- if ( ap != null )
- {
- ActivationProperty newAp = new ActivationProperty();
-
- newAp.setName( ap.getName() );
- newAp.setValue( ap.getValue() );
-
- newActivation.setProperty( newAp );
- }
- }
-
- return newActivation;
- }
-
- private static List cloneModules( List modules )
- {
- if ( modules == null )
- {
- return modules;
- }
- return new ArrayList( modules );
- }
-
- private static Parent cloneParent( Parent parent )
- {
- if ( parent == null )
- {
- return parent;
- }
-
- Parent newParent = new Parent();
- newParent.setArtifactId( parent.getArtifactId() );
- newParent.setGroupId( parent.getGroupId() );
- newParent.setRelativePath( parent.getRelativePath() );
- newParent.setVersion( parent.getVersion() );
- return newParent;
}
public static List mergeRepositoryLists( List dominant, List recessive )
@@ -1125,30 +346,6 @@
return repositories;
}
- public static void mergeExtensionLists( Build childBuild, Build parentBuild )
- {
- for ( Iterator i = parentBuild.getExtensions().iterator(); i.hasNext(); )
- {
- Extension e = (Extension) i.next();
- if ( !childBuild.getExtensions().contains( e ) )
- {
- childBuild.addExtension( e );
- }
- }
- }
-
- public static void mergeResourceLists( List childResources, List parentResources )
- {
- for ( Iterator i = parentResources.iterator(); i.hasNext(); )
- {
- Resource r = (Resource) i.next();
- if ( !childResources.contains( r ) )
- {
- childResources.add( r );
- }
- }
- }
-
public static void mergeFilterLists( List childFilters, List parentFilters )
{
for ( Iterator i = parentFilters.iterator(); i.hasNext(); )
@@ -1161,7 +358,7 @@
}
}
- public static List mergeDependencyList( List child, List parent )
+ private static List mergeDependencyList( List child, List parent )
{
Map depsMap = new HashMap();
@@ -1186,30 +383,4 @@
return new ArrayList( depsMap.values() );
}
- public static String getGroupId( Model model )
- {
- Parent parent = model.getParent();
-
- String groupId = model.getGroupId();
- if ( ( parent != null ) && ( groupId == null ) )
- {
- groupId = parent.getGroupId();
- }
-
- return groupId;
- }
-
- public static String getVersion( Model model )
- {
- Parent parent = model.getParent();
-
- String version = model.getVersion();
- if ( ( parent != null ) && ( version == null ) )
- {
- version = parent.getVersion();
- }
-
- return version;
- }
-
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectBuildingException.java Thu Sep 18 04:09:54 2008
@@ -6,7 +6,6 @@
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.profiles.activation.ProfileActivationException;
import org.apache.maven.project.artifact.InvalidDependencyVersionException;
-import org.apache.maven.project.interpolation.ModelInterpolationException;
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
@@ -49,10 +48,10 @@
}
/**
- * @deprecated use {@link File} constructor for pomLocation
* @param projectId
* @param message
* @param pomLocation absolute path of the pom file
+ * @deprecated use {@link File} constructor for pomLocation
*/
protected ProjectBuildingException( String projectId, String message, String pomLocation )
{
@@ -62,10 +61,9 @@
}
/**
- *
* @param projectId
* @param message
- * @param pomFile pom file location
+ * @param pomFile pom file location
*/
public ProjectBuildingException( String projectId, String message, File pomFile )
{
@@ -77,7 +75,7 @@
/**
* @param projectId
* @param message
- * @param pomFile pom file location
+ * @param pomFile pom file location
* @param cause
*/
protected ProjectBuildingException( String projectId, String message, File pomFile, Throwable cause )
@@ -98,8 +96,7 @@
pomFile = new File( pomLocation );
}
- public ProjectBuildingException( String projectId, String message, File pomFile,
- ProfileActivationException cause )
+ public ProjectBuildingException( String projectId, String message, File pomFile, ProfileActivationException cause )
{
super( message, cause );
this.projectId = projectId;
@@ -133,7 +130,8 @@
/**
* @deprecated use {@link File} constructor for pomLocation
*/
- public ProjectBuildingException( String projectId, String message, String pomLocation, XmlPullParserException cause )
+ public ProjectBuildingException( String projectId, String message, String pomLocation,
+ XmlPullParserException cause )
{
super( message, cause );
this.projectId = projectId;
@@ -178,8 +176,7 @@
this.projectId = projectId;
}
- public ProjectBuildingException( String projectId, String message, File pomFile,
- ArtifactResolutionException cause )
+ public ProjectBuildingException( String projectId, String message, File pomFile, ArtifactResolutionException cause )
{
super( message, cause );
this.projectId = projectId;
@@ -253,32 +250,6 @@
pomFile = new File( pomLocation );
}
- protected ProjectBuildingException( String projectId, String message, File pomFile,
- ModelInterpolationException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- this.pomFile = pomFile;
- }
-
- /**
- * @deprecated use {@link File} constructor for pomLocation
- */
- protected ProjectBuildingException( String projectId, String message, String pomLocation,
- ModelInterpolationException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- pomFile = new File ( pomLocation );
- }
-
- public ProjectBuildingException( String projectId,
- String message,
- ModelInterpolationException cause )
- {
- super( message, cause );
- this.projectId = projectId;
- }
public File getPomFile()
{
@@ -288,7 +259,7 @@
/**
* @deprecated use {@link #getPomFile()}
*/
- public String getPomLocation ()
+ public String getPomLocation()
{
if ( getPomFile() != null )
{
@@ -307,7 +278,7 @@
public String getMessage()
{
- return super.getMessage() + " for project " + projectId
- + ( ( getPomFile() == null ? "" : " at " + getPomFile().getAbsolutePath() ) );
+ return super.getMessage() + " for project " + projectId +
+ ( ( getPomFile() == null ? "" : " at " + getPomFile().getAbsolutePath() ) );
}
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/ProjectUtils.java Thu Sep 18 04:09:54 2008
@@ -97,7 +97,8 @@
if ( url == null || url.trim().length() < 1 )
{
- throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").", id );
+ throw new MissingRepositoryElementException( "Repository URL must not be empty (ID is: " + id + ").",
+ id );
}
ArtifactRepositoryPolicy snapshots = buildArtifactRepositoryPolicy( repo.getSnapshots() );
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ActiveProjectArtifact.java Thu Sep 18 04:09:54 2008
@@ -58,293 +58,389 @@
artifact.setResolved( true );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public File getFile()
{
// we need to get the latest file for the project, not the artifact that was created at one point in time
return project.getArtifact().getFile();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getGroupId()
{
return artifact.getGroupId();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getArtifactId()
{
return artifact.getArtifactId();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getVersion()
{
return artifact.getVersion();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setVersion( String version )
{
artifact.setVersion( version );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getScope()
{
return artifact.getScope();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getType()
{
return artifact.getType();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getClassifier()
{
return artifact.getClassifier();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean hasClassifier()
{
return artifact.hasClassifier();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setFile( File destination )
{
artifact.setFile( destination );
project.getArtifact().setFile( destination );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getBaseVersion()
{
return artifact.getBaseVersion();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setBaseVersion( String baseVersion )
{
artifact.setBaseVersion( baseVersion );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getId()
{
return artifact.getId();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getDependencyConflictId()
{
return artifact.getDependencyConflictId();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void addMetadata( ArtifactMetadata metadata )
{
artifact.addMetadata( metadata );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public Collection getMetadataList()
{
return artifact.getMetadataList();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setRepository( ArtifactRepository remoteRepository )
{
artifact.setRepository( remoteRepository );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public ArtifactRepository getRepository()
{
return artifact.getRepository();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void updateVersion( String version, ArtifactRepository localRepository )
{
artifact.updateVersion( version, localRepository );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String getDownloadUrl()
{
return artifact.getDownloadUrl();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setDownloadUrl( String downloadUrl )
{
artifact.setDownloadUrl( downloadUrl );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public ArtifactFilter getDependencyFilter()
{
return artifact.getDependencyFilter();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setDependencyFilter( ArtifactFilter artifactFilter )
{
artifact.setDependencyFilter( artifactFilter );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public ArtifactHandler getArtifactHandler()
{
return artifact.getArtifactHandler();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public List getDependencyTrail()
{
return artifact.getDependencyTrail();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setDependencyTrail( List dependencyTrail )
{
artifact.setDependencyTrail( dependencyTrail );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setScope( String scope )
{
artifact.setScope( scope );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public VersionRange getVersionRange()
{
return artifact.getVersionRange();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setVersionRange( VersionRange newRange )
{
artifact.setVersionRange( newRange );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void selectVersion( String version )
{
artifact.selectVersion( version );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setGroupId( String groupId )
{
artifact.setGroupId( groupId );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setArtifactId( String artifactId )
{
artifact.setArtifactId( artifactId );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean isSnapshot()
{
return artifact.isSnapshot();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public int compareTo( Object o )
{
return artifact.compareTo( o );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setResolved( boolean resolved )
{
artifact.setResolved( resolved );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean isResolved()
{
return artifact.isResolved();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setResolvedVersion( String version )
{
artifact.setResolvedVersion( version );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setArtifactHandler( ArtifactHandler handler )
{
artifact.setArtifactHandler( handler );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public String toString()
{
return "active project artifact:\n\tartifact = " + artifact + ";\n\tproject: " + project;
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean isRelease()
{
return artifact.isRelease();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setRelease( boolean release )
{
artifact.setRelease( release );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public List getAvailableVersions()
{
return artifact.getAvailableVersions();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setAvailableVersions( List versions )
{
artifact.setAvailableVersions( versions );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean isOptional()
{
return artifact.isOptional();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public ArtifactVersion getSelectedVersion()
throws OverConstrainedVersionException
{
return artifact.getSelectedVersion();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean isSelectedVersionKnown()
throws OverConstrainedVersionException
{
return artifact.isSelectedVersionKnown();
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public void setOptional( boolean optional )
{
artifact.setOptional( optional );
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public int hashCode()
{
int result = 17;
@@ -361,7 +457,9 @@
return result;
}
- /** {@inheritDoc} */
+ /**
+ * {@inheritDoc}
+ */
public boolean equals( Object o )
{
if ( o == this )
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/InvalidDependencyVersionException.java Thu Sep 18 04:09:54 2008
@@ -37,7 +37,8 @@
{
private Dependency dependency;
- public InvalidDependencyVersionException( String projectId, Dependency dependency, File pomFile, InvalidVersionSpecificationException cause )
+ public InvalidDependencyVersionException( String projectId, Dependency dependency, File pomFile,
+ InvalidVersionSpecificationException cause )
{
super( projectId, formatLocationInPom( dependency ), dependency.getVersion(), pomFile, cause );
this.dependency = dependency;
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/MavenMetadataSource.java Thu Sep 18 04:09:54 2008
@@ -85,14 +85,15 @@
private PlexusContainer container;
- /** Unfortunately we have projects that are still sending us JARs without the accompanying POMs. */
+ /**
+ * Unfortunately we have projects that are still sending us JARs without the accompanying POMs.
+ */
private boolean strictlyEnforceThePresenceOfAValidMavenPOM = false;
/**
* Resolve all relocations in the POM for this artifact, and return the new artifact coordinate.
*/
- public Artifact retrieveRelocatedArtifact( Artifact artifact,
- ArtifactRepository localRepository,
+ public Artifact retrieveRelocatedArtifact( Artifact artifact, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
@@ -102,20 +103,19 @@
}
ProjectRelocation rel = retrieveRelocatedProject( artifact, localRepository, remoteRepositories );
-
+
if ( rel == null )
{
return artifact;
}
-
+
MavenProject project = rel.project;
if ( project == null || getRelocationKey( artifact ).equals( getRelocationKey( project.getArtifact() ) ) )
{
return artifact;
}
-
- // NOTE: Using artifact information here, since some POMs are deployed
+ // NOTE: Using artifact information here, since some POMs are deployed
// to central with one version in the filename, but another in the <version> string!
// Case in point: org.apache.ws.commons:XmlSchema:1.1:pom.
//
@@ -124,11 +124,14 @@
Artifact result = null;
if ( artifact.getClassifier() != null )
{
- result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getType(), artifact.getClassifier() );
+ result = artifactFactory.createArtifactWithClassifier( artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion(), artifact.getType(),
+ artifact.getClassifier() );
}
else
{
- result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), artifact.getScope(), artifact.getType() );
+ result = artifactFactory.createArtifact( artifact.getGroupId(), artifact.getArtifactId(),
+ artifact.getVersion(), artifact.getScope(), artifact.getType() );
}
result.setScope( artifact.getScope() );
@@ -146,9 +149,8 @@
return artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion();
}
- private ProjectRelocation retrieveRelocatedProject( Artifact artifact,
- ArtifactRepository localRepository,
- List<ArtifactRepository> remoteRepositories )
+ private ProjectRelocation retrieveRelocatedProject( Artifact artifact, ArtifactRepository localRepository,
+ List<ArtifactRepository> remoteRepositories )
throws ArtifactMetadataRetrievalException
{
if ( remoteRepositories == null )
@@ -162,7 +164,8 @@
}
catch ( ComponentLookupException e )
{
- throw new ArtifactMetadataRetrievalException( "Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
+ throw new ArtifactMetadataRetrievalException(
+ "Cannot lookup MavenProjectBuilder component instance: " + e.getMessage(), e );
}
MavenProject project = null;
@@ -183,7 +186,8 @@
{
try
{
- project = mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
+ project =
+ mavenProjectBuilder.buildFromRepository( pomArtifact, remoteRepositories, localRepository );
}
catch ( InvalidProjectModelException e )
{
@@ -215,7 +219,7 @@
catch ( ProjectBuildingException e )
{
handleInvalidOrMissingMavenPOM( artifact, e );
-
+
project = null;
}
@@ -261,8 +265,8 @@
List available = artifact.getAvailableVersions();
if ( available != null && !available.isEmpty() )
{
- artifact.setAvailableVersions( retrieveAvailableVersions( artifact, localRepository,
- remoteRepositories ) );
+ artifact.setAvailableVersions(
+ retrieveAvailableVersions( artifact, localRepository, remoteRepositories ) );
}
@@ -274,7 +278,8 @@
message += " " + relocation.getMessage() + "\n";
}
- if ( ( artifact.getDependencyTrail() != null ) && ( artifact.getDependencyTrail().size() == 1 ) )
+ if ( ( artifact.getDependencyTrail() != null ) &&
+ ( artifact.getDependencyTrail().size() == 1 ) )
{
getLogger().warn( "While downloading " + artifact.getGroupId() + ":" +
artifact.getArtifactId() + ":" + artifact.getVersion() + message + "\n" );
@@ -342,8 +347,8 @@
// or used the inherited scope (should that be passed to the buildFromRepository method above?)
try
{
- artifacts = project.createArtifacts( artifactFactory, artifact.getScope(),
- artifact.getDependencyFilter() );
+ artifacts =
+ project.createArtifacts( artifactFactory, artifact.getScope(), artifact.getDependencyFilter() );
}
catch ( InvalidDependencyVersionException e )
{
@@ -365,17 +370,16 @@
{
if ( strictlyEnforceThePresenceOfAValidMavenPOM )
{
- throw new ArtifactMetadataRetrievalException( "Invalid POM file for artifact: '" +
- artifact.getDependencyConflictId() + "': " + e.getMessage(), e, artifact );
+ throw new ArtifactMetadataRetrievalException(
+ "Invalid POM file for artifact: '" + artifact.getDependencyConflictId() + "': " + e.getMessage(), e,
+ artifact );
}
else
{
- getLogger().warn(
- "\n\tDEPRECATION: The POM for the artifact '"
- + artifact.getDependencyConflictId()
- + "' was invalid or not found on any repositories.\n"
- + "\tThis may not be supported by future versions of Maven and should be corrected as soon as possible.\n"
- + "\tError given: " + e.getMessage() + "\n" );
+ getLogger().warn( "\n\tDEPRECATION: The POM for the artifact '" + artifact.getDependencyConflictId() +
+ "' was invalid or not found on any repositories.\n" +
+ "\tThis may not be supported by future versions of Maven and should be corrected as soon as possible.\n" +
+ "\tError given: " + e.getMessage() + "\n" );
}
}
@@ -446,11 +450,12 @@
}
/**
- * @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific
* @return {@link Set} < {@link Artifact} >
+ * @todo desperately needs refactoring. It's just here because it's implementation is maven-project specific
*/
- public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies, String inheritedScope,
- ArtifactFilter dependencyFilter, MavenProject project )
+ public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies,
+ String inheritedScope, ArtifactFilter dependencyFilter,
+ MavenProject project )
throws InvalidDependencyVersionException
{
Set<Artifact> projectArtifacts = new LinkedHashSet<Artifact>( dependencies.size() );
@@ -545,8 +550,7 @@
return retrieveAvailableVersionsFromMetadata( metadata.getMetadata() );
}
- public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository(
- Artifact artifact,
+ public List<ArtifactVersion> retrieveAvailableVersionsFromDeploymentRepository( Artifact artifact,
ArtifactRepository localRepository,
ArtifactRepository deploymentRepository )
throws ArtifactMetadataRetrievalException
@@ -578,7 +582,7 @@
}
else
{
- versions = Collections.<ArtifactVersion> emptyList();
+ versions = Collections.<ArtifactVersion>emptyList();
}
return versions;
@@ -593,6 +597,7 @@
private static final class ProjectRelocation
{
private MavenProject project;
+
private Artifact pomArtifact;
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/artifact/ProjectArtifactMetadata.java Thu Sep 18 04:09:54 2008
@@ -45,8 +45,7 @@
this( artifact, null );
}
- public ProjectArtifactMetadata( Artifact artifact,
- File file )
+ public ProjectArtifactMetadata( Artifact artifact, File file )
{
super( artifact );
this.file = file;
@@ -67,8 +66,7 @@
return getArtifactId() + "-" + artifact.getVersion() + ".pom";
}
- public void storeInLocalRepository( ArtifactRepository localRepository,
- ArtifactRepository remoteRepository )
+ public void storeInLocalRepository( ArtifactRepository localRepository, ArtifactRepository remoteRepository )
throws RepositoryMetadataStoreException
{
File destination = new File( localRepository.getBasedir(),
@@ -90,7 +88,7 @@
throw new RepositoryMetadataStoreException( "Error copying POM to the local repository.", e );
}
}
-
+
public String toString()
{
return "project information for " + artifact.getArtifactId() + " " + artifact.getVersion();
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/ArtifactModelContainerFactory.java Thu Sep 18 04:09:54 2008
@@ -72,28 +72,45 @@
private List<ModelProperty> properties;
+ private static String findBaseUriFrom( List<ModelProperty> modelProperties )
+ {
+ String baseUri = null;
+ for ( ModelProperty mp : modelProperties )
+ {
+ if ( baseUri == null || mp.getUri().length() < baseUri.length() )
+ {
+ baseUri = mp.getUri();
+ }
+ }
+ return baseUri;
+ }
+
private ArtifactModelContainer( List<ModelProperty> properties )
{
this.properties = new ArrayList<ModelProperty>( properties );
this.properties = Collections.unmodifiableList( this.properties );
+ String uri = findBaseUriFrom( this.properties );
- for ( ModelProperty mp : properties )
+ for ( ModelProperty mp : this.properties )
{
- if ( mp.getUri().endsWith( "version" ) )
+ if ( version == null && mp.getUri().equals( uri + "/version" ) )
{
- this.version = mp.getValue();
+ this.version = mp.getResolvedValue();
}
- else if ( mp.getUri().endsWith( "artifactId" ) )
+ else if ( artifactId == null && mp.getUri().equals( uri + "/artifactId" ) )
{
- this.artifactId = mp.getValue();
+ this.artifactId = mp.getResolvedValue();
}
- else if ( mp.getUri().endsWith( "groupId" ) )
+ else if ( groupId == null && mp.getUri().equals( uri + "/groupId" ) )
{
- this.groupId = mp.getValue();
+ this.groupId = mp.getResolvedValue();
}
- else if ( mp.getUri().equals( ProjectUri.Dependencies.Dependency.type ) )
+ else if ( type == null && mp.getUri().equals( ProjectUri.Dependencies.Dependency.type )
+ || mp.getUri().equals(ProjectUri.DependencyManagement.Dependencies.Dependency.type)
+ || mp.getUri().equals(ProjectUri.Build.PluginManagement.Plugins.Plugin.Dependencies.Dependency.type)
+ || mp.getUri().equals(ProjectUri.Build.Plugins.Plugin.Dependencies.Dependency.type))
{
- this.type = mp.getValue();
+ this.type = mp.getResolvedValue();
}
}
if ( groupId == null )
@@ -105,8 +122,13 @@
if ( artifactId == null )
{
- throw new IllegalArgumentException(
- "Properties does not contain artifact id. Group ID = " + groupId + ", Version = " + version );
+ StringBuffer sb = new StringBuffer();
+ for ( ModelProperty mp : properties )
+ {
+ sb.append( mp ).append( "\r\n" );
+ }
+ throw new IllegalArgumentException( "Properties does not contain artifact id. Group ID = " + groupId +
+ ", Version = " + version + ":" + sb );
}
if ( type == null )
@@ -134,7 +156,14 @@
{
if ( version == null )
{
- return ModelContainerAction.JOIN;
+ if ( c.type.equals( type ) )
+ {
+ return ModelContainerAction.JOIN;
+ }
+ else
+ {
+ return ModelContainerAction.NOP;
+ }
}
return ModelContainerAction.DELETE;//TODO Verify - PluginManagement Section may make versions equal
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/IdModelContainerFactory.java Thu Sep 18 04:09:54 2008
@@ -70,7 +70,7 @@
{
if ( mp.getUri().endsWith( "/id" ) )
{
- this.id = mp.getValue();
+ this.id = mp.getResolvedValue();
}
}
}
Modified: maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java
URL: http://svn.apache.org/viewvc/maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java?rev=696629&r1=696628&r2=696629&view=diff
==============================================================================
--- maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java (original)
+++ maven/components/branches/jvz/maven-project/src/main/java/org/apache/maven/project/builder/PomClassicDomainModel.java Thu Sep 18 04:09:54 2008
@@ -31,6 +31,8 @@
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.Writer;
@@ -59,6 +61,12 @@
private String id;
+ private File file;
+
+ private File parentFile;
+
+ private File projectDirectory;
+
/**
* Constructor
*
@@ -73,10 +81,20 @@
throw new IllegalArgumentException( "model: null" );
}
ByteArrayOutputStream baos = new ByteArrayOutputStream();
- Writer out = WriterFactory.newXmlWriter( baos );
+ Writer out = null;
MavenXpp3Writer writer = new MavenXpp3Writer();
- writer.write( out, model );
- out.close();
+ try
+ {
+ out = WriterFactory.newXmlWriter( baos );
+ writer.write( out, model );
+ }
+ finally
+ {
+ if ( out != null )
+ {
+ out.close();
+ }
+ }
inputBytes = baos.toByteArray();
}
@@ -96,6 +114,37 @@
this.inputBytes = IOUtil.toByteArray( inputStream );
}
+ public PomClassicDomainModel( File file )
+ throws IOException
+ {
+ this( new FileInputStream( file ) );
+ this.file = file;
+ }
+
+ public File getParentFile()
+ {
+ return parentFile;
+ }
+
+ public void setParentFile( File parentFile )
+ {
+ this.parentFile = parentFile;
+ }
+
+ public void setProjectDirectory(File projectDirectory)
+ {
+ this.projectDirectory = projectDirectory;
+ }
+
+ public File getProjectDirectory()
+ {
+ return projectDirectory;
+ }
+
+ public boolean isPomInBuild()
+ {
+ return projectDirectory != null;
+ }
/**
* Returns true if groupId.equals(a.groupId) && artifactId.equals(a.artifactId) && version.equals(a.version),
@@ -140,10 +189,15 @@
return "";
}
}
- String groupId = ( model.getGroupId() == null ) ? model.getParent().getGroupId() : model.getGroupId();
- String artifactId =
- ( model.getArtifactId() == null ) ? model.getParent().getArtifactId() : model.getArtifactId();
- String version = ( model.getVersion() == null ) ? model.getParent().getVersion() : model.getVersion();
+ String groupId = ( model.getGroupId() == null && model.getParent() != null )
+ ? model.getParent().getGroupId()
+ : model.getGroupId();
+ String artifactId = ( model.getArtifactId() == null && model.getParent() != null )
+ ? model.getParent().getArtifactId()
+ : model.getArtifactId();
+ String version = ( model.getVersion() == null && model.getParent() != null )
+ ? model.getParent().getVersion()
+ : model.getVersion();
id = groupId + ":" + artifactId + ":" + version;
}
@@ -212,6 +266,14 @@
}
/**
+ * @return file of pom. May be null.
+ */
+ public File getFile()
+ {
+ return file;
+ }
+
+ /**
* @see org.apache.maven.shared.model.DomainModel#getEventHistory()
*/
public String getEventHistory()