mirror of https://github.com/apache/ant-ivy
IVY-217 extra attributes: now extra attributes can be used in patterns
git-svn-id: https://svn.apache.org/repos/asf/incubator/ivy/trunk@484305 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a204a6d33a
commit
856b838a06
|
|
@ -5,11 +5,16 @@
|
|||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Hanin
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractArtifact extends DefaultExtendableItem implements Artifact {
|
||||
public abstract class AbstractArtifact implements Artifact {
|
||||
public AbstractArtifact() {
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Artifact)) {
|
||||
return false;
|
||||
|
|
@ -19,7 +24,8 @@ public abstract class AbstractArtifact extends DefaultExtendableItem implements
|
|||
&& getPublicationDate()==null?true:getPublicationDate().equals(art.getPublicationDate())
|
||||
&& getName().equals(art.getName())
|
||||
&& getExt().equals(art.getExt())
|
||||
&& getType().equals(art.getType());
|
||||
&& getType().equals(art.getType())
|
||||
&& getExtraAttributes().equals(art.getExtraAttributes());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
|
@ -31,10 +37,37 @@ public abstract class AbstractArtifact extends DefaultExtendableItem implements
|
|||
hash = hash * 17 + getName().hashCode();
|
||||
hash = hash * 17 + getExt().hashCode();
|
||||
hash = hash * 17 + getType().hashCode();
|
||||
hash = hash * 17 + getExtraAttributes().hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return getModuleRevisionId()+"/"+getName()+"."+getExt()+"["+getType()+"]";
|
||||
}
|
||||
|
||||
public String getAttribute(String attName) {
|
||||
return getId().getAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getAttributes() {
|
||||
return getId().getAttributes();
|
||||
}
|
||||
|
||||
public String getExtraAttribute(String attName) {
|
||||
return getId().getExtraAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getExtraAttributes() {
|
||||
return getId().getExtraAttributes();
|
||||
}
|
||||
|
||||
public String getStandardAttribute(String attName) {
|
||||
return getId().getStandardAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getStandardAttributes() {
|
||||
return getId().getStandardAttributes();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package fr.jayasoft.ivy;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import fr.jayasoft.ivy.extendable.ExtendableItem;
|
||||
|
||||
|
||||
/**
|
||||
* @author x.hanin
|
||||
|
|
|
|||
|
|
@ -5,25 +5,41 @@
|
|||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import fr.jayasoft.ivy.extendable.UnmodifiableExtendableItem;
|
||||
import fr.jayasoft.ivy.util.IvyPatternHelper;
|
||||
|
||||
/**
|
||||
* identifies an artifact in a particular module revision
|
||||
*/
|
||||
public class ArtifactRevisionId {
|
||||
public class ArtifactRevisionId extends UnmodifiableExtendableItem {
|
||||
public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type, String ext) {
|
||||
return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid);
|
||||
return newInstance(mrid, name, type, ext, null);
|
||||
}
|
||||
|
||||
public static ArtifactRevisionId newInstance(ModuleRevisionId mrid, String name, String type, String ext, Map extraAttributes) {
|
||||
return new ArtifactRevisionId(new ArtifactId(mrid.getModuleId(), name, type, ext), mrid, extraAttributes);
|
||||
}
|
||||
|
||||
private ArtifactId _artifactId;
|
||||
private ModuleRevisionId _mrid;
|
||||
|
||||
|
||||
/**
|
||||
* @param revision
|
||||
* @param artifactId
|
||||
*/
|
||||
public ArtifactRevisionId(ArtifactId artifactId, ModuleRevisionId mrid) {
|
||||
this(artifactId, mrid, null);
|
||||
}
|
||||
public ArtifactRevisionId(ArtifactId artifactId, ModuleRevisionId mrid, Map extraAttributes) {
|
||||
super(null, extraAttributes);
|
||||
_artifactId = artifactId;
|
||||
_mrid = mrid;
|
||||
|
||||
setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, getModuleRevisionId().getOrganisation());
|
||||
setStandardAttribute(IvyPatternHelper.MODULE_KEY, getModuleRevisionId().getName());
|
||||
setStandardAttribute(IvyPatternHelper.REVISION_KEY, getModuleRevisionId().getRevision());
|
||||
setStandardAttribute(IvyPatternHelper.ARTIFACT_KEY, getName());
|
||||
setStandardAttribute(IvyPatternHelper.TYPE_KEY, getType());
|
||||
setStandardAttribute(IvyPatternHelper.EXT_KEY, getExt());
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
|
|
@ -32,13 +48,15 @@ public class ArtifactRevisionId {
|
|||
}
|
||||
ArtifactRevisionId arid = (ArtifactRevisionId)obj;
|
||||
return getArtifactId().equals(arid.getArtifactId())
|
||||
&& getModuleRevisionId().equals(arid.getModuleRevisionId());
|
||||
&& getModuleRevisionId().equals(arid.getModuleRevisionId())
|
||||
&& getExtraAttributes().equals(arid.getExtraAttributes());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
int hash = 17;
|
||||
hash += getArtifactId().hashCode() * 37;
|
||||
hash += getModuleRevisionId().hashCode() * 37;
|
||||
hash += getExtraAttributes().hashCode() * 37;
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,8 @@
|
|||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
import fr.jayasoft.ivy.extendable.DefaultExtendableItem;
|
||||
|
||||
|
||||
/**
|
||||
* Represents a module configuration
|
||||
|
|
|
|||
|
|
@ -6,25 +6,38 @@
|
|||
package fr.jayasoft.ivy;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Hanin
|
||||
*
|
||||
*/
|
||||
public class DefaultArtifact extends AbstractArtifact {
|
||||
|
||||
public static Artifact newIvyArtifact(ModuleRevisionId mrid, Date pubDate) {
|
||||
return new DefaultArtifact(mrid, pubDate, "ivy", "ivy", "xml");
|
||||
}
|
||||
|
||||
public static Artifact newPomArtifact(ModuleRevisionId mrid, Date pubDate) {
|
||||
return new DefaultArtifact(mrid, pubDate, mrid.getName(), "pom", "pom");
|
||||
}
|
||||
|
||||
public static Artifact cloneWithAnotherType(Artifact artifact, String newType) {
|
||||
return new DefaultArtifact(artifact.getModuleRevisionId(), artifact.getPublicationDate(), artifact.getName(), newType, artifact.getExt());
|
||||
return new DefaultArtifact(artifact.getModuleRevisionId(), artifact.getPublicationDate(), artifact.getName(), newType, artifact.getExt(), artifact.getExtraAttributes());
|
||||
}
|
||||
|
||||
Date _publicationDate;
|
||||
ArtifactRevisionId _arid;
|
||||
|
||||
public DefaultArtifact(ModuleRevisionId mrid, Date publicationDate, String name, String type, String ext) {
|
||||
this(mrid, publicationDate, name, type, ext, null);
|
||||
}
|
||||
public DefaultArtifact(ModuleRevisionId mrid, Date publicationDate, String name, String type, String ext, Map extraAttributes) {
|
||||
if (mrid == null) {
|
||||
throw new NullPointerException("null mrid not allowed");
|
||||
}
|
||||
if (publicationDate == null) {
|
||||
throw new NullPointerException("null publication date not allowed");
|
||||
publicationDate = new Date();
|
||||
}
|
||||
if (name == null) {
|
||||
throw new NullPointerException("null name not allowed");
|
||||
|
|
@ -36,7 +49,7 @@ public class DefaultArtifact extends AbstractArtifact {
|
|||
throw new NullPointerException("null ext not allowed");
|
||||
}
|
||||
_publicationDate = publicationDate;
|
||||
_arid = ArtifactRevisionId.newInstance(mrid, name, type, ext);
|
||||
_arid = ArtifactRevisionId.newInstance(mrid, name, type, ext, extraAttributes);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -62,4 +75,5 @@ public class DefaultArtifact extends AbstractArtifact {
|
|||
public String[] getConfigurations() {
|
||||
return new String[0];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ import fr.jayasoft.ivy.namespace.NamespaceTransformer;
|
|||
* @author Xavier Hanin
|
||||
*
|
||||
*/
|
||||
public class DefaultDependencyDescriptor extends DefaultExtendableItem implements DependencyDescriptor {
|
||||
public class DefaultDependencyDescriptor implements DependencyDescriptor {
|
||||
private static final Pattern SELF_FALLBACK_PATTERN = Pattern.compile("@(\\(.*\\))?");
|
||||
private static final Pattern THIS_FALLBACK_PATTERN = Pattern.compile("#(\\(.*\\))?");
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class DefaultDependencyDescriptor extends DefaultExtendableItem implement
|
|||
|
||||
public DefaultDependencyDescriptor(DependencyDescriptor dd, String revision) {
|
||||
_parentId = dd.getParentRevisionId();
|
||||
_revId = new ModuleRevisionId(dd.getDependencyId(), revision);
|
||||
_revId = new ModuleRevisionId(dd.getDependencyId(), revision, dd.getExtraAttributes());
|
||||
_force = dd.isForce();
|
||||
_changing = dd.isChanging();
|
||||
_transitive = dd.isTransitive();
|
||||
|
|
@ -379,5 +379,29 @@ public class DefaultDependencyDescriptor extends DefaultExtendableItem implement
|
|||
public Namespace getNamespace() {
|
||||
return _namespace;
|
||||
}
|
||||
|
||||
public String getAttribute(String attName) {
|
||||
return _revId.getAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getAttributes() {
|
||||
return _revId.getAttributes();
|
||||
}
|
||||
|
||||
public String getExtraAttribute(String attName) {
|
||||
return _revId.getExtraAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getExtraAttributes() {
|
||||
return _revId.getExtraAttributes();
|
||||
}
|
||||
|
||||
public String getStandardAttribute(String attName) {
|
||||
return _revId.getStandardAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getStandardAttributes() {
|
||||
return _revId.getStandardAttributes();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An item which is meant to be extended, i.e. defined using extra attributes
|
||||
*/
|
||||
public class DefaultExtendableItem {
|
||||
private Map _attributes = new HashMap();
|
||||
public String getAttribute(String attName) {
|
||||
return (String)_attributes.get(attName);
|
||||
}
|
||||
public void setAttribute(String attName, String attValue) {
|
||||
_attributes.put(attName, attValue);
|
||||
}
|
||||
}
|
||||
|
|
@ -26,7 +26,7 @@ import fr.jayasoft.ivy.util.Message;
|
|||
* @author X.Hanin
|
||||
*
|
||||
*/
|
||||
public class DefaultModuleDescriptor extends DefaultExtendableItem implements ModuleDescriptor {
|
||||
public class DefaultModuleDescriptor implements ModuleDescriptor {
|
||||
|
||||
public static DefaultModuleDescriptor newDefaultInstance(ModuleRevisionId mrid) {
|
||||
return newDefaultInstance(mrid, null);
|
||||
|
|
@ -387,4 +387,29 @@ public class DefaultModuleDescriptor extends DefaultExtendableItem implements Mo
|
|||
public boolean isMappingOverride() {
|
||||
return _mappingOverride;
|
||||
}
|
||||
|
||||
public String getAttribute(String attName) {
|
||||
return _resolvedRevId.getAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getAttributes() {
|
||||
return _resolvedRevId.getAttributes();
|
||||
}
|
||||
|
||||
public String getExtraAttribute(String attName) {
|
||||
return _resolvedRevId.getExtraAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getExtraAttributes() {
|
||||
return _resolvedRevId.getExtraAttributes();
|
||||
}
|
||||
|
||||
public String getStandardAttribute(String attName) {
|
||||
return _resolvedRevId.getStandardAttribute(attName);
|
||||
}
|
||||
|
||||
public Map getStandardAttributes() {
|
||||
return _resolvedRevId.getStandardAttributes();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@
|
|||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
import fr.jayasoft.ivy.extendable.ExtendableItem;
|
||||
import fr.jayasoft.ivy.namespace.Namespace;
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
public interface ExtendableItem {
|
||||
/**
|
||||
* Gets the value of a dependency attribute
|
||||
* Can be used to access the value of a standard attribute (like org, rev) or of an extra attribute.
|
||||
* Note that standard attribute are not really standardized, i.e. some implementations my not return
|
||||
* value for name, so avoid to rely on this in code in which you are not sure of the kind of module descriptor (ivy file, pom, ...) you use.
|
||||
* @param attName the name of the attribute to get
|
||||
* @return the value of the attribute, null if the attribute doesn't exist
|
||||
*/
|
||||
String getAttribute(String attName);
|
||||
}
|
||||
|
|
@ -752,7 +752,7 @@ public class Ivy implements TransferListener {
|
|||
revision = "working@"+getLocalHostName();
|
||||
}
|
||||
if (revision != null) {
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(md.getModuleRevisionId().getModuleId(), revision));
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(md.getModuleRevisionId().getModuleId(), revision, md.getModuleRevisionId().getExtraAttributes()));
|
||||
}
|
||||
if (confs.length == 1 && confs[0].equals("*")) {
|
||||
confs = md.getConfigurationsNames();
|
||||
|
|
@ -1601,14 +1601,14 @@ public class Ivy implements TransferListener {
|
|||
if (destIvyPattern != null) {
|
||||
ModuleRevisionId[] mrids = parser.getRealDependencyRevisionIds(moduleId, conf, cache);
|
||||
for (int j = 0; j < mrids.length; j++) {
|
||||
artifacts.add(new DefaultArtifact(mrids[j], new Date(), "ivy", "ivy", "xml"));
|
||||
artifacts.add(DefaultArtifact.newIvyArtifact(mrids[j], null));
|
||||
}
|
||||
}
|
||||
for (Iterator iter = artifacts.iterator(); iter.hasNext();) {
|
||||
Artifact artifact = (Artifact)iter.next();
|
||||
String destPattern = "ivy".equals(artifact.getType()) ? destIvyPattern: destFilePattern;
|
||||
|
||||
String destFileName = IvyPatternHelper.substitute(destPattern, artifact.getModuleRevisionId().getOrganisation(), artifact.getModuleRevisionId().getName(), artifact.getModuleRevisionId().getRevision(), artifact.getName(), artifact.getType(), artifact.getExt(), conf);
|
||||
String destFileName = IvyPatternHelper.substitute(destPattern, artifact, conf);
|
||||
|
||||
Set dest = (Set)artifactsToCopy.get(artifact);
|
||||
if (dest == null) {
|
||||
|
|
@ -1751,7 +1751,7 @@ public class Ivy implements TransferListener {
|
|||
try {
|
||||
ivyFileURL = ivyFile.toURL();
|
||||
md = XmlModuleDescriptorParser.getInstance().parseDescriptor(this, ivyFileURL, validate);
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), revision));
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), revision, mrid.getExtraAttributes()));
|
||||
md.setResolvedPublicationDate(pubdate);
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException("malformed url obtained for file "+ivyFile);
|
||||
|
|
@ -1851,7 +1851,7 @@ public class Ivy implements TransferListener {
|
|||
try {
|
||||
ivyFileURL = ivyFile.toURL();
|
||||
md = XmlModuleDescriptorParser.getInstance().parseDescriptor(this, ivyFileURL, false);
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), pubrevision));
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), pubrevision, mrid.getExtraAttributes()));
|
||||
} catch (MalformedURLException e) {
|
||||
throw new RuntimeException("malformed url obtained for file "+ivyFile);
|
||||
} catch (ParseException e) {
|
||||
|
|
@ -1883,7 +1883,7 @@ public class Ivy implements TransferListener {
|
|||
}
|
||||
}
|
||||
if (srcIvyPattern != null) {
|
||||
Artifact artifact = new MDArtifact(md, "ivy", "ivy", "xml");
|
||||
Artifact artifact = MDArtifact.newIvyArtifact(md);
|
||||
if (!publish(artifact, srcIvyPattern, resolver, overwrite)) {
|
||||
missing.add(artifact);
|
||||
}
|
||||
|
|
@ -1935,7 +1935,7 @@ public class Ivy implements TransferListener {
|
|||
}
|
||||
|
||||
public File getIvyFileInCache(File cache, ModuleRevisionId mrid) {
|
||||
return new File(cache, IvyPatternHelper.substitute(_cacheIvyPattern, mrid.getOrganisation(), mrid.getName(), mrid.getRevision(), "ivy", "ivy", "xml"));
|
||||
return new File(cache, IvyPatternHelper.substitute(_cacheIvyPattern, DefaultArtifact.newIvyArtifact(mrid, null)));
|
||||
}
|
||||
|
||||
public File getArchiveFileInCache(File cache, Artifact artifact) {
|
||||
|
|
@ -1947,17 +1947,14 @@ public class Ivy implements TransferListener {
|
|||
}
|
||||
|
||||
public String getArchivePathInCache(Artifact artifact) {
|
||||
return getArchivePathInCache(
|
||||
artifact.getModuleRevisionId().getOrganisation(),
|
||||
artifact.getModuleRevisionId().getName(),
|
||||
artifact.getModuleRevisionId().getRevision(),
|
||||
artifact.getName(),
|
||||
artifact.getType(),
|
||||
artifact.getExt());
|
||||
return IvyPatternHelper.substitute(_cacheArtifactPattern, artifact);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public String getArchivePathInCache(String organisation, String module, String revision, String artifact, String type, String ext) {
|
||||
return IvyPatternHelper.substitute(_cacheArtifactPattern, organisation, module, revision, artifact, type, ext);
|
||||
return getArchivePathInCache(new DefaultArtifact(ModuleRevisionId.newInstance(organisation, module, revision), new Date(), artifact, type, ext));
|
||||
}
|
||||
|
||||
public File getOriginFileInCache(File cache, Artifact artifact) {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
|
|
@ -834,7 +833,7 @@ public class IvyNode {
|
|||
}
|
||||
|
||||
private boolean isDependencyModuleExcluded(ModuleRevisionId dependencyRevisionId, String conf) {
|
||||
return doesCallersExclude(getRootModuleConf(), new DefaultArtifact(dependencyRevisionId, new Date(), "ivy", "ivy", "xml"));
|
||||
return doesCallersExclude(getRootModuleConf(), DefaultArtifact.newIvyArtifact(dependencyRevisionId, null));
|
||||
}
|
||||
|
||||
public ModuleRevisionId getId() {
|
||||
|
|
|
|||
|
|
@ -8,20 +8,30 @@ package fr.jayasoft.ivy;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author x.hanin
|
||||
*
|
||||
*/
|
||||
public class MDArtifact extends AbstractArtifact {
|
||||
|
||||
public static Artifact newIvyArtifact(ModuleDescriptor md) {
|
||||
return new MDArtifact(md, "ivy", "ivy", "xml");
|
||||
}
|
||||
|
||||
private ModuleDescriptor _md;
|
||||
private String _name;
|
||||
private String _type;
|
||||
private String _ext;
|
||||
private List _confs = new ArrayList();
|
||||
private ArtifactRevisionId _arid;
|
||||
private Map _extraAttributes = null;
|
||||
|
||||
public MDArtifact(ModuleDescriptor md, String name, String type, String ext) {
|
||||
this(md, name, type, ext, null);
|
||||
}
|
||||
public MDArtifact(ModuleDescriptor md, String name, String type, String ext, Map extraAttributes) {
|
||||
if (md == null) {
|
||||
throw new NullPointerException("null module descriptor not allowed");
|
||||
}
|
||||
|
|
@ -38,6 +48,7 @@ public class MDArtifact extends AbstractArtifact {
|
|||
_name = name;
|
||||
_type = type;
|
||||
_ext = ext;
|
||||
_extraAttributes = extraAttributes;
|
||||
}
|
||||
|
||||
public ModuleRevisionId getModuleRevisionId() {
|
||||
|
|
@ -49,10 +60,10 @@ public class MDArtifact extends AbstractArtifact {
|
|||
}
|
||||
public ArtifactRevisionId getId() {
|
||||
if (_arid == null) {
|
||||
_arid = ArtifactRevisionId.newInstance(_md.getResolvedModuleRevisionId(), _name, _type, _ext);
|
||||
_arid = ArtifactRevisionId.newInstance(_md.getResolvedModuleRevisionId(), _name, _type, _ext, _extraAttributes);
|
||||
}
|
||||
return _arid;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return _name;
|
||||
|
|
|
|||
|
|
@ -7,6 +7,8 @@ package fr.jayasoft.ivy;
|
|||
|
||||
import java.util.Date;
|
||||
|
||||
import fr.jayasoft.ivy.extendable.ExtendableItem;
|
||||
|
||||
/**
|
||||
* @author x.hanin
|
||||
*
|
||||
|
|
|
|||
|
|
@ -5,28 +5,45 @@
|
|||
*/
|
||||
package fr.jayasoft.ivy;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import fr.jayasoft.ivy.extendable.UnmodifiableExtendableItem;
|
||||
import fr.jayasoft.ivy.util.IvyPatternHelper;
|
||||
|
||||
|
||||
/**
|
||||
* @author x.hanin
|
||||
*
|
||||
*/
|
||||
public class ModuleRevisionId {
|
||||
public class ModuleRevisionId extends UnmodifiableExtendableItem {
|
||||
private static final String ENCODE_SEPARATOR = ModuleId.ENCODE_SEPARATOR;
|
||||
private static final String NO_REVISION = "[[NONE]]";
|
||||
|
||||
public static ModuleRevisionId newInstance(String organisation, String name, String revision) {
|
||||
return new ModuleRevisionId(new ModuleId(organisation, name), revision);
|
||||
}
|
||||
public static ModuleRevisionId newInstance(String organisation, String name, String revision, Map extraAttributes) {
|
||||
return new ModuleRevisionId(new ModuleId(organisation, name), revision, extraAttributes);
|
||||
}
|
||||
|
||||
private ModuleId _moduleId;
|
||||
private String _revision;
|
||||
private int _hash;
|
||||
|
||||
public ModuleRevisionId(ModuleId moduleId, String revision) {
|
||||
this(moduleId, revision, null);
|
||||
}
|
||||
public ModuleRevisionId(ModuleId moduleId, String revision, Map extraAttributes) {
|
||||
super(null, extraAttributes);
|
||||
_moduleId = moduleId;
|
||||
_revision = revision;
|
||||
_hash = _hashCode(); //stored for performance reasons, hashCode is very used in many maps
|
||||
setStandardAttribute(IvyPatternHelper.ORGANISATION_KEY, _moduleId.getOrganisation());
|
||||
setStandardAttribute(IvyPatternHelper.MODULE_KEY, _moduleId.getName());
|
||||
setStandardAttribute(IvyPatternHelper.REVISION_KEY, _revision);
|
||||
}
|
||||
|
||||
public ModuleId getModuleId() {
|
||||
return _moduleId;
|
||||
}
|
||||
|
|
@ -46,7 +63,8 @@ public class ModuleRevisionId {
|
|||
}
|
||||
ModuleRevisionId other = (ModuleRevisionId)obj;
|
||||
return (other.getRevision() == null ? getRevision() == null : other.getRevision().equals(getRevision()))
|
||||
&& other.getModuleId().equals(getModuleId());
|
||||
&& other.getModuleId().equals(getModuleId())
|
||||
&& other.getExtraAttributes().equals(getExtraAttributes());
|
||||
}
|
||||
public int hashCode() {
|
||||
return _hash;
|
||||
|
|
@ -55,6 +73,7 @@ public class ModuleRevisionId {
|
|||
int hash = 31;
|
||||
hash = hash * 13 + (getRevision() == null ? 0 : getRevision().hashCode());
|
||||
hash = hash * 13 + getModuleId().hashCode();
|
||||
hash = hash * 13 + getAttributes().hashCode();
|
||||
return hash;
|
||||
}
|
||||
|
||||
|
|
@ -98,21 +117,37 @@ public class ModuleRevisionId {
|
|||
return !revision.startsWith("latest.") && !revision.endsWith("+");
|
||||
}
|
||||
public String encodeToString() {
|
||||
String revision = getRevision();
|
||||
if ((revision == null) || (revision.length() == 0)) {
|
||||
revision = NO_REVISION;
|
||||
StringBuffer buf = new StringBuffer();
|
||||
Map attributes = getAttributes();
|
||||
for (Iterator iter = attributes.keySet().iterator(); iter.hasNext();) {
|
||||
String attName = (String)iter.next();
|
||||
buf.append(attName).append(ENCODE_SEPARATOR).append(attributes.get(attName)).append(ENCODE_SEPARATOR);
|
||||
}
|
||||
return getOrganisation() + ENCODE_SEPARATOR + getName()+ ENCODE_SEPARATOR + revision;
|
||||
return buf.toString();
|
||||
}
|
||||
public static ModuleRevisionId decode(String encoded) {
|
||||
String[] parts = encoded.split(ENCODE_SEPARATOR);
|
||||
if (parts.length != 3) {
|
||||
if (parts.length % 2 != 0) {
|
||||
throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"'");
|
||||
}
|
||||
String revision = parts[2];
|
||||
if (NO_REVISION.equals(revision)) {
|
||||
revision = "";
|
||||
Map attributes = new HashMap();
|
||||
for (int i = 0; i < parts.length; i+=2) {
|
||||
String attName = parts[i];
|
||||
String attValue = parts[i+1];
|
||||
attributes.put(attName, attValue);
|
||||
}
|
||||
return newInstance(parts[0], parts[1], revision);
|
||||
String org = (String)attributes.remove(IvyPatternHelper.ORGANISATION_KEY);
|
||||
String mod = (String)attributes.remove(IvyPatternHelper.MODULE_KEY);
|
||||
String rev = (String)attributes.remove(IvyPatternHelper.REVISION_KEY);
|
||||
if (org == null) {
|
||||
throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': no organisation");
|
||||
}
|
||||
if (mod == null) {
|
||||
throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': no module name");
|
||||
}
|
||||
if (rev == null) {
|
||||
throw new IllegalArgumentException("badly encoded module revision id: '"+encoded+"': no revision");
|
||||
}
|
||||
return newInstance(org, mod, rev, attributes);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.extendable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* An item which is meant to be extended, i.e. defined using extra attributes
|
||||
*/
|
||||
public class DefaultExtendableItem extends UnmodifiableExtendableItem {
|
||||
public DefaultExtendableItem() {
|
||||
this(null, null);
|
||||
}
|
||||
public DefaultExtendableItem(Map stdAttributes, Map extraAttributes) {
|
||||
super(stdAttributes, extraAttributes);
|
||||
}
|
||||
public void setExtraAttribute(String attName, String attValue) {
|
||||
super.setExtraAttribute(attName, attValue);
|
||||
}
|
||||
public void setStandardAttribute(String attName, String attValue) {
|
||||
super.setStandardAttribute(attName, attValue);
|
||||
}
|
||||
public void setAttribute(String attName, String attValue, boolean extra) {
|
||||
super.setAttribute(attName, attValue, extra);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.extendable;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface ExtendableItem {
|
||||
/**
|
||||
* Gets the value of an attribute
|
||||
* Can be used to access the value of a standard attribute (like organisation, revision) or of an extra attribute.
|
||||
* @param attName the name of the attribute to get
|
||||
* @return the value of the attribute, null if the attribute doesn't exist
|
||||
*/
|
||||
String getAttribute(String attName);
|
||||
/**
|
||||
* Gets the value of a standard attribute
|
||||
* Can be used only to access the value of a standard attribute (like organisation, revision), not an extra one
|
||||
* @param attName the name of the standard attribute to get
|
||||
* @return the value of the attribute, null if the attribute doesn't exist
|
||||
*/
|
||||
String getStandardAttribute(String attName);
|
||||
/**
|
||||
* Gets the value of an extra attribute
|
||||
* Can be used only to access the value of an extra attribute, not a standard one (like organisation, revision)
|
||||
* @param attName the name of the extra attribute to get
|
||||
* @return the value of the attribute, null if the attribute doesn't exist
|
||||
*/
|
||||
String getExtraAttribute(String attName);
|
||||
|
||||
/**
|
||||
* Returns a Map of all attributes of this extendable item, including standard and extra ones.
|
||||
* The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)
|
||||
* @return
|
||||
*/
|
||||
Map getAttributes();
|
||||
/**
|
||||
* Returns a Map of all standard attributes of this extendable item.
|
||||
* The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)
|
||||
* @return
|
||||
*/
|
||||
Map getStandardAttributes();
|
||||
/**
|
||||
* Returns a Map of all extra attributes of this extendable item.
|
||||
* The Map keys are attribute names as Strings, and values are corresponding attribute values (as String too)
|
||||
* @return
|
||||
*/
|
||||
Map getExtraAttributes();
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.extendable;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
import org.xml.sax.Attributes;
|
||||
|
||||
|
||||
public class ExtendableItemHelper {
|
||||
|
||||
public static Map getExtraAttributes(Attributes attributes, String[] ignoredAttNames) {
|
||||
Map ret = new HashMap();
|
||||
Collection ignored = Arrays.asList(ignoredAttNames);
|
||||
for (int i=0; i<attributes.getLength(); i++) {
|
||||
if (!ignored.contains(attributes.getQName(i))) {
|
||||
ret.put(attributes.getQName(i), attributes.getValue(i));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static void fillExtraAttributes(DefaultExtendableItem item, Attributes attributes, String[] ignoredAttNames) {
|
||||
Map att = getExtraAttributes(attributes, ignoredAttNames);
|
||||
for (Iterator iter = att.keySet().iterator(); iter.hasNext();) {
|
||||
String attName = (String)iter.next();
|
||||
String attValue = (String)att.get(attName);
|
||||
item.setExtraAttribute(attName, attValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* This file is subject to the licence found in LICENCE.TXT in the root directory of the project.
|
||||
* Copyright Jayasoft 2005 - All rights reserved
|
||||
*
|
||||
* #SNAPSHOT#
|
||||
*/
|
||||
package fr.jayasoft.ivy.extendable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class UnmodifiableExtendableItem implements ExtendableItem {
|
||||
private Map _attributes = new HashMap();
|
||||
private Map _unmodifiableAttributesView = Collections.unmodifiableMap(_attributes);
|
||||
private Map _stdAttributes = new HashMap();
|
||||
private Map _unmodifiableStdAttributesView = Collections.unmodifiableMap(_stdAttributes);
|
||||
private Map _extraAttributes = new HashMap();
|
||||
private Map _unmodifiableExtraAttributesView = Collections.unmodifiableMap(_extraAttributes);
|
||||
|
||||
public UnmodifiableExtendableItem(Map stdAttributes, Map extraAttributes) {
|
||||
if (stdAttributes != null) {
|
||||
_attributes.putAll(stdAttributes);
|
||||
_stdAttributes.putAll(stdAttributes);
|
||||
}
|
||||
if (extraAttributes != null) {
|
||||
_attributes.putAll(extraAttributes);
|
||||
_extraAttributes.putAll(extraAttributes);
|
||||
}
|
||||
}
|
||||
public String getAttribute(String attName) {
|
||||
return (String)_attributes.get(attName);
|
||||
}
|
||||
public String getExtraAttribute(String attName) {
|
||||
return (String)_extraAttributes.get(attName);
|
||||
}
|
||||
public String getStandardAttribute(String attName) {
|
||||
return (String)_stdAttributes.get(attName);
|
||||
}
|
||||
protected void setExtraAttribute(String attName, String attValue) {
|
||||
setAttribute(attName, attValue, true);
|
||||
}
|
||||
protected void setStandardAttribute(String attName, String attValue) {
|
||||
setAttribute(attName, attValue, false);
|
||||
}
|
||||
protected void setAttribute(String attName, String attValue, boolean extra) {
|
||||
if (extra) {
|
||||
_extraAttributes.put(attName, attValue);
|
||||
} else {
|
||||
_stdAttributes.put(attName, attValue);
|
||||
}
|
||||
_attributes.put(attName, attValue);
|
||||
}
|
||||
public Map getAttributes() {
|
||||
return _unmodifiableAttributesView;
|
||||
}
|
||||
public Map getStandardAttributes() {
|
||||
return _unmodifiableStdAttributesView;
|
||||
}
|
||||
public Map getExtraAttributes() {
|
||||
return _unmodifiableExtraAttributesView;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -41,7 +41,7 @@ public class MRIDTransformationRule implements NamespaceTransformer {
|
|||
String mod = applyRules(dest.getModule(), "m");
|
||||
String rev = applyRules(dest.getRev(), "r");
|
||||
|
||||
return ModuleRevisionId.newInstance(org, mod, rev);
|
||||
return ModuleRevisionId.newInstance(org, mod, rev, mrid.getExtraAttributes());
|
||||
}
|
||||
private String applyRules(String str, String type) {
|
||||
for (int i = 0; i < TYPES.length; i++) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ public class NameSpaceHelper {
|
|||
if (artifact.getModuleRevisionId().equals(mrid)) {
|
||||
return artifact;
|
||||
}
|
||||
return new DefaultArtifact(mrid, artifact.getPublicationDate(), artifact.getName(), artifact.getType(), artifact.getExt());
|
||||
return new DefaultArtifact(mrid, artifact.getPublicationDate(), artifact.getName(), artifact.getType(), artifact.getExt(), artifact.getExtraAttributes());
|
||||
}
|
||||
|
||||
public static ArtifactId transform(ArtifactId artifactId, NamespaceTransformer t) {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,13 @@ import fr.jayasoft.ivy.util.Message;
|
|||
*/
|
||||
public abstract class AbstractResourceResolver extends BasicResolver {
|
||||
|
||||
private static final Map IVY_ARTIFACT_ATTRIBUTES = new HashMap();
|
||||
static {
|
||||
IVY_ARTIFACT_ATTRIBUTES.put(IvyPatternHelper.ARTIFACT_KEY, "ivy");
|
||||
IVY_ARTIFACT_ATTRIBUTES.put(IvyPatternHelper.TYPE_KEY, "ivy");
|
||||
IVY_ARTIFACT_ATTRIBUTES.put(IvyPatternHelper.EXT_KEY, "xml");
|
||||
}
|
||||
|
||||
private List _ivyPatterns = new ArrayList(); // List (String pattern)
|
||||
private List _artifactPatterns = new ArrayList(); // List (String pattern)
|
||||
private boolean _m2compatible = false;
|
||||
|
|
@ -47,11 +54,7 @@ public abstract class AbstractResourceResolver extends BasicResolver {
|
|||
if (isM2compatible()) {
|
||||
mrid = convertM2IdForResourceSearch(mrid);
|
||||
}
|
||||
ResolvedResource rres = findResourceUsingPatterns(mrid, _ivyPatterns, "ivy", "ivy", "xml", data.getDate());
|
||||
// if (rres == null && isM2compatible()) {
|
||||
// rres = findResourceUsingPatterns(mrid, _ivyPatterns, mrid.getName(), "pom", "pom", data.getDate());
|
||||
// }
|
||||
return rres;
|
||||
return findResourceUsingPatterns(mrid, _ivyPatterns, DefaultArtifact.newIvyArtifact(mrid, data.getDate()), data.getDate());
|
||||
}
|
||||
|
||||
protected ResolvedResource findArtifactRef(Artifact artifact, Date date) {
|
||||
|
|
@ -59,9 +62,13 @@ public abstract class AbstractResourceResolver extends BasicResolver {
|
|||
if (isM2compatible()) {
|
||||
mrid = convertM2IdForResourceSearch(mrid);
|
||||
}
|
||||
return findResourceUsingPatterns(mrid, _artifactPatterns, artifact.getName(), artifact.getType(), artifact.getExt(), date);
|
||||
return findResourceUsingPatterns(mrid, _artifactPatterns, artifact, date);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
* @return
|
||||
*/
|
||||
protected ResolvedResource findResourceUsingPatterns(ModuleRevisionId moduleRevision, List patternList, String artifact, String type, String ext, Date date) {
|
||||
ResolvedResource rres = null;
|
||||
for (Iterator iter = patternList.iterator(); iter.hasNext() && rres == null;) {
|
||||
|
|
@ -71,8 +78,51 @@ public abstract class AbstractResourceResolver extends BasicResolver {
|
|||
return rres;
|
||||
}
|
||||
|
||||
protected abstract ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid, String pattern, String artifact, String type, String ext, Date date);
|
||||
protected abstract ResolvedResource[] findAll(ModuleRevisionId mrid, String pattern, String artifact, String type, String ext);
|
||||
protected ResolvedResource findResourceUsingPatterns(ModuleRevisionId moduleRevision, List patternList, Artifact artifact, Date date) {
|
||||
ResolvedResource rres = null;
|
||||
for (Iterator iter = patternList.iterator(); iter.hasNext() && rres == null;) {
|
||||
String pattern = (String)iter.next();
|
||||
rres = findResourceUsingPattern(moduleRevision, pattern, artifact, date);
|
||||
}
|
||||
return rres;
|
||||
}
|
||||
|
||||
/**
|
||||
* No need to implement that in post 1.4 dependency resolvers.
|
||||
* @deprecated
|
||||
* @return
|
||||
*/
|
||||
protected ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid, String pattern, String artifact, String type, String ext, Date date) {
|
||||
// implemented for backward compatibility reason only.
|
||||
// in post 1.4 dependency resolvers this has no utility except to let old code use this old method
|
||||
// WARNING: if none of the two methods is overriden, this will result in a StackOverflow error !
|
||||
return findResourceUsingPattern(mrid, pattern, new DefaultArtifact(mrid, date, artifact, type, ext), date);
|
||||
}
|
||||
|
||||
protected ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid, String pattern, Artifact artifact, Date date) {
|
||||
// implemented for backward compatibility reason only.
|
||||
// MUST be overriden in post 1.4 dependency resolvers
|
||||
return findResourceUsingPattern(mrid, pattern, artifact.getName(), artifact.getType(), artifact.getExt(), date);
|
||||
}
|
||||
|
||||
/**
|
||||
* No need to implement that in post 1.4 dependency resolvers.
|
||||
* @deprecated
|
||||
* @return
|
||||
*/
|
||||
protected ResolvedResource[] findAll(ModuleRevisionId mrid, String pattern, String artifact, String type, String ext) {
|
||||
// implemented for backward compatibility reason only.
|
||||
// in post 1.4 dependency resolvers this has no utility except to let old code use this old method
|
||||
// WARNING: if none of the two methods is overriden, this will result in a StackOverflow error !
|
||||
return findAll(mrid, pattern, new DefaultArtifact(mrid, null, artifact, type, ext));
|
||||
}
|
||||
|
||||
protected ResolvedResource[] findAll(ModuleRevisionId mrid, String pattern, Artifact artifact) {
|
||||
// implemented for backward compatibility reason only.
|
||||
// MUST be overriden in post 1.4 dependency resolvers
|
||||
return findAll(mrid, pattern, artifact.getName(), artifact.getType(), artifact.getExt());
|
||||
}
|
||||
|
||||
protected abstract long get(Resource resource, File dest) throws IOException;
|
||||
|
||||
/**
|
||||
|
|
@ -82,9 +132,9 @@ public abstract class AbstractResourceResolver extends BasicResolver {
|
|||
* @param artifact the artifact which has not been found
|
||||
*/
|
||||
protected void logIvyNotFound(ModuleRevisionId mrid) {
|
||||
Artifact artifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
|
||||
Artifact artifact = new DefaultArtifact(mrid, null, "ivy", "ivy", "xml");
|
||||
String revisionToken = mrid.getRevision().startsWith("latest.")?"[any "+mrid.getRevision().substring("latest.".length())+"]":"["+mrid.getRevision()+"]";
|
||||
Artifact latestArtifact = new DefaultArtifact(new ModuleRevisionId(mrid.getModuleId(), revisionToken), new Date(), "ivy", "ivy", "xml");
|
||||
Artifact latestArtifact = new DefaultArtifact(new ModuleRevisionId(mrid.getModuleId(), revisionToken, mrid.getExtraAttributes()), new Date(), "ivy", "ivy", "xml");
|
||||
if (_ivyPatterns.isEmpty()) {
|
||||
logIvyAttempt("no ivy pattern => no attempt to find ivy file for "+mrid);
|
||||
} else {
|
||||
|
|
@ -213,7 +263,7 @@ public abstract class AbstractResourceResolver extends BasicResolver {
|
|||
if (mrid.getOrganisation().indexOf('.') == -1) {
|
||||
return mrid;
|
||||
}
|
||||
return ModuleRevisionId.newInstance(mrid.getOrganisation().replace('.', '/'), mrid.getName(), mrid.getRevision());
|
||||
return ModuleRevisionId.newInstance(mrid.getOrganisation().replace('.', '/'), mrid.getName(), mrid.getRevision(), mrid.getExtraAttributes());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public abstract class AbstractURLResolver extends AbstractResolver {
|
|||
Message.verbose("\t"+getName()+": no ivy file found for "+mrid+": using default data");
|
||||
logIvyNotFound(mrid);
|
||||
if (!mrid.isExactRevision()) {
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), artifactURL.getRevision()));
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), artifactURL.getRevision(), mrid.getExtraAttributes()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -160,7 +160,7 @@ public abstract class AbstractURLResolver extends AbstractResolver {
|
|||
Message.verbose("\t\t=> "+ivyURL);
|
||||
// first check if this dependency has not yet been resolved
|
||||
if (!mrid.isExactRevision()) {
|
||||
ModuleRevisionId resolvedMrid = new ModuleRevisionId(mrid.getModuleId(), ivyURL.getRevision());
|
||||
ModuleRevisionId resolvedMrid = new ModuleRevisionId(mrid.getModuleId(), ivyURL.getRevision(), mrid.getExtraAttributes());
|
||||
IvyNode node = data.getNode(resolvedMrid);
|
||||
if (node != null) {
|
||||
// this revision has already be resolved : return it
|
||||
|
|
@ -224,9 +224,9 @@ public abstract class AbstractURLResolver extends AbstractResolver {
|
|||
resolvedMrid = md.getResolvedModuleRevisionId();
|
||||
if (resolvedMrid.getRevision() == null || resolvedMrid.getRevision().length() == 0) {
|
||||
if (ivyURL.getRevision() == null || ivyURL.getRevision().length() == 0) {
|
||||
resolvedMrid = new ModuleRevisionId(resolvedMrid.getModuleId(), (_envDependent?"##":"")+DATE_FORMAT.format(data.getDate())+"@"+_workspaceName);
|
||||
resolvedMrid = new ModuleRevisionId(resolvedMrid.getModuleId(), (_envDependent?"##":"")+DATE_FORMAT.format(data.getDate())+"@"+_workspaceName, mrid.getExtraAttributes());
|
||||
} else {
|
||||
resolvedMrid = new ModuleRevisionId(resolvedMrid.getModuleId(), ivyURL.getRevision());
|
||||
resolvedMrid = new ModuleRevisionId(resolvedMrid.getModuleId(), ivyURL.getRevision(), mrid.getExtraAttributes());
|
||||
}
|
||||
}
|
||||
Message.verbose("\t\t["+resolvedMrid.getRevision()+"] "+mrid.getModuleId());
|
||||
|
|
@ -419,9 +419,9 @@ public abstract class AbstractURLResolver extends AbstractResolver {
|
|||
* @param artifact the artifact which has not been found
|
||||
*/
|
||||
protected void logIvyNotFound(ModuleRevisionId mrid) {
|
||||
Artifact artifact = new DefaultArtifact(mrid, new Date(), "ivy", "ivy", "xml");
|
||||
Artifact artifact = DefaultArtifact.newIvyArtifact(mrid, null);
|
||||
String revisionToken = mrid.getRevision().startsWith("latest.")?"[any "+mrid.getRevision().substring("latest.".length())+"]":"["+mrid.getRevision()+"]";
|
||||
Artifact latestArtifact = new DefaultArtifact(new ModuleRevisionId(mrid.getModuleId(), revisionToken), new Date(), "ivy", "ivy", "xml");
|
||||
Artifact latestArtifact = DefaultArtifact.newIvyArtifact(new ModuleRevisionId(mrid.getModuleId(), revisionToken, mrid.getExtraAttributes()), null);
|
||||
for (Iterator iter = _ivyPatterns.iterator(); iter.hasNext();) {
|
||||
String pattern = (String)iter.next();
|
||||
String resolvedFileName = IvyPatternHelper.substitute(pattern, artifact);
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ public abstract class BasicResolver extends AbstractResolver {
|
|||
Message.verbose("\t"+getName()+": no ivy file found for "+mrid+": using default data");
|
||||
logIvyNotFound(mrid);
|
||||
if (!mrid.isExactRevision()) {
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), artifactRef.getRevision()));
|
||||
md.setResolvedModuleRevisionId(new ModuleRevisionId(mrid.getModuleId(), artifactRef.getRevision(), mrid.getExtraAttributes()));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -277,7 +277,7 @@ public abstract class BasicResolver extends AbstractResolver {
|
|||
checkDescriptorConsistency(systemDd.getDependencyRevisionId(), systemMd, ivyRef);
|
||||
} else {
|
||||
if (md instanceof DefaultModuleDescriptor) {
|
||||
((DefaultModuleDescriptor)md).setModuleRevisionId(ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName(), ivyRef.getRevision()));
|
||||
((DefaultModuleDescriptor)md).setModuleRevisionId(ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName(), ivyRef.getRevision(), mrid.getExtraAttributes()));
|
||||
} else {
|
||||
Message.warn("consistency disabled with non default module descriptor... module info can't be updated, so consistency check will be done");
|
||||
checkDescriptorConsistency(mrid, md, ivyRef);
|
||||
|
|
@ -539,7 +539,8 @@ public abstract class BasicResolver extends AbstractResolver {
|
|||
artifacts[i].getPublicationDate(),
|
||||
artifacts[i].getName(),
|
||||
artifacts[i].getType(),
|
||||
artifacts[i].getExt()+".part"));
|
||||
artifacts[i].getExt()+".part",
|
||||
artifacts[i].getExtraAttributes()));
|
||||
adr.setSize(get(artifactRef.getResource(), tmp));
|
||||
if (!tmp.renameTo(archiveFile)) {
|
||||
originFile.delete();
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class CacheResolver extends FileSystemResolver {
|
|||
Message.verbose("\t"+getName()+": found ivy file in cache for "+mrid);
|
||||
Message.verbose("\t\t=> "+ivyRef);
|
||||
|
||||
ModuleRevisionId resolvedMrid = new ModuleRevisionId(mrid.getModuleId(), ivyRef.getRevision());
|
||||
ModuleRevisionId resolvedMrid = new ModuleRevisionId(mrid.getModuleId(), ivyRef.getRevision(), mrid.getExtraAttributes());
|
||||
IvyNode node = data.getNode(resolvedMrid);
|
||||
if (node != null && node.getModuleRevision() != null) {
|
||||
// this revision has already be resolved : return it
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import java.util.Date;
|
|||
import java.util.List;
|
||||
|
||||
import fr.jayasoft.ivy.Artifact;
|
||||
import fr.jayasoft.ivy.DefaultArtifact;
|
||||
import fr.jayasoft.ivy.DependencyDescriptor;
|
||||
import fr.jayasoft.ivy.Ivy;
|
||||
import fr.jayasoft.ivy.ModuleRevisionId;
|
||||
|
|
@ -37,7 +38,7 @@ public class IBiblioResolver extends URLResolver {
|
|||
if (isM2compatible()) {
|
||||
ModuleRevisionId mrid = dd.getDependencyRevisionId();
|
||||
mrid = convertM2IdForResourceSearch(mrid);
|
||||
ResolvedResource rres = findResourceUsingPatterns(mrid, getIvyPatterns(), mrid.getName(), "pom", "pom", data.getDate());
|
||||
ResolvedResource rres = findResourceUsingPatterns(mrid, getIvyPatterns(), DefaultArtifact.newPomArtifact(mrid, data.getDate()), data.getDate());
|
||||
return rres;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
|
||||
import fr.jayasoft.ivy.Artifact;
|
||||
import fr.jayasoft.ivy.DefaultArtifact;
|
||||
import fr.jayasoft.ivy.Ivy;
|
||||
import fr.jayasoft.ivy.LatestStrategy;
|
||||
import fr.jayasoft.ivy.ModuleRevisionId;
|
||||
|
|
@ -54,16 +55,26 @@ public class RepositoryResolver extends AbstractResourceResolver {
|
|||
}
|
||||
|
||||
|
||||
protected ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid, String pattern, String artifact, String type, String ext, Date date) {
|
||||
return findResourceUsingPattern(getName(), getRepository(), getLatestStrategy(), mrid, pattern, artifact, type, ext, date, isAlwaysCheckExactRevision());
|
||||
protected ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid, String pattern, Artifact artifact, Date date) {
|
||||
return findResourceUsingPattern(getName(), getRepository(), getLatestStrategy(), mrid, pattern, artifact, date, isAlwaysCheckExactRevision());
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static ResolvedResource findResourceUsingPattern(String name, Repository repository, LatestStrategy strategy, ModuleRevisionId mrid, String pattern, String artifact, String type, String ext, Date date) {
|
||||
return findResourceUsingPattern(name, repository, strategy, mrid, pattern, artifact, type, ext, date, true);
|
||||
}
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static ResolvedResource findResourceUsingPattern(String name, Repository repository, LatestStrategy strategy, ModuleRevisionId mrid, String pattern, String artifact, String type, String ext, Date date, boolean alwaysCheckExactRevision) {
|
||||
return findResourceUsingPattern(name, repository, strategy, mrid, pattern, new DefaultArtifact(mrid, date, artifact, type, ext), date, alwaysCheckExactRevision);
|
||||
}
|
||||
|
||||
public static ResolvedResource findResourceUsingPattern(String name, Repository repository, LatestStrategy strategy, ModuleRevisionId mrid, String pattern, Artifact artifact, Date date, boolean alwaysCheckExactRevision) {
|
||||
try {
|
||||
if (mrid.isExactRevision() || alwaysCheckExactRevision) {
|
||||
String resourceName = IvyPatternHelper.substitute(pattern, mrid, artifact, type, ext);
|
||||
String resourceName = IvyPatternHelper.substitute(pattern, mrid, artifact);
|
||||
Message.debug("\t trying "+resourceName);
|
||||
Resource res = repository.getResource(resourceName);
|
||||
long start = System.currentTimeMillis();
|
||||
|
|
@ -71,22 +82,29 @@ public class RepositoryResolver extends AbstractResourceResolver {
|
|||
if (reachable) {
|
||||
return new ResolvedResource(res, mrid.getRevision());
|
||||
} else if (!mrid.isExactRevision()) {
|
||||
return findDynamicResourceUsingPattern(name, repository, strategy, mrid, pattern, artifact, type, ext, date);
|
||||
return findDynamicResourceUsingPattern(name, repository, strategy, mrid, pattern, artifact, date);
|
||||
} else {
|
||||
Message.debug("\t"+name+": resource not reachable for "+mrid+": res="+res);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return findDynamicResourceUsingPattern(name, repository, strategy, mrid, pattern, artifact, type, ext, date);
|
||||
return findDynamicResourceUsingPattern(name, repository, strategy, mrid, pattern, artifact, date);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
Message.debug("\t"+name+": unable to get resource for "+mrid+": res="+IvyPatternHelper.substitute(pattern, mrid, artifact, type, ext)+": "+ex.getMessage());
|
||||
Message.debug("\t"+name+": unable to get resource for "+mrid+": res="+IvyPatternHelper.substitute(pattern, mrid, artifact)+": "+ex.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
private static ResolvedResource findDynamicResourceUsingPattern(String name, Repository repository, LatestStrategy strategy, ModuleRevisionId mrid, String pattern, String artifact, String type, String ext, Date date) {
|
||||
ResolvedResource[] rress = ResolverHelper.findAll(repository, mrid, pattern, artifact, type, ext);
|
||||
return findDynamicResourceUsingPattern(name, repository, strategy, mrid, pattern, new DefaultArtifact(mrid, date, artifact, type, ext), date);
|
||||
}
|
||||
|
||||
private static ResolvedResource findDynamicResourceUsingPattern(String name, Repository repository, LatestStrategy strategy, ModuleRevisionId mrid, String pattern, Artifact artifact, Date date) {
|
||||
ResolvedResource[] rress = ResolverHelper.findAll(repository, mrid, pattern, artifact);
|
||||
if (rress == null) {
|
||||
Message.debug("\t"+name+": unable to list resources for "+mrid+": pattern="+pattern);
|
||||
return null;
|
||||
|
|
@ -113,16 +131,9 @@ public class RepositoryResolver extends AbstractResourceResolver {
|
|||
/**
|
||||
* Returns all resolved res matching the given pattern and matching given mrid,
|
||||
* or null if no lister is able to handle the given pattern
|
||||
*
|
||||
* @param mrid
|
||||
* @param pattern
|
||||
* @param artifact
|
||||
* @param type
|
||||
* @param ext
|
||||
* @return
|
||||
*/
|
||||
protected ResolvedResource[] findAll(ModuleRevisionId mrid, String pattern, String artifact, String type, String ext) {
|
||||
return ResolverHelper.findAll(_repository, mrid, pattern, artifact, type, ext);
|
||||
protected ResolvedResource[] findAll(ModuleRevisionId mrid, String pattern, Artifact artifact) {
|
||||
return ResolverHelper.findAll(_repository, mrid, pattern, artifact);
|
||||
}
|
||||
|
||||
protected long get(Resource resource, File ivyTempFile) throws IOException {
|
||||
|
|
@ -146,12 +157,8 @@ public class RepositoryResolver extends AbstractResourceResolver {
|
|||
}
|
||||
|
||||
String dest = IvyPatternHelper.substitute(destPattern,
|
||||
mrid.getOrganisation(),
|
||||
mrid.getName(),
|
||||
mrid.getRevision(),
|
||||
artifact.getName(),
|
||||
artifact.getType(),
|
||||
artifact.getExt());
|
||||
mrid,
|
||||
artifact);
|
||||
|
||||
_repository.put(src, dest, overwrite);
|
||||
Message.info("\tpublished "+artifact.getName()+" to "+dest);
|
||||
|
|
|
|||
|
|
@ -10,11 +10,14 @@ import java.net.MalformedURLException;
|
|||
import java.net.URL;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import fr.jayasoft.ivy.Artifact;
|
||||
import fr.jayasoft.ivy.DefaultArtifact;
|
||||
import fr.jayasoft.ivy.ModuleRevisionId;
|
||||
import fr.jayasoft.ivy.ResolvedURL;
|
||||
import fr.jayasoft.ivy.repository.Repository;
|
||||
|
|
@ -107,9 +110,16 @@ public class ResolverHelper {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static ResolvedResource[] findAll(Repository rep, ModuleRevisionId mrid, String pattern, String artifact, String type, String ext) {
|
||||
return findAll(rep, mrid, pattern, new DefaultArtifact(mrid, new Date(), artifact, type, ext));
|
||||
}
|
||||
|
||||
public static ResolvedResource[] findAll(Repository rep, ModuleRevisionId mrid, String pattern, Artifact artifact) {
|
||||
// substitute all but revision
|
||||
String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, new ModuleRevisionId(mrid.getModuleId(), IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY)), artifact, type, ext);
|
||||
String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, new ModuleRevisionId(mrid.getModuleId(), IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY), mrid.getExtraAttributes()), artifact);
|
||||
Message.debug("\tlisting all in "+partiallyResolvedPattern);
|
||||
|
||||
String[] revs = listTokenValues(rep, partiallyResolvedPattern, IvyPatternHelper.REVISION_KEY);
|
||||
|
|
@ -147,13 +157,6 @@ public class ResolverHelper {
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO: remove this code
|
||||
|
||||
|
||||
|
||||
// lists all the values a token can take in a pattern, as listed by a given url lister
|
||||
public static String[] listTokenValues(URLLister lister, String pattern, String token) {
|
||||
pattern = standardize(pattern);
|
||||
|
|
@ -219,10 +222,39 @@ public class ResolverHelper {
|
|||
return path.replace('\\', '/');
|
||||
}
|
||||
|
||||
public static String[] listAll(URLLister lister, URL root) {
|
||||
try {
|
||||
if (lister.accept(root.toExternalForm())) {
|
||||
Message.debug("\tusing "+lister+" to list all in "+root);
|
||||
List all = lister.listAll(root);
|
||||
Message.debug("\t\tfound "+all.size()+" urls");
|
||||
List names = new ArrayList(all.size());
|
||||
for (Iterator iter = all.iterator(); iter.hasNext();) {
|
||||
URL dir = (URL)iter.next();
|
||||
String path = dir.getPath();
|
||||
if (path.endsWith("/")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
int slashIndex = path.lastIndexOf('/');
|
||||
names.add(path.substring(slashIndex +1));
|
||||
}
|
||||
return (String[])names.toArray(new String[names.size()]);
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
Message.warn("problem while listing directories in "+root+": "+e.getClass()+" "+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static ResolvedURL[] findAll(URLLister lister, ModuleRevisionId mrid, String pattern, String artifact, String type, String ext) {
|
||||
if (lister.accept(pattern)) {
|
||||
// substitute all but revision
|
||||
String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, new ModuleRevisionId(mrid.getModuleId(), IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY)), artifact, type, ext);
|
||||
String partiallyResolvedPattern = IvyPatternHelper.substitute(pattern, new ModuleRevisionId(mrid.getModuleId(), IvyPatternHelper.getTokenString(IvyPatternHelper.REVISION_KEY), mrid.getExtraAttributes()), artifact, type, ext);
|
||||
Message.debug("\tlisting all in "+partiallyResolvedPattern);
|
||||
|
||||
String[] revs = listTokenValues(lister, partiallyResolvedPattern, IvyPatternHelper.REVISION_KEY);
|
||||
|
|
@ -252,30 +284,4 @@ public class ResolverHelper {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String[] listAll(URLLister lister, URL root) {
|
||||
try {
|
||||
if (lister.accept(root.toExternalForm())) {
|
||||
Message.debug("\tusing "+lister+" to list all in "+root);
|
||||
List all = lister.listAll(root);
|
||||
Message.debug("\t\tfound "+all.size()+" urls");
|
||||
List names = new ArrayList(all.size());
|
||||
for (Iterator iter = all.iterator(); iter.hasNext();) {
|
||||
URL dir = (URL)iter.next();
|
||||
String path = dir.getPath();
|
||||
if (path.endsWith("/")) {
|
||||
path = path.substring(0, path.length() - 1);
|
||||
}
|
||||
int slashIndex = path.lastIndexOf('/');
|
||||
names.add(path.substring(slashIndex +1));
|
||||
}
|
||||
return (String[])names.toArray(new String[names.size()]);
|
||||
}
|
||||
return null;
|
||||
} catch (Exception e) {
|
||||
Message.warn("problem while listing directories in "+root+": "+e.getClass()+" "+e.getMessage());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,8 @@
|
|||
package fr.jayasoft.ivy.util;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
|
@ -14,6 +16,7 @@ import java.util.regex.Matcher;
|
|||
import java.util.regex.Pattern;
|
||||
|
||||
import fr.jayasoft.ivy.Artifact;
|
||||
import fr.jayasoft.ivy.DefaultArtifact;
|
||||
import fr.jayasoft.ivy.ModuleRevisionId;
|
||||
|
||||
/**
|
||||
|
|
@ -42,38 +45,50 @@ public class IvyPatternHelper {
|
|||
"ivy",
|
||||
"ivy",
|
||||
"xml",
|
||||
null);
|
||||
null,
|
||||
moduleRevision.getAttributes());
|
||||
}
|
||||
public static String substitute(String pattern, ModuleRevisionId moduleRevision, String artifact, String type, String ext) {
|
||||
return substitute(pattern,
|
||||
moduleRevision.getOrganisation(),
|
||||
moduleRevision.getName(),
|
||||
moduleRevision.getRevision(),
|
||||
artifact,
|
||||
type,
|
||||
ext,
|
||||
moduleRevision,
|
||||
new DefaultArtifact(moduleRevision, null, artifact, type, ext),
|
||||
null);
|
||||
}
|
||||
public static String substitute(String pattern, Artifact artifact) {
|
||||
return substitute(pattern, artifact, null);
|
||||
}
|
||||
public static String substitute(String pattern, Artifact artifact, String conf) {
|
||||
return substitute(pattern, artifact.getModuleRevisionId(), artifact, null);
|
||||
}
|
||||
public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact) {
|
||||
return substitute(pattern, mrid, artifact, null);
|
||||
}
|
||||
public static String substitute(String pattern, ModuleRevisionId mrid, Artifact artifact, String conf) {
|
||||
Map attributes = new HashMap();
|
||||
attributes.putAll(mrid.getAttributes());
|
||||
attributes.putAll(artifact.getAttributes());
|
||||
return substitute(pattern,
|
||||
artifact.getModuleRevisionId().getOrganisation(),
|
||||
artifact.getModuleRevisionId().getName(),
|
||||
artifact.getModuleRevisionId().getRevision(),
|
||||
mrid.getOrganisation(),
|
||||
mrid.getName(),
|
||||
mrid.getRevision(),
|
||||
artifact.getName(),
|
||||
artifact.getType(),
|
||||
artifact.getExt(),
|
||||
conf);
|
||||
conf,
|
||||
attributes);
|
||||
}
|
||||
|
||||
|
||||
public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext) {
|
||||
return substitute(pattern, org, module, revision, artifact, type, ext, null);
|
||||
}
|
||||
|
||||
public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext, String conf) {
|
||||
Map tokens = new HashMap();
|
||||
return substitute(pattern, org, module, revision, artifact, type, ext, conf, null);
|
||||
}
|
||||
|
||||
public static String substitute(String pattern, String org, String module, String revision, String artifact, String type, String ext, String conf, Map extraAttributes) {
|
||||
Map tokens = new HashMap(extraAttributes == null ? Collections.EMPTY_MAP : extraAttributes);
|
||||
tokens.put(ORGANISATION_KEY, org==null?"":org);
|
||||
tokens.put(ORGANISATION_KEY2, org==null?"":org);
|
||||
tokens.put(MODULE_KEY, module==null?"":module);
|
||||
|
|
@ -294,5 +309,4 @@ public class IvyPatternHelper {
|
|||
System.out.println("pattern= "+pattern);
|
||||
System.out.println("resolved= "+substituteVariables(pattern, variables));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,12 @@ import java.io.IOException;
|
|||
import java.net.URL;
|
||||
import java.text.ParseException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
||||
|
|
@ -24,7 +28,6 @@ import fr.jayasoft.ivy.ConflictManager;
|
|||
import fr.jayasoft.ivy.DefaultDependencyArtifactDescriptor;
|
||||
import fr.jayasoft.ivy.DefaultDependencyDescriptor;
|
||||
import fr.jayasoft.ivy.DefaultModuleDescriptor;
|
||||
import fr.jayasoft.ivy.DefaultExtendableItem;
|
||||
import fr.jayasoft.ivy.Ivy;
|
||||
import fr.jayasoft.ivy.License;
|
||||
import fr.jayasoft.ivy.MDArtifact;
|
||||
|
|
@ -33,6 +36,8 @@ import fr.jayasoft.ivy.ModuleId;
|
|||
import fr.jayasoft.ivy.ModuleRevisionId;
|
||||
import fr.jayasoft.ivy.Status;
|
||||
import fr.jayasoft.ivy.conflict.FixedConflictManager;
|
||||
import fr.jayasoft.ivy.extendable.DefaultExtendableItem;
|
||||
import fr.jayasoft.ivy.extendable.ExtendableItemHelper;
|
||||
import fr.jayasoft.ivy.matcher.PatternMatcher;
|
||||
import fr.jayasoft.ivy.namespace.Namespace;
|
||||
import fr.jayasoft.ivy.parser.AbstractModuleDescriptorParser;
|
||||
|
|
@ -178,7 +183,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
String org = _ivy.substitute(attributes.getValue("organisation"));
|
||||
String module = _ivy.substitute(attributes.getValue("module"));
|
||||
String revision = _ivy.substitute(attributes.getValue("revision"));
|
||||
_md.setModuleRevisionId(ModuleRevisionId.newInstance(org, module, revision));
|
||||
_md.setModuleRevisionId(ModuleRevisionId.newInstance(org, module, revision, ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"organisation", "module", "revision", "status", "publication", "namespace", "default"})));
|
||||
|
||||
String namespace = _ivy.substitute(attributes.getValue("namespace"));
|
||||
if (namespace != null) {
|
||||
|
|
@ -205,7 +210,6 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
_md.setPublicationDate(getDefaultPubDate());
|
||||
}
|
||||
|
||||
fillAttributes(_md, attributes);
|
||||
} else if ("license".equals(qName)) {
|
||||
_md.addLicense(new License(_ivy.substitute(attributes.getValue("name")), _ivy.substitute(attributes.getValue("url"))));
|
||||
} else if ("description".equals(qName)) {
|
||||
|
|
@ -237,8 +241,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
// this is a published artifact
|
||||
String ext = _ivy.substitute(attributes.getValue("ext"));
|
||||
ext = ext != null?ext:_ivy.substitute(attributes.getValue("type"));
|
||||
_artifact = new MDArtifact(_md, _ivy.substitute(attributes.getValue("name")), _ivy.substitute(attributes.getValue("type")), ext);
|
||||
fillAttributes(_artifact, attributes);
|
||||
_artifact = new MDArtifact(_md, _ivy.substitute(attributes.getValue("name")), _ivy.substitute(attributes.getValue("type")), ext, ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"ext", "type", "name", "conf"}));
|
||||
String confs = _ivy.substitute(attributes.getValue("conf"));
|
||||
// only add confs if they are specified. if they aren't, endElement will handle this
|
||||
// only if there are no conf defined in sub elements
|
||||
|
|
@ -277,8 +280,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
|
||||
String name = _ivy.substitute(attributes.getValue("name"));
|
||||
String rev = _ivy.substitute(attributes.getValue("rev"));
|
||||
_dd = new DefaultDependencyDescriptor(_md, ModuleRevisionId.newInstance(org, name, rev), force, changing, transitive);
|
||||
fillAttributes(_dd, attributes);
|
||||
_dd = new DefaultDependencyDescriptor(_md, ModuleRevisionId.newInstance(org, name, rev, ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"org", "name", "rev", "force", "transitive", "changing", "conf"})), force, changing, transitive);
|
||||
_md.addDependency(_dd);
|
||||
String confs = _ivy.substitute(attributes.getValue("conf"));
|
||||
if (confs != null && confs.length() > 0) {
|
||||
|
|
@ -298,7 +300,7 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
_ivy.substitute(attributes.getValue("description")),
|
||||
ext==null?null:ext.split(","),
|
||||
transitive);
|
||||
fillAttributes(configuration, attributes);
|
||||
ExtendableItemHelper.fillExtraAttributes(configuration, attributes, new String[] {"name", "visibility", "extends", "transitive", "description"});
|
||||
_md.addConfiguration(configuration);
|
||||
break;
|
||||
case PUB:
|
||||
|
|
@ -481,13 +483,6 @@ public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
|
|||
}
|
||||
|
||||
|
||||
public void fillAttributes(DefaultExtendableItem item, Attributes attributes) {
|
||||
for (int i=0; i<attributes.getLength(); i++) {
|
||||
item.setAttribute(attributes.getQName(i), attributes.getValue(i));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import fr.jayasoft.ivy.DefaultArtifact;
|
|||
import fr.jayasoft.ivy.Ivy;
|
||||
import fr.jayasoft.ivy.ModuleId;
|
||||
import fr.jayasoft.ivy.ModuleRevisionId;
|
||||
import fr.jayasoft.ivy.extendable.ExtendableItemHelper;
|
||||
import fr.jayasoft.ivy.report.XmlReportOutputter;
|
||||
|
||||
public class XmlReportParser {
|
||||
|
|
@ -75,7 +76,7 @@ public class XmlReportParser {
|
|||
_skip = true;
|
||||
} else {
|
||||
_revisionsMap.put(new Integer(_position), _revisionArtifacts);
|
||||
_mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision);
|
||||
_mrid = ModuleRevisionId.newInstance(_organisation, _module, _revision, ExtendableItemHelper.getExtraAttributes(attributes, new String[] {"position", "name", "default", "evicted", "error", "pubdate"}));
|
||||
_mrids.add(_mrid);
|
||||
if (_default) {
|
||||
_defaultMrids.add(_mrid);
|
||||
|
|
|
|||
|
|
@ -2029,6 +2029,20 @@ public class ResolveTest extends TestCase {
|
|||
assertEquals(0, report.getConfigurationReport("j2ee").getArtifactsNumber());
|
||||
}
|
||||
|
||||
public void testExtraAttributes() throws Exception {
|
||||
Ivy ivy = new Ivy();
|
||||
ivy.configure(new File("test/repositories/extra-attributes/ivyconf.xml"));
|
||||
|
||||
ResolveReport report = ivy.resolve(ResolveTest.class.getResource("ivy-extra-att.xml"),
|
||||
null, new String[] {"*"}, _cache, null, false);
|
||||
assertFalse(report.hasError());
|
||||
|
||||
assertTrue(new File(_cache, "jayasoft/mymodule/task1/1854/ivy.xml").exists());
|
||||
assertTrue(new File(_cache, "jayasoft/mymodule/task1/1854/mymodule-windows.jar").exists());
|
||||
assertTrue(new File(_cache, "jayasoft/mymodule/task1/1854/mymodule-linux.jar").exists());
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////
|
||||
// helper methods to ease the tests
|
||||
////////////////////////////////////////////////////////////
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
<ivy-module version="1.0">
|
||||
<info organisation="jayasoft" module="extra-att" revision="1.0"/>
|
||||
<dependencies>
|
||||
<dependency name="mymodule" branch="task1" rev="1854" />
|
||||
</dependencies>
|
||||
</ivy-module>
|
||||
|
|
@ -426,6 +426,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
|
|||
assertNotNull(md);
|
||||
|
||||
assertEquals("infoextravalue", md.getAttribute("infoextra"));
|
||||
assertEquals("infoextravalue", md.getModuleRevisionId().getAttribute("infoextra"));
|
||||
|
||||
assertEquals("confextravalue", md.getConfiguration("default").getAttribute("confextra"));
|
||||
|
||||
|
|
@ -445,6 +446,7 @@ public class XmlModuleDescriptorParserTest extends AbstractModuleDescriptorParse
|
|||
assertEquals("myorg", dd.getDependencyId().getOrganisation());
|
||||
assertEquals("1.0", dd.getDependencyRevisionId().getRevision());
|
||||
assertEquals("depextravalue", dd.getAttribute("depextra"));
|
||||
assertEquals("depextravalue", dd.getDependencyRevisionId().getAttribute("depextra"));
|
||||
}
|
||||
|
||||
public void testImportConfigurations1() throws Exception {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,14 @@
|
|||
<ivyconf>
|
||||
<conf
|
||||
defaultCache="${ivy.conf.dir}/cache"
|
||||
cacheIvyPattern="[organisation]/[module]/[branch]/[revision]/ivy.xml"
|
||||
cacheArtifactPattern="[organisation]/[module]/[branch]/[revision]/[artifact]-[platform].[ext]"
|
||||
defaultResolver="default"
|
||||
/>
|
||||
<resolvers>
|
||||
<filesystem name="default">
|
||||
<ivy pattern="${ivy.conf.dir}/[module]/[branch]/[revision]/ivy.xml" />
|
||||
<artifact pattern="${ivy.conf.dir}/[module]/[branch]/[revision]/[artifact]-[platform].[ext]" />
|
||||
</filesystem>
|
||||
</resolvers>
|
||||
</ivyconf>
|
||||
|
|
@ -0,0 +1,14 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<ivy-module version="1.0">
|
||||
<info
|
||||
organisation="jayasoft"
|
||||
module="mymodule"
|
||||
branch="task1"
|
||||
revision="1854"
|
||||
status="integration">
|
||||
</info>
|
||||
<publications>
|
||||
<artifact name="mymodule" platform="windows" type="jar"/>
|
||||
<artifact name="mymodule" platform="linux" type="jar"/>
|
||||
</publications>
|
||||
</ivy-module>
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
|
|
@ -0,0 +1 @@
|
|||
|
||||
Loading…
Reference in New Issue