mirror of https://github.com/apache/archiva.git
[MRM-487] pom version is not resolved
[MRM-488] properties in pom are not resolved (at least while browsing) Fixed the ProjectModelExpressionFilter to filter all important fields. Fixed ProjectModel400Reader's Generic's Fleshed out the rest of ProjectModel400Writer. git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@580514 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e50371591d
commit
701f790c59
|
@ -66,7 +66,7 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.modello</groupId>
|
||||
<artifactId>modello-maven-plugin</artifactId>
|
||||
<version>1.0-alpha-15</version>
|
||||
<version>1.0-alpha-17</version>
|
||||
<configuration>
|
||||
<version>1.0.0</version>
|
||||
<packageWithVersion>false</packageWithVersion>
|
||||
|
|
|
@ -23,18 +23,32 @@ import org.apache.commons.collections.CollectionUtils;
|
|||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaModelCloner;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.CiManagement;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.Exclusion;
|
||||
import org.apache.maven.archiva.model.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.MailingList;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.codehaus.plexus.evaluator.DefaultExpressionEvaluator;
|
||||
import org.codehaus.plexus.evaluator.EvaluatorException;
|
||||
import org.codehaus.plexus.evaluator.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.evaluator.ExpressionSource;
|
||||
import org.codehaus.plexus.evaluator.sources.PropertiesExpressionSource;
|
||||
import org.codehaus.plexus.evaluator.sources.SystemPropertyExpressionSource;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ProjectModelExpressionFilter
|
||||
|
@ -65,52 +79,351 @@ public class ProjectModelExpressionFilter
|
|||
props.putAll( model.getProperties() );
|
||||
}
|
||||
|
||||
props.setProperty( "pom.artifactId", model.getArtifactId() );
|
||||
|
||||
props.setProperty( "pom.groupId", StringUtils.defaultString( model.getGroupId() ) );
|
||||
props.setProperty( "pom.version", StringUtils.defaultString( model.getVersion() ) );
|
||||
|
||||
PropertiesExpressionSource propsSource = new PropertiesExpressionSource();
|
||||
propsSource.setProperties( props );
|
||||
evaluator.addExpressionSource( propsSource );
|
||||
evaluator.addExpressionSource( new SystemPropertyExpressionSource() );
|
||||
|
||||
ArchivaProjectModel ret = ArchivaModelCloner.clone( model );
|
||||
|
||||
try
|
||||
// TODO: should probably clone evaluator to prevent threading issues.
|
||||
synchronized ( evaluator )
|
||||
{
|
||||
ret.setVersion( evaluator.expand( ret.getVersion() ) );
|
||||
ret.setGroupId( evaluator.expand( ret.getGroupId() ) );
|
||||
|
||||
if ( CollectionUtils.isNotEmpty( ret.getDependencies() ) )
|
||||
// TODO: create .resetSources() method in ExpressionEvaluator project on plexus side.
|
||||
// Remove previous expression sources.
|
||||
List<ExpressionSource> oldSources = new ArrayList<ExpressionSource>();
|
||||
oldSources.addAll( evaluator.getExpressionSourceList() );
|
||||
for ( ExpressionSource exprSrc : oldSources )
|
||||
{
|
||||
evaluateExpressionsInDependencyList( evaluator, ret.getDependencies() );
|
||||
evaluator.removeExpressionSource( exprSrc );
|
||||
}
|
||||
|
||||
evaluateExpressionsInDependencyList( evaluator, ret.getDependencyManagement() );
|
||||
}
|
||||
catch ( EvaluatorException e )
|
||||
{
|
||||
throw new ProjectModelException( "Unable to evaluate expression in model: " + e.getMessage(), e );
|
||||
// Setup new sources (based on current model)
|
||||
PropertiesExpressionSource propsSource = new PropertiesExpressionSource();
|
||||
propsSource.setProperties( props );
|
||||
evaluator.addExpressionSource( propsSource );
|
||||
|
||||
// Add system properties to the mix.
|
||||
evaluator.addExpressionSource( new SystemPropertyExpressionSource() );
|
||||
|
||||
try
|
||||
{
|
||||
// Setup some common properties.
|
||||
props.setProperty( "pom.groupId", StringUtils.defaultString( evaluator.expand( model.getGroupId() ) ) );
|
||||
props.setProperty( "pom.artifactId", StringUtils.defaultString( evaluator
|
||||
.expand( model.getArtifactId() ) ) );
|
||||
props.setProperty( "pom.version", StringUtils.defaultString( evaluator.expand( model.getVersion() ) ) );
|
||||
props.setProperty( "pom.name", StringUtils.defaultString( evaluator.expand( model.getName() ) ) );
|
||||
|
||||
// Evaluate everything.
|
||||
ret.setVersion( evaluator.expand( ret.getVersion() ) );
|
||||
ret.setGroupId( evaluator.expand( ret.getGroupId() ) );
|
||||
ret.setName( evaluator.expand( ret.getName() ) );
|
||||
ret.setDescription( evaluator.expand( ret.getDescription() ) );
|
||||
ret.setPackaging( evaluator.expand( ret.getPackaging() ) );
|
||||
ret.setUrl( evaluator.expand( ret.getUrl() ) );
|
||||
|
||||
evaluateParentProject( evaluator, ret.getParentProject() );
|
||||
|
||||
evaluateBuildExtensions( evaluator, ret.getBuildExtensions() );
|
||||
evaluateCiManagement( evaluator, ret.getCiManagement() );
|
||||
evaluateDependencyList( evaluator, ret.getDependencies() );
|
||||
evaluateDependencyList( evaluator, ret.getDependencyManagement() );
|
||||
evaluateIndividuals( evaluator, ret.getIndividuals() );
|
||||
evaluateIssueManagement( evaluator, ret.getIssueManagement() );
|
||||
evaluateLicenses( evaluator, ret.getLicenses() );
|
||||
evaluateMailingLists( evaluator, ret.getMailingLists() );
|
||||
evaluateOrganization( evaluator, ret.getOrganization() );
|
||||
evaluatePlugins( evaluator, ret.getPlugins() );
|
||||
evaluateRelocation( evaluator, ret.getRelocation() );
|
||||
evaluateReports( evaluator, ret.getReports() );
|
||||
evaluateRepositories( evaluator, ret.getRepositories() );
|
||||
evaluateScm( evaluator, ret.getScm() );
|
||||
}
|
||||
catch ( EvaluatorException e )
|
||||
{
|
||||
throw new ProjectModelException( "Unable to evaluate expression in model: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static void evaluateExpressionsInDependencyList( ExpressionEvaluator evaluator, List dependencies )
|
||||
private void evaluateArtifactReferenceList( ExpressionEvaluator eval, List<ArtifactReference> refs )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( dependencies == null )
|
||||
if ( CollectionUtils.isEmpty( refs ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator it = dependencies.iterator();
|
||||
while ( it.hasNext() )
|
||||
for ( ArtifactReference ref : refs )
|
||||
{
|
||||
Dependency dependency = (Dependency) it.next();
|
||||
dependency.setGroupId( evaluator.expand( dependency.getGroupId() ) );
|
||||
dependency.setVersion( evaluator.expand( dependency.getVersion() ) );
|
||||
ref.setGroupId( eval.expand( ref.getGroupId() ) );
|
||||
ref.setArtifactId( eval.expand( ref.getArtifactId() ) );
|
||||
ref.setVersion( eval.expand( ref.getVersion() ) );
|
||||
ref.setClassifier( eval.expand( ref.getClassifier() ) );
|
||||
ref.setType( eval.expand( ref.getType() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateBuildExtensions( ExpressionEvaluator eval, List<ArtifactReference> buildExtensions )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( buildExtensions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ArtifactReference ref : buildExtensions )
|
||||
{
|
||||
ref.setGroupId( eval.expand( ref.getGroupId() ) );
|
||||
ref.setArtifactId( eval.expand( ref.getArtifactId() ) );
|
||||
ref.setVersion( eval.expand( ref.getVersion() ) );
|
||||
ref.setClassifier( eval.expand( ref.getClassifier() ) );
|
||||
ref.setType( eval.expand( ref.getType() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateCiManagement( ExpressionEvaluator eval, CiManagement ciManagement )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( ciManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ciManagement.setSystem( eval.expand( ciManagement.getSystem() ) );
|
||||
ciManagement.setUrl( eval.expand( ciManagement.getUrl() ) );
|
||||
}
|
||||
|
||||
private void evaluateDependencyList( ExpressionEvaluator eval, List<Dependency> dependencies )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencies ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
dependency.setGroupId( eval.expand( dependency.getGroupId() ) );
|
||||
dependency.setArtifactId( eval.expand( dependency.getArtifactId() ) );
|
||||
dependency.setVersion( eval.expand( dependency.getVersion() ) );
|
||||
dependency.setScope( eval.expand( dependency.getScope() ) );
|
||||
dependency.setType( eval.expand( dependency.getType() ) );
|
||||
dependency.setUrl( eval.expand( dependency.getUrl() ) );
|
||||
|
||||
evaluateExclusions( eval, dependency.getExclusions() );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateExclusions( ExpressionEvaluator eval, List<Exclusion> exclusions )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( exclusions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Exclusion exclusion : exclusions )
|
||||
{
|
||||
exclusion.setGroupId( eval.expand( exclusion.getGroupId() ) );
|
||||
exclusion.setArtifactId( eval.expand( exclusion.getArtifactId() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateIndividuals( ExpressionEvaluator eval, List<Individual> individuals )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( individuals ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Individual individual : individuals )
|
||||
{
|
||||
individual.setPrincipal( eval.expand( individual.getPrincipal() ) );
|
||||
individual.setName( eval.expand( individual.getName() ) );
|
||||
individual.setEmail( eval.expand( individual.getEmail() ) );
|
||||
individual.setTimezone( eval.expand( individual.getTimezone() ) );
|
||||
individual.setOrganization( eval.expand( individual.getOrganization() ) );
|
||||
individual.setOrganizationUrl( eval.expand( individual.getOrganizationUrl() ) );
|
||||
individual.setUrl( eval.expand( individual.getUrl() ) );
|
||||
|
||||
evaluateProperties( eval, individual.getProperties() );
|
||||
evaluateStringList( eval, individual.getRoles() );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateIssueManagement( ExpressionEvaluator eval, IssueManagement issueManagement )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( issueManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
issueManagement.setSystem( eval.expand( issueManagement.getSystem() ) );
|
||||
issueManagement.setUrl( eval.expand( issueManagement.getUrl() ) );
|
||||
}
|
||||
|
||||
private void evaluateLicenses( ExpressionEvaluator eval, List<License> licenses )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( licenses ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( License license : licenses )
|
||||
{
|
||||
license.setName( eval.expand( license.getName() ) );
|
||||
license.setUrl( eval.expand( license.getUrl() ) );
|
||||
license.setComments( eval.expand( license.getComments() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateMailingLists( ExpressionEvaluator eval, List<MailingList> mailingLists )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( mailingLists ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( MailingList mlist : mailingLists )
|
||||
{
|
||||
mlist.setName( eval.expand( mlist.getName() ) );
|
||||
mlist.setSubscribeAddress( eval.expand( mlist.getSubscribeAddress() ) );
|
||||
mlist.setUnsubscribeAddress( eval.expand( mlist.getUnsubscribeAddress() ) );
|
||||
mlist.setPostAddress( eval.expand( mlist.getPostAddress() ) );
|
||||
mlist.setMainArchiveUrl( eval.expand( mlist.getMainArchiveUrl() ) );
|
||||
|
||||
evaluateStringList( eval, mlist.getOtherArchives() );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateOrganization( ExpressionEvaluator eval, Organization organization )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( organization == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
organization.setName( eval.expand( organization.getName() ) );
|
||||
organization.setUrl( eval.expand( organization.getUrl() ) );
|
||||
organization.setFavicon( eval.expand( organization.getFavicon() ) );
|
||||
}
|
||||
|
||||
private void evaluateParentProject( ExpressionEvaluator eval, VersionedReference parentProject )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( parentProject == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
parentProject.setGroupId( eval.expand( parentProject.getGroupId() ) );
|
||||
parentProject.setArtifactId( eval.expand( parentProject.getArtifactId() ) );
|
||||
parentProject.setVersion( eval.expand( parentProject.getVersion() ) );
|
||||
}
|
||||
|
||||
private void evaluatePlugins( ExpressionEvaluator eval, List<ArtifactReference> plugins )
|
||||
throws EvaluatorException
|
||||
{
|
||||
evaluateArtifactReferenceList( eval, plugins );
|
||||
}
|
||||
|
||||
private void evaluateProperties( ExpressionEvaluator eval, Properties props )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( props == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only evaluate the values, not the keys.
|
||||
|
||||
// Collect the key names. (Done ahead of time to prevent iteration / concurrent modification exceptions)
|
||||
Set<String> keys = new HashSet<String>();
|
||||
for ( Object obj : props.keySet() )
|
||||
{
|
||||
keys.add( (String) obj );
|
||||
}
|
||||
|
||||
// Evaluate all of the values.
|
||||
for ( String key : keys )
|
||||
{
|
||||
String value = props.getProperty( key );
|
||||
props.setProperty( key, eval.expand( value ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateRelocation( ExpressionEvaluator eval, VersionedReference relocation )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( relocation == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
relocation.setGroupId( eval.expand( relocation.getGroupId() ) );
|
||||
relocation.setArtifactId( eval.expand( relocation.getArtifactId() ) );
|
||||
relocation.setVersion( eval.expand( relocation.getVersion() ) );
|
||||
}
|
||||
|
||||
private void evaluateReports( ExpressionEvaluator eval, List<ArtifactReference> reports )
|
||||
throws EvaluatorException
|
||||
{
|
||||
evaluateArtifactReferenceList( eval, reports );
|
||||
}
|
||||
|
||||
private void evaluateRepositories( ExpressionEvaluator eval, List<ProjectRepository> repositories )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( repositories ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ProjectRepository repository : repositories )
|
||||
{
|
||||
repository.setId( eval.expand( repository.getId() ) );
|
||||
repository.setLayout( eval.expand( repository.getLayout() ) );
|
||||
repository.setName( eval.expand( repository.getName() ) );
|
||||
repository.setUrl( eval.expand( repository.getUrl() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateScm( ExpressionEvaluator eval, Scm scm )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( scm == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
scm.setConnection( eval.expand( scm.getConnection() ) );
|
||||
scm.setDeveloperConnection( eval.expand( scm.getDeveloperConnection() ) );
|
||||
scm.setUrl( eval.expand( scm.getUrl() ) );
|
||||
}
|
||||
|
||||
private void evaluateStringList( ExpressionEvaluator eval, List<String> strings )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( strings ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new list to hold post-evaluated strings.
|
||||
List<String> evaluated = new ArrayList<String>();
|
||||
|
||||
// Evaluate them all
|
||||
for ( String str : strings )
|
||||
{
|
||||
evaluated.add( eval.expand( str ) );
|
||||
}
|
||||
|
||||
// Populate the original list with the post-evaluated list.
|
||||
strings.clear();
|
||||
strings.addAll( evaluated );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ import java.util.Properties;
|
|||
*
|
||||
* @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a>
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component
|
||||
*
|
||||
* @plexus.component
|
||||
* role="org.apache.maven.archiva.repository.project.ProjectModelReader"
|
||||
* role-hint="model400"
|
||||
*/
|
||||
|
@ -133,23 +133,23 @@ public class ProjectModel400Reader
|
|||
/**
|
||||
* Get List of {@link ArtifactReference} objects from xpath expr.
|
||||
*/
|
||||
private List getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType )
|
||||
private List<ArtifactReference> getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType )
|
||||
throws XMLException
|
||||
{
|
||||
List plugins = new ArrayList();
|
||||
List<ArtifactReference> refs = new ArrayList<ArtifactReference>();
|
||||
|
||||
Iterator it = xml.getElementList( xpathExpr ).iterator();
|
||||
Iterator<Element> it = xml.getElementList( xpathExpr ).iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemPlugin = (Element) it.next();
|
||||
Element elemPlugin = it.next();
|
||||
|
||||
plugins.add( getArtifactReference( elemPlugin, defaultType ) );
|
||||
refs.add( getArtifactReference( elemPlugin, defaultType ) );
|
||||
}
|
||||
|
||||
return plugins;
|
||||
return refs;
|
||||
}
|
||||
|
||||
private List getBuildExtensions( XMLReader xml )
|
||||
private List<ArtifactReference> getBuildExtensions( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/build/extensions/extension", "jar" );
|
||||
|
@ -170,24 +170,23 @@ public class ProjectModel400Reader
|
|||
return null;
|
||||
}
|
||||
|
||||
private List getDependencies( XMLReader xml )
|
||||
private List<Dependency> getDependencies( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getDependencyList( xml, new String[] { "dependencies" } );
|
||||
}
|
||||
|
||||
private List getDependencyList( XMLReader xml, String parts[] )
|
||||
private List<Dependency> getDependencyList( XMLReader xml, String parts[] )
|
||||
throws XMLException
|
||||
{
|
||||
List dependencyList = new ArrayList();
|
||||
List<Dependency> dependencyList = new ArrayList<Dependency>();
|
||||
|
||||
Element project = xml.getElement( "//project" );
|
||||
|
||||
Element depsParent = project;
|
||||
|
||||
for ( int i = 0; i < parts.length; i++ )
|
||||
for ( String part : parts )
|
||||
{
|
||||
String part = parts[i];
|
||||
depsParent = depsParent.element( part );
|
||||
if ( depsParent == null )
|
||||
{
|
||||
|
@ -195,10 +194,10 @@ public class ProjectModel400Reader
|
|||
}
|
||||
}
|
||||
|
||||
Iterator it = depsParent.elementIterator( "dependency" );
|
||||
Iterator<Element> it = depsParent.elementIterator( "dependency" );
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemDependency = (Element) it.next();
|
||||
Element elemDependency = it.next();
|
||||
Dependency dependency = new Dependency();
|
||||
|
||||
dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) );
|
||||
|
@ -228,24 +227,24 @@ public class ProjectModel400Reader
|
|||
return dependencyList;
|
||||
}
|
||||
|
||||
private List getDependencyManagement( XMLReader xml )
|
||||
private List<Dependency> getDependencyManagement( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getDependencyList( xml, new String[] { "dependencyManagement", "dependencies" } );
|
||||
}
|
||||
|
||||
private List getExclusions( Element elemDependency )
|
||||
private List<Exclusion> getExclusions( Element elemDependency )
|
||||
{
|
||||
List exclusions = new ArrayList();
|
||||
List<Exclusion> exclusions = new ArrayList<Exclusion>();
|
||||
|
||||
Element elemExclusions = elemDependency.element( "exclusions" );
|
||||
|
||||
if ( elemExclusions != null )
|
||||
{
|
||||
Iterator it = elemExclusions.elementIterator( "exclusion" );
|
||||
Iterator<Element> it = elemExclusions.elementIterator( "exclusion" );
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemExclusion = (Element) it.next();
|
||||
Element elemExclusion = it.next();
|
||||
Exclusion exclusion = new Exclusion();
|
||||
|
||||
exclusion.setGroupId( elemExclusion.elementTextTrim( "groupId" ) );
|
||||
|
@ -258,10 +257,10 @@ public class ProjectModel400Reader
|
|||
return exclusions;
|
||||
}
|
||||
|
||||
private List getIndividuals( XMLReader xml )
|
||||
private List<Individual> getIndividuals( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List individuals = new ArrayList();
|
||||
List<Individual> individuals = new ArrayList<Individual>();
|
||||
|
||||
individuals.addAll( getIndividuals( xml, true, "//project/developers/developer" ) );
|
||||
individuals.addAll( getIndividuals( xml, false, "//project/contributors/contributor" ) );
|
||||
|
@ -269,19 +268,24 @@ public class ProjectModel400Reader
|
|||
return individuals;
|
||||
}
|
||||
|
||||
private List getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr )
|
||||
private List<Individual> getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr )
|
||||
throws XMLException
|
||||
{
|
||||
List ret = new ArrayList();
|
||||
List<Individual> ret = new ArrayList<Individual>();
|
||||
|
||||
List modelPersonList = xml.getElementList( xpathExpr );
|
||||
List<Element> modelPersonList = xml.getElementList( xpathExpr );
|
||||
|
||||
Iterator iter = modelPersonList.iterator();
|
||||
Iterator<Element> iter = modelPersonList.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
Element elemPerson = (Element) iter.next();
|
||||
Element elemPerson = iter.next();
|
||||
Individual individual = new Individual();
|
||||
|
||||
if ( isCommitor )
|
||||
{
|
||||
individual.setPrincipal( elemPerson.elementTextTrim( "id" ) );
|
||||
}
|
||||
|
||||
individual.setCommitor( isCommitor );
|
||||
individual.setEmail( elemPerson.elementTextTrim( "email" ) );
|
||||
individual.setName( elemPerson.elementTextTrim( "name" ) );
|
||||
|
@ -294,11 +298,11 @@ public class ProjectModel400Reader
|
|||
Element elemRoles = elemPerson.element( "roles" );
|
||||
if ( elemRoles != null )
|
||||
{
|
||||
List roleNames = elemRoles.elements( "role" );
|
||||
Iterator itRole = roleNames.iterator();
|
||||
List<Element> roleNames = elemRoles.elements( "role" );
|
||||
Iterator<Element> itRole = roleNames.iterator();
|
||||
while ( itRole.hasNext() )
|
||||
{
|
||||
Element role = (Element) itRole.next();
|
||||
Element role = itRole.next();
|
||||
individual.addRole( role.getTextTrim() );
|
||||
}
|
||||
}
|
||||
|
@ -329,19 +333,18 @@ public class ProjectModel400Reader
|
|||
return null;
|
||||
}
|
||||
|
||||
private List getLicenses( XMLReader xml )
|
||||
private List<License> getLicenses( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List licenses = new ArrayList();
|
||||
List<License> licenses = new ArrayList<License>();
|
||||
|
||||
Element elemLicenses = xml.getElement( "//project/licenses" );
|
||||
|
||||
if ( elemLicenses != null )
|
||||
{
|
||||
Iterator itLicense = elemLicenses.elements( "license" ).iterator();
|
||||
while ( itLicense.hasNext() )
|
||||
List<Element> licenseList = elemLicenses.elements( "license" );
|
||||
for ( Element elemLicense : licenseList )
|
||||
{
|
||||
Element elemLicense = (Element) itLicense.next();
|
||||
License license = new License();
|
||||
|
||||
// TODO: Create LicenseIdentity class to managed license ids.
|
||||
|
@ -357,16 +360,14 @@ public class ProjectModel400Reader
|
|||
return licenses;
|
||||
}
|
||||
|
||||
private List getMailingLists( XMLReader xml )
|
||||
private List<MailingList> getMailingLists( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List mailingLists = new ArrayList();
|
||||
List<MailingList> mailingLists = new ArrayList<MailingList>();
|
||||
|
||||
List mailingListElems = xml.getElementList( "//project/mailingLists/mailingList" );
|
||||
Iterator it = mailingListElems.iterator();
|
||||
while ( it.hasNext() )
|
||||
List<Element> mailingListElems = xml.getElementList( "//project/mailingLists/mailingList" );
|
||||
for ( Element elemMailingList : mailingListElems )
|
||||
{
|
||||
Element elemMailingList = (Element) it.next();
|
||||
MailingList mlist = new MailingList();
|
||||
|
||||
mlist.setName( elemMailingList.elementTextTrim( "name" ) );
|
||||
|
@ -378,11 +379,11 @@ public class ProjectModel400Reader
|
|||
Element elemOtherArchives = elemMailingList.element( "otherArchives" );
|
||||
if ( elemOtherArchives != null )
|
||||
{
|
||||
List otherArchives = new ArrayList();
|
||||
Iterator itother = elemOtherArchives.elementIterator( "otherArchive" );
|
||||
while ( itother.hasNext() )
|
||||
List<String> otherArchives = new ArrayList<String>();
|
||||
List<Element> others = elemOtherArchives.elements( "otherArchive" );
|
||||
for ( Element other : others )
|
||||
{
|
||||
String otherArchive = ( (Element) itother.next() ).getTextTrim();
|
||||
String otherArchive = other.getTextTrim();
|
||||
otherArchives.add( otherArchive );
|
||||
}
|
||||
|
||||
|
@ -425,7 +426,7 @@ public class ProjectModel400Reader
|
|||
return null;
|
||||
}
|
||||
|
||||
private List getPlugins( XMLReader xml )
|
||||
private List<ArtifactReference> getPlugins( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/build/plugins/plugin", "maven-plugin" );
|
||||
|
@ -440,7 +441,7 @@ public class ProjectModel400Reader
|
|||
|
||||
Properties ret = new Properties();
|
||||
|
||||
Iterator itProps = elemProperties.elements().iterator();
|
||||
Iterator<Element> itProps = elemProperties.elements().iterator();
|
||||
while ( itProps.hasNext() )
|
||||
{
|
||||
Element elemProp = (Element) itProps.next();
|
||||
|
@ -463,16 +464,16 @@ public class ProjectModel400Reader
|
|||
return null;
|
||||
}
|
||||
|
||||
private List getReports( XMLReader xml )
|
||||
private List<ArtifactReference> getReports( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/reporting/plugins/plugin", "maven-plugin" );
|
||||
}
|
||||
|
||||
private List getRepositories( XMLReader xml )
|
||||
private List<ProjectRepository> getRepositories( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List repos = new ArrayList();
|
||||
List<ProjectRepository> repos = new ArrayList<ProjectRepository>();
|
||||
|
||||
repos.addAll( getRepositories( xml, false, "//project/repositories/repository" ) );
|
||||
repos.addAll( getRepositories( xml, true, "//project/pluginRepositories/pluginRepository" ) );
|
||||
|
@ -480,17 +481,15 @@ public class ProjectModel400Reader
|
|||
return repos;
|
||||
}
|
||||
|
||||
private List getRepositories( XMLReader xml, boolean isPluginRepo, String xpathExpr )
|
||||
private List<ProjectRepository> getRepositories( XMLReader xml, boolean isPluginRepo, String xpathExpr )
|
||||
throws XMLException
|
||||
{
|
||||
List ret = new ArrayList();
|
||||
List<ProjectRepository> ret = new ArrayList<ProjectRepository>();
|
||||
|
||||
List repositoriesList = xml.getElementList( xpathExpr );
|
||||
List<Element> repositoriesList = xml.getElementList( xpathExpr );
|
||||
|
||||
Iterator itRepos = repositoriesList.iterator();
|
||||
while ( itRepos.hasNext() )
|
||||
for ( Element elemRepo : repositoriesList )
|
||||
{
|
||||
Element elemRepo = (Element) itRepos.next();
|
||||
ProjectRepository repo = new ProjectRepository();
|
||||
|
||||
repo.setId( elemRepo.elementTextTrim( "id" ) );
|
||||
|
|
|
@ -25,9 +25,14 @@ import org.apache.commons.lang.StringUtils;
|
|||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.CiManagement;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.Exclusion;
|
||||
import org.apache.maven.archiva.model.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.MailingList;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
|
@ -97,25 +102,40 @@ public class ProjectModel400Writer
|
|||
|
||||
addParent( root, model.getParentProject() );
|
||||
|
||||
addOptionalElementText( root, "groupId", model.getGroupId() );
|
||||
addChildElement( root, "groupId", model.getGroupId() );
|
||||
root.addElement( "artifactId" ).setText( model.getArtifactId() );
|
||||
|
||||
addOptionalElementText( root, "version", model.getVersion() );
|
||||
addChildElement( root, "version", model.getVersion() );
|
||||
|
||||
addOptionalElementText( root, "packaging", model.getPackaging() );
|
||||
addOptionalElementText( root, "name", model.getName() );
|
||||
addOptionalElementText( root, "description", model.getDescription() );
|
||||
addOptionalElementText( root, "url", model.getUrl() );
|
||||
addChildElement( root, "packaging", model.getPackaging() );
|
||||
addChildElement( root, "name", model.getName() );
|
||||
addChildElement( root, "description", model.getDescription() );
|
||||
addChildElement( root, "url", model.getUrl() );
|
||||
// TODO: add inceptionYear to ArchivaProjectModel
|
||||
|
||||
addOrganization( root, model.getOrganization() );
|
||||
|
||||
addIssueManagement( root, model.getIssueManagement() );
|
||||
addCiManagement( root, model.getCiManagement() );
|
||||
addMailingLists( root, model.getMailingLists() );
|
||||
addDevelopersAndContributors( root, model.getIndividuals() );
|
||||
// TODO: add distribution management to ArchivaProjectModel
|
||||
|
||||
addLicenses( root, model.getLicenses() );
|
||||
addRepositories( root, model.getRepositories() );
|
||||
addDependencyManagement( root, model.getDependencyManagement() );
|
||||
addDependencies( root, model.getDependencies() );
|
||||
|
||||
addReporting( root, model.getReports() );
|
||||
addScm( root, model.getScm() );
|
||||
|
||||
// <build> element
|
||||
addPlugins( root, model.getPlugins() );
|
||||
addBuildExtensions( root, model.getBuildExtensions() );
|
||||
|
||||
// <distributionManagement>
|
||||
addRelocation( root, model.getRelocation() );
|
||||
|
||||
fixDefaultNamespace( root );
|
||||
|
||||
try
|
||||
|
@ -128,37 +148,99 @@ public class ProjectModel400Writer
|
|||
}
|
||||
}
|
||||
|
||||
private void addScm( Element root, Scm scm )
|
||||
private void addArtifactReference( Element elem, ArtifactReference ref, String defaultType )
|
||||
{
|
||||
if( scm == null )
|
||||
addChildElement( elem, "groupId", ref.getGroupId() );
|
||||
addChildElement( elem, "artifactId", ref.getArtifactId() );
|
||||
addChildElement( elem, "version", ref.getVersion() );
|
||||
addChildElement( elem, "classifier", ref.getClassifier() );
|
||||
|
||||
if ( !StringUtils.equals( defaultType, ref.getType() ) )
|
||||
{
|
||||
return;
|
||||
addChildElement( elem, "type", ref.getType() );
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "scm" );
|
||||
|
||||
addOptionalElementText( elem, "connection", scm.getConnection() );
|
||||
addOptionalElementText( elem, "developerConnection", scm.getDeveloperConnection() );
|
||||
addOptionalElementText( elem, "url", scm.getUrl() );
|
||||
}
|
||||
|
||||
private void addReporting( Element root, List<ArtifactReference> reports )
|
||||
private void addBuildExtensions( Element root, List<ArtifactReference> buildExtensions )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( reports ) )
|
||||
if ( CollectionUtils.isEmpty( buildExtensions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element reporting = root.addElement( "reporting" );
|
||||
Element plugins = reporting.addElement( "plugins" );
|
||||
|
||||
for ( ArtifactReference reference : reports )
|
||||
Element build = root.element( "build" );
|
||||
if ( build == null )
|
||||
{
|
||||
Element plugin = plugins.addElement( "plugin" );
|
||||
addOptionalElementText( plugin, "groupId", reference.getGroupId() );
|
||||
addOptionalElementText( plugin, "artifactId", reference.getArtifactId() );
|
||||
addOptionalElementText( plugin, "version", reference.getVersion() );
|
||||
build = root.addElement( "build" );
|
||||
}
|
||||
|
||||
Element elemExtensions = build.addElement( "extensions" );
|
||||
|
||||
for ( ArtifactReference extension : buildExtensions )
|
||||
{
|
||||
Element elem = elemExtensions.addElement( "extension" );
|
||||
|
||||
addArtifactReference( elem, extension, "jar" );
|
||||
}
|
||||
}
|
||||
|
||||
private void addCiManagement( Element root, CiManagement ciManagement )
|
||||
{
|
||||
if ( ciManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "ciManagement" );
|
||||
addChildElement( elem, "system", ciManagement.getSystem() );
|
||||
addChildElement( elem, "url", ciManagement.getUrl() );
|
||||
// TODO: Add notifiers into ArchivaProjectModel
|
||||
}
|
||||
|
||||
private void addDependencies( Element root, List<Dependency> dependencies )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencies ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addDependencyList( root, dependencies );
|
||||
}
|
||||
|
||||
private void addDependencyList( Element elemParent, List<Dependency> dependencies )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencies ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemDeps = elemParent.addElement( "dependencies" );
|
||||
|
||||
for ( Dependency dep : dependencies )
|
||||
{
|
||||
Element elem = elemDeps.addElement( "dependency" );
|
||||
|
||||
addChildElement( elem, "groupId", dep.getGroupId() );
|
||||
addChildElement( elem, "artifactId", dep.getArtifactId() );
|
||||
addChildElement( elem, "version", dep.getVersion() );
|
||||
addChildElement( elem, "classifier", dep.getClassifier() );
|
||||
addChildElement( elem, "type", dep.getType() );
|
||||
addChildElement( elem, "scope", dep.getScope() );
|
||||
addChildElement( elem, "systemPath", dep.getSystemPath() );
|
||||
|
||||
addExclusions( elem, dep.getExclusions() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addDependencyManagement( Element root, List<Dependency> dependencyManagement )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencyManagement ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemDepMgmt = root.addElement( "dependencyManagement" );
|
||||
addDependencyList( elemDepMgmt, dependencyManagement );
|
||||
}
|
||||
|
||||
private void addDevelopersAndContributors( Element root, List<Individual> individuals )
|
||||
|
@ -181,7 +263,7 @@ public class ProjectModel400Writer
|
|||
}
|
||||
|
||||
Element developer = developers.addElement( "developer" );
|
||||
addOptionalElementText( developer, "id", individual.getPrincipal() );
|
||||
addChildElement( developer, "id", individual.getPrincipal() );
|
||||
addIndividual( developer, individual );
|
||||
}
|
||||
else
|
||||
|
@ -197,12 +279,31 @@ public class ProjectModel400Writer
|
|||
}
|
||||
}
|
||||
|
||||
private void addExclusions( Element elemParent, List<Exclusion> exclusions )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( exclusions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemExclusions = elemParent.addElement( "exclusions" );
|
||||
|
||||
for ( Exclusion exclusion : exclusions )
|
||||
{
|
||||
Element elem = elemExclusions.addElement( "exclusion" );
|
||||
|
||||
addChildElement( elem, "groupId", exclusion.getGroupId() );
|
||||
addChildElement( elem, "artifactId", exclusion.getArtifactId() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addIndividual( Element elem, Individual individual )
|
||||
{
|
||||
addOptionalElementText( elem, "name", individual.getName() );
|
||||
addOptionalElementText( elem, "email", individual.getEmail() );
|
||||
addOptionalElementText( elem, "organization", individual.getOrganization() );
|
||||
addOptionalElementText( elem, "timezone", individual.getTimezone() );
|
||||
addChildElement( elem, "name", individual.getName() );
|
||||
addChildElement( elem, "email", individual.getEmail() );
|
||||
addChildElement( elem, "organization", individual.getOrganization() );
|
||||
addChildElement( elem, "organizationUrl", individual.getOrganizationUrl() );
|
||||
addChildElement( elem, "timezone", individual.getTimezone() );
|
||||
|
||||
if ( CollectionUtils.isNotEmpty( individual.getRoles() ) )
|
||||
{
|
||||
|
@ -210,11 +311,41 @@ public class ProjectModel400Writer
|
|||
List<String> roleList = individual.getRoles();
|
||||
for ( String roleName : roleList )
|
||||
{
|
||||
addOptionalElementText( roles, "role", roleName );
|
||||
addChildElement( roles, "role", roleName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addIssueManagement( Element root, IssueManagement issueManagement )
|
||||
{
|
||||
if ( issueManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "issueManagement" );
|
||||
addChildElement( elem, "system", issueManagement.getSystem() );
|
||||
addChildElement( elem, "url", issueManagement.getUrl() );
|
||||
}
|
||||
|
||||
private void addLicenses( Element root, List<License> licenses )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( licenses ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemLicenses = root.addElement( "licenses" );
|
||||
|
||||
for ( License license : licenses )
|
||||
{
|
||||
Element elem = elemLicenses.addElement( "license" );
|
||||
addChildElement( elem, "name", license.getName() );
|
||||
addChildElement( elem, "url", license.getUrl() );
|
||||
// TODO: research if we need <distribution> subelement.
|
||||
}
|
||||
}
|
||||
|
||||
private void addMailingLists( Element root, List<MailingList> mailingLists )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( mailingLists ) )
|
||||
|
@ -227,37 +358,42 @@ public class ProjectModel400Writer
|
|||
for ( MailingList mailingList : mailingLists )
|
||||
{
|
||||
Element mlist = mlists.addElement( "mailingList" );
|
||||
addOptionalElementText( mlist, "name", mailingList.getName() );
|
||||
addOptionalElementText( mlist, "post", mailingList.getPostAddress() );
|
||||
addOptionalElementText( mlist, "subscribe", mailingList.getSubscribeAddress() );
|
||||
addOptionalElementText( mlist, "unsubscribe", mailingList.getUnsubscribeAddress() );
|
||||
addOptionalElementText( mlist, "archive", mailingList.getMainArchiveUrl() );
|
||||
addChildElement( mlist, "name", mailingList.getName() );
|
||||
addChildElement( mlist, "post", mailingList.getPostAddress() );
|
||||
addChildElement( mlist, "subscribe", mailingList.getSubscribeAddress() );
|
||||
addChildElement( mlist, "unsubscribe", mailingList.getUnsubscribeAddress() );
|
||||
addChildElement( mlist, "archive", mailingList.getMainArchiveUrl() );
|
||||
|
||||
addOtherArchives( mlist, mailingList.getOtherArchives() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addCiManagement( Element root, CiManagement ciManagement )
|
||||
private void addOtherArchives( Element mlist, List<String> otherArchives )
|
||||
{
|
||||
if ( ciManagement == null )
|
||||
if ( CollectionUtils.isEmpty( otherArchives ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "ciManagement" );
|
||||
addOptionalElementText( elem, "system", ciManagement.getSystem() );
|
||||
addOptionalElementText( elem, "url", ciManagement.getUrl() );
|
||||
// TODO: Add notifiers into ArchivaProjectModel
|
||||
Element elemOtherArchives = mlist.addElement( "otherArchives" );
|
||||
|
||||
for ( String archive : otherArchives )
|
||||
{
|
||||
addChildElement( elemOtherArchives, "otherArchive", archive );
|
||||
}
|
||||
}
|
||||
|
||||
private void addIssueManagement( Element root, IssueManagement issueManagement )
|
||||
private void addOrganization( Element root, Organization organization )
|
||||
{
|
||||
if ( issueManagement == null )
|
||||
if ( organization == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "issueManagement" );
|
||||
addOptionalElementText( elem, "system", issueManagement.getSystem() );
|
||||
addOptionalElementText( elem, "url", issueManagement.getUrl() );
|
||||
Element elem = root.addElement( "organization" );
|
||||
|
||||
addChildElement( elem, "name", organization.getName() );
|
||||
addChildElement( elem, "url", organization.getUrl() );
|
||||
}
|
||||
|
||||
private void addParent( Element root, VersionedReference parentProject )
|
||||
|
@ -273,10 +409,108 @@ public class ProjectModel400Writer
|
|||
parent.addElement( "version" ).setText( parentProject.getVersion() );
|
||||
}
|
||||
|
||||
private void addPlugins( Element root, List<ArtifactReference> plugins )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( plugins ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element build = root.element( "build" );
|
||||
if ( build == null )
|
||||
{
|
||||
build = root.addElement( "build" );
|
||||
}
|
||||
|
||||
Element elemPlugins = build.addElement( "plugins" );
|
||||
|
||||
for ( ArtifactReference plugin : plugins )
|
||||
{
|
||||
Element elem = elemPlugins.addElement( "plugin" );
|
||||
|
||||
addArtifactReference( elem, plugin, "maven-plugin" );
|
||||
}
|
||||
}
|
||||
|
||||
private void addRelocation( Element root, VersionedReference relocation )
|
||||
{
|
||||
if ( relocation == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element distribManagement = root.element( "distributionManagement" );
|
||||
|
||||
if ( distribManagement == null )
|
||||
{
|
||||
distribManagement = root.addElement( "distributionManagement" );
|
||||
}
|
||||
|
||||
Element elem = distribManagement.addElement( "relocation" );
|
||||
addChildElement( elem, "groupId", relocation.getGroupId() );
|
||||
addChildElement( elem, "artifactId", relocation.getArtifactId() );
|
||||
addChildElement( elem, "version", relocation.getVersion() );
|
||||
}
|
||||
|
||||
private void addReporting( Element root, List<ArtifactReference> reports )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( reports ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element reporting = root.addElement( "reporting" );
|
||||
Element plugins = reporting.addElement( "plugins" );
|
||||
|
||||
for ( ArtifactReference reference : reports )
|
||||
{
|
||||
Element plugin = plugins.addElement( "plugin" );
|
||||
addChildElement( plugin, "groupId", reference.getGroupId() );
|
||||
addChildElement( plugin, "artifactId", reference.getArtifactId() );
|
||||
addChildElement( plugin, "version", reference.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addRepositories( Element root, List<ProjectRepository> repositories )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( repositories ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemRepos = root.addElement( "repositories" );
|
||||
for ( ProjectRepository repository : repositories )
|
||||
{
|
||||
Element elem = elemRepos.addElement( "repository" );
|
||||
addChildElement( elem, "id", repository.getId() );
|
||||
addChildElement( elem, "name", repository.getName() );
|
||||
addChildElement( elem, "url", repository.getUrl() );
|
||||
|
||||
if ( !StringUtils.equals( "default", repository.getLayout() ) )
|
||||
{
|
||||
addChildElement( elem, "layout", repository.getLayout() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addScm( Element root, Scm scm )
|
||||
{
|
||||
if ( scm == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "scm" );
|
||||
|
||||
addChildElement( elem, "connection", scm.getConnection() );
|
||||
addChildElement( elem, "developerConnection", scm.getDeveloperConnection() );
|
||||
addChildElement( elem, "url", scm.getUrl() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the default namespace on all elements recursively.
|
||||
*/
|
||||
public void fixDefaultNamespace( Element elem )
|
||||
private void fixDefaultNamespace( Element elem )
|
||||
{
|
||||
elem.remove( elem.getNamespace() );
|
||||
elem.setQName( QName.get( elem.getName(), DEFAULT_NAMESPACE, elem.getQualifiedName() ) );
|
||||
|
@ -297,7 +531,7 @@ public class ProjectModel400Writer
|
|||
}
|
||||
}
|
||||
|
||||
private static void addOptionalElementText( Element elem, String elemName, String text )
|
||||
private static void addChildElement( Element elem, String elemName, String text )
|
||||
{
|
||||
if ( StringUtils.isBlank( text ) )
|
||||
{
|
||||
|
|
|
@ -0,0 +1,284 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.apache</groupId>
|
||||
<artifactId>apache</artifactId>
|
||||
<version>1</version>
|
||||
</parent>
|
||||
<groupId>org.apache.cocoon</groupId>
|
||||
<artifactId>cocoon</artifactId>
|
||||
<version>1</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Apache Cocoon</name>
|
||||
<url>http://cocoon.apache.org</url>
|
||||
<organization>
|
||||
<name>The Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
<issueManagement>
|
||||
<system>jira</system>
|
||||
<url>https://issues.apache.org/jira/browse/COCOON</url>
|
||||
</issueManagement>
|
||||
<ciManagement>
|
||||
<system>continuum</system>
|
||||
<url>http://cocoon.zones.apache.org:12000/continuum/servlet/continuum</url>
|
||||
</ciManagement>
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>Cocoon User List</name>
|
||||
<post>users@cocoon.apache.org</post>
|
||||
<subscribe>users-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>users-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-users</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/users@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-user</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.user</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>Cocoon Developer List</name>
|
||||
<post>dev@cocoon.apache.org</post>
|
||||
<subscribe>dev-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-dev</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/dev@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-dev</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.dev</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>Cocoon Documentation List</name>
|
||||
<post>docs@cocoon.apache.org</post>
|
||||
<subscribe>docs-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>docs-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-docs</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/dev@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-docs</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.docs</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>Cocoon Subversion Repository List</name>
|
||||
<subscribe>cvs-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>cvs-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-cvs</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/cvs@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-cvs</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.cvs</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>crossley</id>
|
||||
<name>David Crossley</name>
|
||||
<email>crossley@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org/</organizationUrl>
|
||||
<timezone>+10</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>bdelacretaz</id>
|
||||
<name>Bertrand Delacretaz</name>
|
||||
<email>bdelacretaz@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>danielf</id>
|
||||
<name>Daniel Fagerstrom</name>
|
||||
<email>danielf@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>antonio</id>
|
||||
<name>Antonio Gallardo</name>
|
||||
<email>antonio@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>-6</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>lgawron</id>
|
||||
<name>Leszek Gawron</name>
|
||||
<email>lgawron@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>joerg</id>
|
||||
<name>Jörg Heinicke</name>
|
||||
<email>joerg@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jheymans</id>
|
||||
<name>Jorg Heymans</name>
|
||||
<email>jheymans@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>anathaniel</id>
|
||||
<name>Alfred Nathaniel</name>
|
||||
<email>anathaniel@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>giacomo</id>
|
||||
<name>Giacomo Pati</name>
|
||||
<email>giacomo@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>reinhard</id>
|
||||
<name>Reinhard Poetz</name>
|
||||
<email>reinhard@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jbq</id>
|
||||
<name>Jean-Baptiste Quenot</name>
|
||||
<email>jbq@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>gianugo</id>
|
||||
<name>Gianugo Rabellino</name>
|
||||
<email>gianugo@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>cziegeler</id>
|
||||
<name>Carsten Ziegeler</name>
|
||||
<email>cziegeler@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>vgritsenko</id>
|
||||
<name>Vadim Gritsenko</name>
|
||||
<email>vgritsenko@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>-5</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
</developers>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
</license>
|
||||
</licenses>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Maven central repository</name>
|
||||
<url>http://ibiblio.org/maven2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>apache.snapshot</id>
|
||||
<name>Apache Snapshot Repository</name>
|
||||
<url>http://svn.apache.org/maven-snapshot-repository</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>apache-cvs</id>
|
||||
<name>Apache Maven Repository</name>
|
||||
<url>http://svn.apache.org/repository</url>
|
||||
<layout>legacy</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
<scm>
|
||||
<connection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-1</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-1</developerConnection>
|
||||
<url>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-1</url>
|
||||
</scm>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-6</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
</build>
|
||||
</project>
|
|
@ -47,6 +47,7 @@
|
|||
</mailingLists>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>jvanzyl</id>
|
||||
<name>Jason van Zyl</name>
|
||||
<email>jason@maven.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -56,6 +57,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>brett</id>
|
||||
<name>Brett Porter</name>
|
||||
<email>brett@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -65,6 +67,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>evenisse</id>
|
||||
<name>Emmanuel Venisse</name>
|
||||
<email>evenisse@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -74,6 +77,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>kenney</id>
|
||||
<name>Kenney Westerhof</name>
|
||||
<email>kenney@apache.org</email>
|
||||
<organization>Neonics</organization>
|
||||
|
@ -82,6 +86,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>snicoll</id>
|
||||
<name>Stephane Nicoll</name>
|
||||
<email>snicoll@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -91,6 +96,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>vmassol</id>
|
||||
<name>Vincent Massol</name>
|
||||
<email>vmassol@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -100,6 +106,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>fgiust</id>
|
||||
<name>Fabrizio Giustina</name>
|
||||
<email>fgiust@apache.org</email>
|
||||
<organization>openmind</organization>
|
||||
|
@ -109,6 +116,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>epunzalan</id>
|
||||
<name>Edwin Punzalan</name>
|
||||
<email>epunzalan@mergere.com</email>
|
||||
<organization>Mergere</organization>
|
||||
|
@ -118,6 +126,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>mperham</id>
|
||||
<name>Mike Perham</name>
|
||||
<email>mperham@gmail.com</email>
|
||||
<organization>IBM</organization>
|
||||
|
@ -127,6 +136,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jdcasey</id>
|
||||
<name>John Casey</name>
|
||||
<email>jdcasey@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -136,6 +146,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>trygvis</id>
|
||||
<name>Trygve Laugstol</name>
|
||||
<email>trygvis@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -145,6 +156,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>vsiveton</id>
|
||||
<name>Vincent Siveton</name>
|
||||
<email>vsiveton@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -154,6 +166,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>carlos</id>
|
||||
<name>Carlos Sanchez</name>
|
||||
<email>carlos@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
@ -163,6 +176,7 @@
|
|||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>dennisl</id>
|
||||
<name>Dennis Lundberg</name>
|
||||
<email>dennisl@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
|
|
|
@ -21,9 +21,17 @@ package org.apache.maven.archiva.repository.project.filters;
|
|||
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelWriter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.repository.project.writers.ProjectModel400Writer;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
@ -37,11 +45,14 @@ import java.util.List;
|
|||
public class ProjectModelExpressionExpanderTest
|
||||
extends PlexusTestCase
|
||||
{
|
||||
private ProjectModelExpressionFilter lookupExpression() throws Exception
|
||||
private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository";
|
||||
|
||||
private ProjectModelExpressionFilter lookupExpression()
|
||||
throws Exception
|
||||
{
|
||||
return (ProjectModelExpressionFilter) lookup( ProjectModelFilter.class, "expression" );
|
||||
}
|
||||
|
||||
|
||||
public void testExpressionEvaluation()
|
||||
throws Exception
|
||||
{
|
||||
|
@ -50,18 +61,18 @@ public class ProjectModelExpressionExpanderTest
|
|||
model.setArtifactId( "archiva-test-project" );
|
||||
model.setVersion( "1.0-SNAPSHOT" );
|
||||
|
||||
List deps = new ArrayList();
|
||||
|
||||
List<Dependency> deps = new ArrayList<Dependency>();
|
||||
|
||||
deps.add( createDependency( "org.apache.maven.archiva", "archiva-model", "${archiva.version}" ) );
|
||||
deps.add( createDependency( "org.apache.maven.archiva", "archiva-common", "${archiva.version}" ) );
|
||||
deps.add( createDependency( "org.apache.maven.archiva", "archiva-indexer", "${archiva.version}" ) );
|
||||
|
||||
model.setDependencies( deps );
|
||||
|
||||
|
||||
model.addProperty( "archiva.version", "1.0-SNAPSHOT" );
|
||||
|
||||
ProjectModelExpressionFilter filter = lookupExpression();
|
||||
|
||||
|
||||
model = filter.filter( model );
|
||||
|
||||
assertNotNull( model );
|
||||
|
@ -71,16 +82,64 @@ public class ProjectModelExpressionExpanderTest
|
|||
assertNotNull( "Dependencies", model.getDependencies() );
|
||||
assertEquals( "Dependencies Size", 3, model.getDependencies().size() );
|
||||
|
||||
Iterator it = model.getDependencies().iterator();
|
||||
Iterator<Dependency> it = model.getDependencies().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = (Dependency) it.next();
|
||||
Dependency dep = it.next();
|
||||
assertEquals( "Dependency [" + dep.getArtifactId() + "] Group ID", "org.apache.maven.archiva", dep
|
||||
.getGroupId() );
|
||||
assertEquals( "Dependency [" + dep.getArtifactId() + "] Version", "1.0-SNAPSHOT", dep.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [MRM-487] pom version is not resolved
|
||||
* [MRM-488] properties in pom are not resolved (at least while browsing)
|
||||
*
|
||||
* This is to ensure that any expression within the pom is evaluated properly.
|
||||
*/
|
||||
public void testExpressionHell()
|
||||
throws Exception
|
||||
{
|
||||
ProjectModelExpressionFilter filter = lookupExpression();
|
||||
|
||||
ArchivaProjectModel initialModel = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
+ "/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom" );
|
||||
|
||||
ArchivaProjectModel filteredModel = filter.filter( initialModel );
|
||||
|
||||
// Dump the evaluated model to xml
|
||||
String evaluatedModelText = toModelText( filteredModel );
|
||||
|
||||
// Test xml buffer for the existance of an unevaluated expression.
|
||||
if ( evaluatedModelText.indexOf( "${" ) != ( -1 ) )
|
||||
{
|
||||
System.err.println( "Found Expression:\n" + evaluatedModelText );
|
||||
fail( "Found Unevaluated Expression. (see System.err)" );
|
||||
}
|
||||
}
|
||||
|
||||
private String toModelText( ArchivaProjectModel model )
|
||||
throws ProjectModelException, IOException
|
||||
{
|
||||
StringWriter strWriter = new StringWriter();
|
||||
|
||||
ProjectModelWriter modelWriter = new ProjectModel400Writer();
|
||||
modelWriter.write( model, strWriter );
|
||||
|
||||
return strWriter.toString();
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws ProjectModelException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
File pomFile = new File( getBasedir(), path );
|
||||
|
||||
return reader.read( pomFile );
|
||||
}
|
||||
|
||||
private Dependency createDependency( String groupId, String artifactId, String version )
|
||||
{
|
||||
Dependency dep = new Dependency();
|
||||
|
|
|
@ -19,7 +19,6 @@ package org.apache.maven.archiva.repository.project.writers;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.beanutils.PropertyUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
|
@ -29,18 +28,10 @@ import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader
|
|||
import org.codehaus.plexus.PlexusTestCase;
|
||||
import org.custommonkey.xmlunit.DetailedDiff;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentType;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Namespace;
|
||||
import org.dom4j.io.SAXReader;
|
||||
import org.dom4j.io.XMLWriter;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* ProjectModel400WriterTest
|
||||
|
@ -90,7 +81,7 @@ public class ProjectModel400WriterTest
|
|||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
public void testReadWriteComplex()
|
||||
public void testReadWriteMavenParent()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
|
@ -101,6 +92,18 @@ public class ProjectModel400WriterTest
|
|||
|
||||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
public void testReadWriteCocoon()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
+ "/org/apache/cocoon/cocoon/1/cocoon-1.pom" );
|
||||
|
||||
String actualModel = writeToString( model );
|
||||
String expectedModel = getExpectedModelString( "cocoon-1.pom" );
|
||||
|
||||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
private void assertModelSimilar( String expectedModel, String actualModel )
|
||||
throws Exception
|
||||
|
|
|
@ -0,0 +1,379 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
Copyright 2005 The Apache Software Foundation
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
<!--+
|
||||
| This is the main Maven file that contains all global settings, management and information.
|
||||
| @version $Id$
|
||||
+-->
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.apache</groupId>
|
||||
<artifactId>apache</artifactId>
|
||||
<version>1</version>
|
||||
</parent>
|
||||
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<groupId>org.apache.cocoon</groupId>
|
||||
<artifactId>cocoon</artifactId>
|
||||
<version>1</version>
|
||||
|
||||
<name>Apache Cocoon</name>
|
||||
<url>http://cocoon.apache.org</url>
|
||||
<licenses>
|
||||
<license>
|
||||
<name>Apache License, Version 2.0</name>
|
||||
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
|
||||
<distribution>repo</distribution>
|
||||
</license>
|
||||
</licenses>
|
||||
<!--modules>
|
||||
<module>blocks</module>
|
||||
<module>commons</module>
|
||||
<module>core</module>
|
||||
<module>tools</module>
|
||||
</modules-->
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>central</id>
|
||||
<name>Maven central repository</name>
|
||||
<url>http://ibiblio.org/maven2</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>apache.snapshot</id>
|
||||
<name>Apache Snapshot Repository</name>
|
||||
<url>http://svn.apache.org/maven-snapshot-repository</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>apache-cvs</id>
|
||||
<name>Apache Maven Repository</name>
|
||||
<url>http://svn.apache.org/repository</url>
|
||||
<layout>legacy</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
<!-- Activate this element if you want to use snapshot versions of plugins
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>snapshots</id>
|
||||
<url>http://snapshots.maven.codehaus.org/maven2</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
-->
|
||||
<organization>
|
||||
<name>The Apache Software Foundation</name>
|
||||
<url>http://www.apache.org/</url>
|
||||
</organization>
|
||||
<developers>
|
||||
<developer>
|
||||
<id>crossley</id>
|
||||
<name>David Crossley</name>
|
||||
<email>crossley@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org/</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+10</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>bdelacretaz</id>
|
||||
<name>Bertrand Delacretaz</name>
|
||||
<email>bdelacretaz@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>danielf</id>
|
||||
<name>Daniel Fagerstrom</name>
|
||||
<email>danielf@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>antonio</id>
|
||||
<name>Antonio Gallardo</name>
|
||||
<email>antonio@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>-6</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>lgawron</id>
|
||||
<name>Leszek Gawron</name>
|
||||
<email>lgawron@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>joerg</id>
|
||||
<name>Jörg Heinicke</name>
|
||||
<email>joerg@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<timezone>+1</timezone>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jheymans</id>
|
||||
<name>Jorg Heymans</name>
|
||||
<email>jheymans@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>anathaniel</id>
|
||||
<name>Alfred Nathaniel</name>
|
||||
<email>anathaniel@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>giacomo</id>
|
||||
<name>Giacomo Pati</name>
|
||||
<email>giacomo@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>reinhard</id>
|
||||
<name>Reinhard Poetz</name>
|
||||
<email>reinhard@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>jbq</id>
|
||||
<name>Jean-Baptiste Quenot</name>
|
||||
<email>jbq@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>gianugo</id>
|
||||
<name>Gianugo Rabellino</name>
|
||||
<email>gianugo@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>cziegeler</id>
|
||||
<name>Carsten Ziegeler</name>
|
||||
<email>cziegeler@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>+1</timezone>
|
||||
</developer>
|
||||
<developer>
|
||||
<id>vgritsenko</id>
|
||||
<name>Vadim Gritsenko</name>
|
||||
<email>vgritsenko@apache.org</email>
|
||||
<organization>ASF</organization>
|
||||
<organizationUrl>http://www.apache.org</organizationUrl>
|
||||
<roles>
|
||||
<role>Committer</role>
|
||||
</roles>
|
||||
<timezone>-5</timezone>
|
||||
</developer>
|
||||
</developers>
|
||||
<issueManagement>
|
||||
<system>jira</system>
|
||||
<url>https://issues.apache.org/jira/browse/COCOON</url>
|
||||
</issueManagement>
|
||||
<ciManagement>
|
||||
<system>continuum</system>
|
||||
<url>http://cocoon.zones.apache.org:12000/continuum/servlet/continuum</url>
|
||||
<notifiers>
|
||||
<notifier>
|
||||
<type>mail</type>
|
||||
<configuration>
|
||||
<address>dev@cocoon.apache.org</address>
|
||||
</configuration>
|
||||
</notifier>
|
||||
</notifiers>
|
||||
</ciManagement>
|
||||
<mailingLists>
|
||||
<mailingList>
|
||||
<name>Cocoon User List</name>
|
||||
<subscribe>users-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>users-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<post>users@cocoon.apache.org</post>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-users</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/users@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-user</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.user</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>Cocoon Developer List</name>
|
||||
<subscribe>dev-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>dev-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<post>dev@cocoon.apache.org</post>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-dev</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/dev@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-dev</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.dev</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>Cocoon Documentation List</name>
|
||||
<subscribe>docs-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>docs-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<post>docs@cocoon.apache.org</post>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-docs</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/dev@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-docs</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.docs</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
<mailingList>
|
||||
<name>Cocoon Subversion Repository List</name>
|
||||
<subscribe>cvs-subscribe@cocoon.apache.org</subscribe>
|
||||
<unsubscribe>cvs-unsubscribe@cocoon.apache.org</unsubscribe>
|
||||
<archive>http://mail-archives.apache.org/mod_mbox/cocoon-cvs</archive>
|
||||
<otherArchives>
|
||||
<otherArchive>http://www.mail-archive.com/cvs@cocoon.apache.org/</otherArchive>
|
||||
<otherArchive>http://marc.theaimsgroup.com/?l=xml-cocoon-cvs</otherArchive>
|
||||
<otherArchive>http://news.gmane.org/gmane.text.xml.cocoon.cvs</otherArchive>
|
||||
</otherArchives>
|
||||
</mailingList>
|
||||
</mailingLists>
|
||||
<scm>
|
||||
<connection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-1</connection>
|
||||
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/cocoon/tags/cocoon-1</developerConnection>
|
||||
<url>https://svn.apache.org/repos/asf/cocoon/tags/cocoon-1</url>
|
||||
</scm>
|
||||
<distributionManagement>
|
||||
<repository>
|
||||
<id>apache-maven</id>
|
||||
<name>release repository</name>
|
||||
<url>scpexe://people.apache.org/www/people.apache.org/repo/m2-ibiblio-rsync-repository</url>
|
||||
</repository>
|
||||
<snapshotRepository>
|
||||
<id>apache-maven-snapshot</id>
|
||||
<name>snapshot repository</name>
|
||||
<url>scpexe://people.apache.org/www/people.apache.org/repo/m2-snapshot-repository</url>
|
||||
</snapshotRepository>
|
||||
</distributionManagement>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.apache.maven.wagon</groupId>
|
||||
<artifactId>wagon-ssh-external</artifactId>
|
||||
<version>1.0-alpha-6</version>
|
||||
</extension>
|
||||
</extensions>
|
||||
<!--
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.4</source>
|
||||
<target>1.4</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
-->
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<configuration>
|
||||
<tagBase>https://svn.apache.org/repos/asf/cocoon/tags</tagBase>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<reporting>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||
<reportSets>
|
||||
<reportSet>
|
||||
<reports>
|
||||
<report>dependencies</report>
|
||||
<report>project-team</report>
|
||||
<report>mailing-list</report>
|
||||
<report>cim</report>
|
||||
<report>issue-tracking</report>
|
||||
<report>license</report>
|
||||
<report>scm</report>
|
||||
</reports>
|
||||
</reportSet>
|
||||
</reportSets>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</reporting>
|
||||
</project>
|
Loading…
Reference in New Issue