Try to make the code more generic about handling descriptor based repository

git-svn-id: https://svn.apache.org/repos/asf/ant/ivy/core/trunk@1056016 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Nicolas Lalevee 2011-01-06 19:18:41 +00:00
parent 3222754b7d
commit 0905dc0045
17 changed files with 699 additions and 758 deletions

View File

@ -65,9 +65,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId mrid, String[] confs,
boolean transitive, boolean changing) {
DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId
.newInstance(mrid.getOrganisation(), mrid.getName() + "-caller", "working"),
"integration", null, true);
DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(
ModuleRevisionId.newInstance(mrid.getOrganisation(), mrid.getName() + "-caller",
"working"), "integration", null, true);
for (int i = 0; i < confs.length; i++) {
moduleDescriptor.addConfiguration(new Configuration(confs[i]));
}
@ -84,8 +84,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
public static DefaultModuleDescriptor newCallerInstance(ModuleRevisionId[] mrid,
boolean transitive, boolean changing) {
DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(ModuleRevisionId
.newInstance("caller", "all-caller", "working"), "integration", null, true);
DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(
ModuleRevisionId.newInstance("caller", "all-caller", "working"), "integration",
null, true);
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
moduleDescriptor.setLastModified(System.currentTimeMillis());
for (int i = 0; i < mrid.length; i++) {
@ -105,9 +106,10 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
if (artifacts != null && artifacts.length > 0) {
for (int i = 0; i < artifacts.length; i++) {
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(
moduleDescriptor, artifacts[i].getName(), artifacts[i].getType(),
artifacts[i].getExt(), artifacts[i].getUrl(), artifacts[i].getExtraAttributes()));
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION,
new MDArtifact(moduleDescriptor, artifacts[i].getName(),
artifacts[i].getType(), artifacts[i].getExt(), artifacts[i].getUrl(),
artifacts[i].getExtraAttributes()));
}
} else {
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor,
@ -122,8 +124,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
DefaultModuleDescriptor moduleDescriptor = new DefaultModuleDescriptor(mrid, "release",
publicationDate, false);
moduleDescriptor.addConfiguration(new Configuration(DEFAULT_CONFIGURATION));
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION, new MDArtifact(moduleDescriptor, mrid
.getName(), "jar", "jar"));
moduleDescriptor.addArtifact(DEFAULT_CONFIGURATION,
new MDArtifact(moduleDescriptor, mrid.getName(), "jar", "jar"));
return moduleDescriptor;
}
@ -153,8 +155,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
for (int i = 0; i < ed.length; ++i) {
ModuleRevisionId mrid = t.transform(ed[i].getParentRevisionId());
ModuleRevisionId resolvedMrid = t.transform(ed[i].getResolvedParentRevisionId());
nmd.inheritedDescriptors.add(new DefaultExtendsDescriptor(mrid, resolvedMrid,
ed[i].getLocation(), ed[i].getExtendsTypes()));
nmd.inheritedDescriptors.add(new DefaultExtendsDescriptor(mrid, resolvedMrid, ed[i]
.getLocation(), ed[i].getExtendsTypes()));
}
DependencyDescriptor[] dd = md.getDependencies();
@ -173,12 +175,12 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
if (md instanceof DefaultModuleDescriptor) {
DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
nmd.conflictManagers = (ModuleRules) dmd.conflictManagers.clone();
nmd.dependencyDescriptorMediators =
(ModuleRules) dmd.dependencyDescriptorMediators.clone();
nmd.dependencyDescriptorMediators = (ModuleRules) dmd.dependencyDescriptorMediators
.clone();
} else {
Message.warn(
"transformed module descriptor is not a default module descriptor: "
+ "impossible to copy conflict manager and version mediation configuration: " + md);
Message.warn("transformed module descriptor is not a default module descriptor: "
+ "impossible to copy conflict manager and version mediation configuration: "
+ md);
}
nmd.licenses.addAll(Arrays.asList(md.getLicenses()));
nmd.homePage = md.getHomePage();
@ -207,15 +209,16 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
private Map artifactsByConf = new HashMap(); // Map (String conf -> Collection(Artifact))
private Collection artifacts = new LinkedHashSet(); // Collection(Artifact)
private Collection artifacts = new LinkedHashSet(); // Collection(Artifact)
// all artifacts could also be found in the artifactsByConf map, but here we can
// preserve the order
private boolean isDefault = false;
private ModuleRules conflictManagers = new ModuleRules();
private ModuleRules dependencyDescriptorMediators = new ModuleRules();
private ModuleRules conflictManagers = new ModuleRules();
private ModuleRules dependencyDescriptorMediators = new ModuleRules();
private List licenses = new ArrayList(); // List(License)
@ -232,16 +235,16 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
private ModuleDescriptorParser parser;
private Resource resource;
private List excludeRules = new ArrayList(); // List(ExcludeRule)
private Artifact metadataArtifact;
private List inheritedDescriptors = new ArrayList(); //List(ExtendsDescriptor)
private Map/*<String,String>*/ extraAttributesNamespaces = new LinkedHashMap();
private List inheritedDescriptors = new ArrayList(); // List(ExtendsDescriptor)
private Map/*<String,String>*/ extraInfo = new HashMap();
private Map/* <String,String> */extraAttributesNamespaces = new LinkedHashMap();
private Map/* <String,String> */extraInfo = new HashMap();
public DefaultModuleDescriptor(ModuleRevisionId id, String status, Date pubDate) {
this(id, status, pubDate, false);
@ -272,15 +275,15 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
this.parser = parser;
resource = res;
}
public Artifact getMetadataArtifact() {
if (metadataArtifact == null) {
metadataArtifact = DefaultArtifact.newIvyArtifact(
resolvedRevId, resolvedPublicationDate);
metadataArtifact = DefaultArtifact.newIvyArtifact(resolvedRevId,
resolvedPublicationDate);
}
return metadataArtifact;
}
public void setModuleArtifact(Artifact moduleArtifact) {
this.metadataArtifact = moduleArtifact;
}
@ -310,7 +313,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
public Date getResolvedPublicationDate() {
return resolvedPublicationDate;
}
public String getRevision() {
return getResolvedModuleRevisionId().getRevision();
}
@ -355,8 +358,9 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
public void addArtifact(String conf, Artifact artifact) {
Configuration c = getConfiguration(conf);
if (c == null) {
throw new IllegalArgumentException("Cannot add artifact '" + artifact.getId().getArtifactId().getShortDescription()
+ "' to configuration '" + conf + "' of module " + revId
throw new IllegalArgumentException("Cannot add artifact '"
+ artifact.getId().getArtifactId().getShortDescription()
+ "' to configuration '" + conf + "' of module " + revId
+ " because this configuration doesn't exist!");
}
if (c instanceof ConfigurationGroup) {
@ -389,8 +393,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public ExtendsDescriptor[] getInheritedDescriptors() {
return (ExtendsDescriptor[]) inheritedDescriptors.toArray(
new ExtendsDescriptor[inheritedDescriptors.size()]);
return (ExtendsDescriptor[]) inheritedDescriptors
.toArray(new ExtendsDescriptor[inheritedDescriptors.size()]);
}
public Configuration[] getConfigurations() {
@ -427,7 +431,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
String attValue = m.group(2);
// this is a conf group, let's search for its members
Map /*<String,Configuration>*/ members = new LinkedHashMap();
Map /* <String,Configuration> */members = new LinkedHashMap();
for (Iterator it = configurations.values().iterator(); it.hasNext();) {
Configuration conf = (Configuration) it.next();
if (attValue.equals(conf.getAttribute(attName))) {
@ -436,19 +440,18 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
return new ConfigurationGroup(confName, members);
}
// let's see if a configuration intersection is requested
String[] confs = confName.split("\\+");
if (confs.length <= 1) {
return null;
}
Map /*<String,Configuration>*/ intersectedConfs = new LinkedHashMap();
Map /* <String,Configuration> */intersectedConfs = new LinkedHashMap();
for (int i = 0; i < confs.length; i++) {
Configuration c = (Configuration) configurations.get(confs[i]);
if (c == null) {
Message.verbose(
"missing configuration '" + confs[i]
+ "' from intersection " + confName + " in " + this);
Message.verbose("missing configuration '" + confs[i] + "' from intersection "
+ confName + " in " + this);
return null;
}
intersectedConfs.put(confs[i], c);
@ -467,7 +470,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
if (c instanceof ConfigurationIntersection) {
ConfigurationIntersection intersection = (ConfigurationIntersection) c;
String[] intersected = intersection.getIntersectedConfigurationNames();
Set/*<Artifact>*/ intersectedArtifacts = new LinkedHashSet();
Set/* <Artifact> */intersectedArtifacts = new LinkedHashSet();
for (int j = 0; j < intersected.length; j++) {
Collection arts = getArtifactsIncludingExtending(intersected[j]);
if (intersectedArtifacts.isEmpty()) {
@ -479,12 +482,12 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
if (artifacts != null) {
intersectedArtifacts.addAll(artifacts);
}
return (Artifact[]) intersectedArtifacts.toArray(
new Artifact[intersectedArtifacts.size()]);
return (Artifact[]) intersectedArtifacts.toArray(new Artifact[intersectedArtifacts
.size()]);
} else if (c instanceof ConfigurationGroup) {
ConfigurationGroup group = (ConfigurationGroup) c;
String[] members = group.getMembersConfigurationNames();
Set/*<Artifact>*/ groupArtifacts = new LinkedHashSet();
Set/* <Artifact> */groupArtifacts = new LinkedHashSet();
for (int i = 0; i < members.length; i++) {
groupArtifacts.addAll(getArtifactsIncludingExtending(members[i]));
}
@ -501,10 +504,10 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
}
private Collection/*<Artifact>*/ getArtifactsIncludingExtending(String conf) {
Collection extendingConfs = Configuration.findConfigurationExtending(
conf, getConfigurations());
Set/*<Artifact>*/ artifacts = new LinkedHashSet();
private Collection/* <Artifact> */getArtifactsIncludingExtending(String conf) {
Collection extendingConfs = Configuration.findConfigurationExtending(conf,
getConfigurations());
Set/* <Artifact> */artifacts = new LinkedHashSet();
Collection arts = (Collection) artifactsByConf.get(conf);
if (arts != null) {
artifacts.addAll(arts);
@ -524,8 +527,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
public DependencyDescriptor[] getDependencies() {
return (DependencyDescriptor[]) dependencies
.toArray(new DependencyDescriptor[dependencies.size()]);
return (DependencyDescriptor[]) dependencies.toArray(new DependencyDescriptor[dependencies
.size()]);
}
public boolean dependsOn(VersionMatcher matcher, ModuleDescriptor md) {
@ -550,6 +553,34 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((revId == null) ? 0 : revId.hashCode());
return result;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
DefaultModuleDescriptor other = (DefaultModuleDescriptor) obj;
if (revId == null) {
if (other.revId != null) {
return false;
}
} else if (!revId.equals(other.revId)) {
return false;
}
return true;
}
public String toString() {
return "module: " + revId + " status=" + status + " publication=" + publicationDate
+ " configurations=" + configurations + " artifacts=" + artifactsByConf
@ -576,13 +607,13 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
public ConflictManager getConflictManager(ModuleId moduleId) {
return (ConflictManager) conflictManagers.getRule(moduleId);
}
public void addDependencyDescriptorMediator(ModuleId moduleId, PatternMatcher matcher,
DependencyDescriptorMediator ddm) {
dependencyDescriptorMediators.defineRule(
new MapMatcher(moduleId.getAttributes(), matcher), ddm);
dependencyDescriptorMediators.defineRule(new MapMatcher(moduleId.getAttributes(), matcher),
ddm);
}
public DependencyDescriptor mediate(DependencyDescriptor dd) {
Object[] mediators = dependencyDescriptorMediators.getRules(dd.getDependencyId());
for (int i = 0; i < mediators.length; i++) {
@ -591,7 +622,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return dd;
}
public ModuleRules/*<DependencyDescriptorMediator>*/ getAllDependencyDescriptorMediators() {
public ModuleRules/* <DependencyDescriptorMediator> */getAllDependencyDescriptorMediators() {
return (ModuleRules) dependencyDescriptorMediators.clone();
}
@ -610,11 +641,11 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
public void setHomePage(String homePage) {
this.homePage = homePage;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@ -646,8 +677,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
}
/**
* Throws an exception if the module descriptor is inconsistent
* For the moment, only extended configurations existence and cycles are checked
* Throws an exception if the module descriptor is inconsistent For the moment, only extended
* configurations existence and cycles are checked
*/
public void check() {
Stack confs = new Stack();
@ -670,8 +701,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
cycle.append(confs.get(index)).append(" => ");
}
cycle.append(confName);
throw new IllegalStateException(
"illegal cycle detected in configuration extension: " + cycle);
throw new IllegalStateException("illegal cycle detected in configuration extension: "
+ cycle);
}
Configuration conf = getConfiguration(confName);
if (conf == null) {
@ -714,8 +745,6 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
return resolvedRevId.getQualifiedExtraAttributes();
}
public ModuleDescriptorParser getParser() {
return parser;
}
@ -738,8 +767,8 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
*/
public boolean doesExclude(String[] moduleConfigurations, ArtifactId artifactId) {
if (namespace != null) {
artifactId = NameSpaceHelper.transform(artifactId, namespace
.getFromSystemTransformer());
artifactId = NameSpaceHelper
.transform(artifactId, namespace.getFromSystemTransformer());
}
ExcludeRule[] rules = getExcludeRules(moduleConfigurations);
for (int i = 0; i < rules.length; i++) {
@ -769,7 +798,7 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
private boolean containsAny(String[] arr1, String[] arr2) {
return new ArrayList(Arrays.asList(arr1)).removeAll(Arrays.asList(arr2));
}
public Map getExtraAttributesNamespaces() {
return extraAttributesNamespaces;
}
@ -778,12 +807,10 @@ public class DefaultModuleDescriptor implements ModuleDescriptor {
extraAttributesNamespaces.put(prefix, namespace);
}
public void addExtraInfo(String infoKey, String value) {
extraInfo.put(infoKey, value);
}
public Map getExtraInfo() {
return extraInfo;
}

View File

@ -37,7 +37,6 @@ import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.id.ArtifactId;
import org.apache.ivy.core.module.id.ModuleId;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.osgi.repo.ExecutionEnvironmentProfile;
import org.apache.ivy.osgi.util.Version;
import org.apache.ivy.osgi.util.VersionRange;
import org.apache.ivy.plugins.matcher.ExactOrRegexpPatternMatcher;
@ -197,7 +196,7 @@ public class BundleInfoAdapter {
return builder.toString();
}
private static DefaultArtifact decodeIvyLocation(String uri) {
private static DefaultArtifact decodeIvyLocation(final String uri) {
String org = null;
String name = null;
String branch = null;
@ -206,24 +205,27 @@ public class BundleInfoAdapter {
String type = null;
String ext = null;
uri = uri.substring(6);
int i = uri.indexOf('/');
String u = uri.substring(6);
int i = u.indexOf('/');
if (i < 0) {
throw new IllegalArgumentException("Expecting an organisation in the ivy uri: " + uri);
}
org = uri.substring(0, i);
uri = uri.substring(i + 1);
org = u.substring(0, i);
u = u.substring(i + 1);
i = uri.indexOf('?');
i = u.indexOf('?');
if (i < 0) {
throw new IllegalArgumentException("Expecting an module name in the ivy uri: " + uri);
}
name = uri.substring(0, i);
uri = uri.substring(i + 1);
name = u.substring(0, i);
u = u.substring(i + 1);
String[] parameters = uri.split("&");
String[] parameters = u.split("&");
for (int j = 0; j < parameters.length; j++) {
String parameter = parameters[j];
if (parameter.length() == 0) {
continue;
}
String[] nameAndValue = parameter.split("=");
if (nameAndValue.length != 2) {
throw new IllegalArgumentException("Malformed query string in the ivy uri: " + uri);

View File

@ -15,7 +15,7 @@
* limitations under the License.
*
*/
package org.apache.ivy.osgi.repo;
package org.apache.ivy.osgi.core;
import java.util.Set;
import java.util.TreeSet;

View File

@ -26,7 +26,6 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.ivy.osgi.repo.ExecutionEnvironmentProfile;
import org.apache.ivy.util.Message;
public class ExecutionEnvironmentProfileProvider {
@ -37,6 +36,20 @@ public class ExecutionEnvironmentProfileProvider {
private Map/* <String, ExecutionEnvironmentProfile> */profileList;
private static final ExecutionEnvironmentProfileProvider INSTANCE;
static {
try {
INSTANCE = new ExecutionEnvironmentProfileProvider();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
public static ExecutionEnvironmentProfileProvider getInstance() {
return INSTANCE;
}
public ExecutionEnvironmentProfileProvider() throws IOException {
profileList = loadDefaultProfileList();
}
@ -76,10 +89,10 @@ public class ExecutionEnvironmentProfileProvider {
}
private static ExecutionEnvironmentProfile loadProfile(Properties props, Map/*
* <String,
* ExecutionEnvironmentProfile
* >
*/profiles,
* <String,
* ExecutionEnvironmentProfile
* >
*/profiles,
String name) {
ExecutionEnvironmentProfile profile = new ExecutionEnvironmentProfile(name);

View File

@ -32,8 +32,8 @@ import org.apache.ivy.core.module.descriptor.DefaultArtifact;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.ArtifactDownloadReport;
import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
import org.apache.ivy.osgi.repo.BundleRepoResolver;
import org.apache.ivy.osgi.repo.RelativeURLRepository;
import org.apache.ivy.osgi.repo.RepoDescriptorBasedResolver;
import org.apache.ivy.plugins.repository.ArtifactResourceResolver;
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.plugins.repository.ResourceDownloader;
@ -43,7 +43,7 @@ import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.util.FileUtil;
import org.xml.sax.SAXException;
public class OBRResolver extends BundleRepoResolver {
public class OBRResolver extends RepoDescriptorBasedResolver {
private String repoXmlURL;

View File

@ -24,8 +24,9 @@ import java.text.ParseException;
import javax.xml.parsers.ParserConfigurationException;
import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
import org.apache.ivy.osgi.obr.filter.RequirementFilterParser;
import org.apache.ivy.osgi.repo.BundleRepo;
import org.apache.ivy.osgi.repo.BundleRepoDescriptor;
import org.apache.ivy.osgi.util.DelegetingHandler;
import org.apache.ivy.osgi.util.Version;
import org.apache.ivy.util.Message;
@ -82,7 +83,8 @@ public class OBRXMLParser {
static final String FALSE = "false";
public static BundleRepo parse(InputStream in) throws ParseException, IOException, SAXException {
public static BundleRepoDescriptor parse(InputStream in) throws ParseException, IOException,
SAXException {
RepositoryHandler handler = new RepositoryHandler();
try {
XMLHelper.parse(in, null, handler, null);
@ -96,7 +98,7 @@ public class OBRXMLParser {
private static class RepositoryHandler extends DelegetingHandler/* <DelegetingHandler<?>> */{
BundleRepo repo;
BundleRepoDescriptor repo;
public RepositoryHandler() {
super(REPOSITORY, null);
@ -104,7 +106,7 @@ public class OBRXMLParser {
}
protected void handleAttributes(Attributes atts) {
repo = new BundleRepo();
repo = new BundleRepoDescriptor(ExecutionEnvironmentProfileProvider.getInstance());
repo.setName(atts.getValue(REPOSITORY_NAME));

View File

@ -1,163 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package org.apache.ivy.osgi.repo;
import java.text.ParseException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import org.apache.ivy.osgi.core.BundleCapability;
import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.osgi.core.ManifestParser;
import org.apache.ivy.osgi.util.Version;
import org.apache.ivy.util.Message;
public class BundleRepo {
private String name;
private Long lastModified;
private final Set/* <BundleInfo> */bundles = new HashSet/* <BundleInfo> */();
private final Map/* <String, Map<String, Set<BundleCapabilityAndLocation>>> */bundleByCapabilities = new HashMap/*
* <
* String
* ,
* Map
* <
* String
* ,
* Set
* <
* BundleCapabilityAndLocation
* >>>
*/();
public BundleRepo() {
// default constructor
}
public BundleRepo(Iterator/* <ManifestAndLocation> */it) {
populate(it);
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setLastModified(Long lastModified) {
this.lastModified = lastModified;
}
public Long getLastModified() {
return lastModified;
}
public void populate(Iterator/* <ManifestAndLocation> */it) {
while (it.hasNext()) {
ManifestAndLocation manifestAndLocation = (ManifestAndLocation) it.next();
try {
BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation
.getManifest());
bundleInfo.setUri(manifestAndLocation.getLocation());
addBundle(bundleInfo);
} catch (ParseException e) {
Message.error("Rejected " + manifestAndLocation.getLocation() + ": "
+ e.getMessage());
}
}
}
public void addBundle(BundleInfo bundleInfo) {
bundles.add(bundleInfo);
populateCapabilities(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(),
bundleInfo.getVersion(), bundleInfo);
Iterator itCapability = bundleInfo.getCapabilities().iterator();
while (itCapability.hasNext()) {
BundleCapability capability = (BundleCapability) itCapability.next();
populateCapabilities(capability.getType(), capability.getName(),
capability.getVersion(), bundleInfo);
}
}
private void populateCapabilities(String type, String n, Version version, BundleInfo bundleInfo) {
Map/* <String, Set<BundleCapabilityAndLocation>> */map = (Map) bundleByCapabilities
.get(type);
if (map == null) {
map = new HashMap/* <String, Set<BundleCapabilityAndLocation>> */();
bundleByCapabilities.put(type, map);
}
Set/* <BundleCapabilityAndLocation> */bundleReferences = (Set) map.get(n);
if (bundleReferences == null) {
bundleReferences = new HashSet/* <BundleCapabilityAndLocation> */();
map.put(n, bundleReferences);
}
if (!bundleReferences.add(new BundleCapabilityAndLocation(type, n, version, bundleInfo))) {
Message.warn("The repo did already contains " + n + "#" + version);
}
}
public Set/* <BundleInfo> */getBundles() {
return bundles;
}
public Map/* <String, Map<String, Set<BundleCapabilityAndLocation>>> */getBundleByCapabilities() {
return bundleByCapabilities;
}
public String toString() {
return bundles.toString();
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((bundles == null) ? 0 : bundles.hashCode());
return result;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof BundleRepo)) {
return false;
}
BundleRepo other = (BundleRepo) obj;
if (bundles == null) {
if (other.bundles != null) {
return false;
}
} else if (!bundles.equals(other.bundles)) {
return false;
}
return true;
}
}

View File

@ -0,0 +1,85 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package org.apache.ivy.osgi.repo;
import java.text.ParseException;
import java.util.Iterator;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.osgi.core.BundleCapability;
import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.osgi.core.BundleInfoAdapter;
import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
import org.apache.ivy.osgi.core.ManifestParser;
import org.apache.ivy.util.Message;
public class BundleRepoDescriptor extends RepoDescriptor {
private String name;
private Long lastModified;
private final ExecutionEnvironmentProfileProvider profileProvider;
public BundleRepoDescriptor(ExecutionEnvironmentProfileProvider profileProvider) {
this.profileProvider = profileProvider;
}
public void setName(String name) {
this.name = name;
}
public String getName() {
return name;
}
public void setLastModified(Long lastModified) {
this.lastModified = lastModified;
}
public Long getLastModified() {
return lastModified;
}
public void populate(Iterator/* <ManifestAndLocation> */it) {
while (it.hasNext()) {
ManifestAndLocation manifestAndLocation = (ManifestAndLocation) it.next();
try {
BundleInfo bundleInfo = ManifestParser.parseManifest(manifestAndLocation
.getManifest());
bundleInfo.setUri(manifestAndLocation.getLocation());
addBundle(bundleInfo);
} catch (ParseException e) {
Message.error("Rejected " + manifestAndLocation.getLocation() + ": "
+ e.getMessage());
}
}
}
public void addBundle(BundleInfo bundleInfo) {
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo,
profileProvider);
add(BundleInfo.BUNDLE_TYPE, bundleInfo.getSymbolicName(), md);
Iterator itCapability = bundleInfo.getCapabilities().iterator();
while (itCapability.hasNext()) {
BundleCapability capability = (BundleCapability) itCapability.next();
add(capability.getType(), capability.getName(), md);
}
}
}

View File

@ -0,0 +1,105 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*
*/
package org.apache.ivy.osgi.repo;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.util.Message;
public class RepoDescriptor {
private final Map/* <String, Map<String, Set<ModuleDescriptor>>> */moduleByCapbilities = new HashMap();
private final Set/* <ModuleDescriptor> */modules = new HashSet();
public Set getModules() {
return modules;
}
public Set/* <ModuleDescriptor> */findModule(String requirement, String value) {
Map/* <String, Set<ModuleDescriptor>> */modules = (Map) moduleByCapbilities
.get(requirement);
if (modules == null) {
return null;
}
return (Set) modules.get(value);
}
public Set/* <String> */getCapabilityValues(String capabilityName) {
Map/* <String, Set<ModuleDescriptor>> */modules = (Map) moduleByCapbilities
.get(capabilityName);
if (modules == null) {
return null;
}
return (Set) modules.keySet();
}
public void add(String type, String value, ModuleDescriptor md) {
modules.add(md);
Map/* <String, Set<ModuleDescriptor>> */map = (Map) moduleByCapbilities.get(type);
if (map == null) {
map = new HashMap/* <String, Set<ModuleDescriptor>> */();
moduleByCapbilities.put(type, map);
}
Set/* <ModuleDescriptor> */bundleReferences = (Set) map.get(value);
if (bundleReferences == null) {
bundleReferences = new HashSet/* <ModuleDescriptor> */();
map.put(value, bundleReferences);
}
if (!bundleReferences.add(md)) {
Message.warn("The repo did already contains " + md);
}
}
public String toString() {
return modules.toString();
}
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((modules == null) ? 0 : modules.hashCode());
return result;
}
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (getClass() != obj.getClass()) {
return false;
}
RepoDescriptor other = (RepoDescriptor) obj;
if (modules == null) {
if (other.modules != null) {
return false;
}
} else if (!modules.equals(other.modules)) {
return false;
}
return true;
}
}

View File

@ -19,7 +19,6 @@ package org.apache.ivy.osgi.repo;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@ -33,40 +32,34 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.IvyContext;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.Configuration;
import org.apache.ivy.core.module.descriptor.DefaultModuleDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
import org.apache.ivy.core.module.descriptor.MDArtifact;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
import org.apache.ivy.core.module.id.ModuleRevisionId;
import org.apache.ivy.core.report.DownloadStatus;
import org.apache.ivy.core.report.MetadataArtifactDownloadReport;
import org.apache.ivy.core.resolve.IvyNode;
import org.apache.ivy.core.resolve.ResolveData;
import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.osgi.core.BundleInfoAdapter;
import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
import org.apache.ivy.osgi.util.Version;
import org.apache.ivy.plugins.conflict.ConflictManager;
import org.apache.ivy.plugins.latest.ArtifactInfo;
import org.apache.ivy.plugins.repository.Repository;
import org.apache.ivy.plugins.repository.Resource;
import org.apache.ivy.plugins.repository.file.FileRepository;
import org.apache.ivy.plugins.resolver.BasicResolver;
import org.apache.ivy.plugins.resolver.util.MDResolvedResource;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.plugins.resolver.util.ResourceMDParser;
import org.apache.ivy.util.Message;
import org.xml.sax.SAXException;
public abstract class BundleRepoResolver extends BasicResolver {
public abstract class RepoDescriptorBasedResolver extends BasicResolver {
private Repository repository = null;
private BundleRepo repoDescriptor = null;
private RepoDescriptor repoDescriptor = null;
private ExecutionEnvironmentProfileProvider profileProvider;
@ -106,7 +99,7 @@ public abstract class BundleRepoResolver extends BasicResolver {
this.repository = repository;
}
protected void setRepoDescriptor(BundleRepo repoDescriptor) {
protected void setRepoDescriptor(RepoDescriptor repoDescriptor) {
this.repoDescriptor = repoDescriptor;
}
@ -123,173 +116,74 @@ public abstract class BundleRepoResolver extends BasicResolver {
return repository;
}
private BundleRepo getRepoDescriptor() {
private RepoDescriptor getRepoDescriptor() {
ensureInit();
return repoDescriptor;
}
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
throws ParseException {
DefaultModuleDescriptor md = getDependencyMD(dd, data);
if (md == null) {
// not found, so let's return the mrid resolved by a previous resolver
return data.getCurrentResolvedModuleRevision();
}
Artifact mdar = new MDArtifact(md, "MANIFEST", "manifest", "MF");
MetadataArtifactDownloadReport mdardr = new MetadataArtifactDownloadReport(mdar);
mdardr.setDownloadStatus(DownloadStatus.SUCCESSFUL);
return new ResolvedModuleRevision(this, this, md, mdardr);
public boolean isCheckconsistency() {
// since a module can fit a requirement with a different id, no not check anything
return false;
}
private DefaultModuleDescriptor getDependencyMD(DependencyDescriptor dd, ResolveData data) {
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
ModuleRevisionId mrid = dd.getDependencyRevisionId();
String osgiAtt = mrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
Map/* <String, Set<BundleCapabilityAndLocation>> */bundleCapabilities = (Map) getRepoDescriptor()
.getBundleByCapabilities().get(osgiAtt);
if (bundleCapabilities == null) {
Message.verbose("\t Not an OSGi dependency: " + mrid);
return null;
}
String id = mrid.getName();
Set/* <BundleCapabilityAndLocation> */bundleReferences = (Set) bundleCapabilities.get(id);
if (bundleReferences == null || bundleReferences.isEmpty()) {
Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiAtt, id);
if (mds == null || mds.isEmpty()) {
Message.verbose("\t " + id + " not found.");
return null;
}
List/* <BundleCandidate> */ret = new ArrayList/* <BundleCandidate> */();
Iterator itBundle = bundleReferences.iterator();
while (itBundle.hasNext()) {
BundleCapabilityAndLocation bundleCapability = (BundleCapabilityAndLocation) itBundle
.next();
BundleInfo bundleInfo = bundleCapability.getBundleInfo();
if (!bundleCapability.getType().equals(BundleInfo.BUNDLE_TYPE)) {
ModuleRevisionId foundMrid = ModuleRevisionId.newInstance("",
bundleInfo.getSymbolicName(), bundleInfo.getVersion().toString(),
BundleInfoAdapter.OSGI_BUNDLE);
if (data.getVisitData(foundMrid) != null) {
ResolvedResource[] ret = new ResolvedResource[mds.size()];
int i = 0;
Iterator itMd = mds.iterator();
while (itMd.hasNext()) {
ModuleDescriptor md = (ModuleDescriptor) itMd.next();
MetadataArtifactDownloadReport report = new MetadataArtifactDownloadReport(null);
report.setDownloadStatus(DownloadStatus.NO);
report.setSearched(true);
ResolvedModuleRevision rmr = new ResolvedModuleRevision(this, this, md, report);
MDResolvedResource mdrr = new MDResolvedResource(null, md.getRevision(), rmr);
if (!BundleInfo.BUNDLE_TYPE.equals(osgiAtt)) {
if (data.getVisitData(md.getModuleRevisionId()) != null) {
// already resolved import, no need to go further
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo,
profileProvider);
md.setPublicationDate(new Date(0));
return md;
return mdrr;
}
}
BundleCandidate candidate = new BundleCandidate();
candidate.bundleInfo = bundleInfo;
candidate.version = bundleCapability.getVersion().toString();
ret.add(candidate);
ret[i++] = mdrr;
}
DefaultModuleDescriptor found = selectResource(ret, mrid, data.getDate());
ResolvedResource found = findResource(ret, getDefaultRMDParser(dd.getDependencyId()), mrid,
data.getDate());
if (found == null) {
Message.debug("\t" + getName() + ": no resource found for " + mrid);
}
return found;
}
private class BundleCandidate implements ArtifactInfo {
BundleInfo bundleInfo;
String version;
public long getLastModified() {
return 0;
}
public String getRevision() {
return version;
}
}
public DefaultModuleDescriptor selectResource(List/* <BundleCandidate> */rress,
public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
ModuleRevisionId mrid, Date date) {
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
List/* <BundleCandidate> */founds = new ArrayList/* <BundleCandidate> */();
List/* <BundleCandidate> */sorted = getLatestStrategy().sort(
(ArtifactInfo[]) rress.toArray(new BundleCandidate[rress.size()]));
List/* <String> */rejected = new ArrayList/* <String> */();
List/* <ModuleRevisionId> */foundBlacklisted = new ArrayList/* <ModuleRevisionId> */();
IvyContext context = IvyContext.getContext();
Iterator itBundle = sorted.iterator();
while (itBundle.hasNext()) {
BundleCandidate rres = (BundleCandidate) itBundle.next();
if (filterNames(new ArrayList/* <String> */(Collections.singleton(rres.getRevision())))
.isEmpty()) {
Message.debug("\t" + getName() + ": filtered by name: " + rres);
continue;
}
if ((date != null && rres.getLastModified() > date.getTime())) {
Message.verbose("\t" + getName() + ": too young: " + rres);
rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
continue;
}
ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
ResolveData data = context.getResolveData();
if (data != null && data.getReport() != null
&& data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
Message.debug("\t" + getName() + ": blacklisted: " + rres);
rejected.add(rres.getRevision() + " (blacklisted)");
foundBlacklisted.add(foundMrid);
continue;
}
if (!versionMatcher.accept(mrid, foundMrid)) {
Message.debug("\t" + getName() + ": rejected by version matcher: " + rres);
rejected.add(rres.getRevision());
continue;
}
if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
throw new IllegalStateException();
} else {
founds.add(rres);
}
}
if (founds.isEmpty() && !rejected.isEmpty()) {
logAttempt(rejected.toString());
}
if (founds.isEmpty() && !foundBlacklisted.isEmpty()) {
// all acceptable versions have been blacklisted, this means that an unsolvable conflict
// has been found
DependencyDescriptor dd = context.getDependencyDescriptor();
IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId());
ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId());
cm.handleAllBlacklistedRevisions(dd, foundBlacklisted);
}
if (founds.isEmpty()) {
return null;
}
BundleCandidate found = (BundleCandidate) founds.get(0);
ResolvedResource found = super.findResource(rress, rmdparser, mrid, date);
String osgiAtt = mrid.getExtraAttribute(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
// for non bundle requirement : log the selected bundle
if (!BundleInfo.BUNDLE_TYPE.equals(osgiAtt)) {
// several candidates with different symbolic name : make an warning about the ambiguity
if (founds.size() != 1) {
if (rress.length != 1) {
// several candidates with different symbolic name ?
Map/* <String, List<BundleCandidate>> */matching = new HashMap/*
* <String,
* List<BundleCandidate
* >>
*/();
Iterator itBundle2 = founds.iterator();
while (itBundle2.hasNext()) {
BundleCandidate c = (BundleCandidate) itBundle2.next();
String name = c.bundleInfo.getSymbolicName();
List/* <BundleCandidate> */list = (List) matching.get(name);
Map/* <String, List<MDResolvedResource>> */matching = new HashMap();
for (int i = 0; i < rress.length; i++) {
String name = ((MDResolvedResource) rress[i]).getResolvedModuleRevision()
.getId().getName();
List/* <MDResolvedResource> */list = (List) matching.get(name);
if (list == null) {
list = new ArrayList/* <BundleCandidate> */();
list = new ArrayList/* <MDResolvedResource> */();
matching.put(name, list);
}
list.add(c);
list.add(rress[i]);
}
if (matching.keySet().size() != 1) {
if (requirementStrategy == RequirementStrategy.first) {
@ -297,12 +191,12 @@ public abstract class BundleRepoResolver extends BasicResolver {
+ mrid.getName() + ";version=" + mrid.getRevision());
Iterator itMatching = matching.entrySet().iterator();
while (itMatching.hasNext()) {
Entry/* <String, List<BundleCandidate>> */entry = (Entry) itMatching
Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
.next();
Message.warn("\t" + entry.getKey());
Iterator itB = ((List) entry.getValue()).iterator();
while (itB.hasNext()) {
BundleCandidate c = (BundleCandidate) itB.next();
MDResolvedResource c = (MDResolvedResource) itB.next();
Message.warn("\t\t" + c.getRevision()
+ (found == c ? " (selected)" : ""));
}
@ -312,12 +206,12 @@ public abstract class BundleRepoResolver extends BasicResolver {
+ mrid.getName() + ";version=" + mrid.getRevision());
Iterator itMatching = matching.entrySet().iterator();
while (itMatching.hasNext()) {
Entry/* <String, List<BundleCandidate>> */entry = (Entry) itMatching
Entry/* <String, List<MDResolvedResource>> */entry = (Entry) itMatching
.next();
Message.error("\t" + entry.getKey());
Iterator itB = ((List) entry.getValue()).iterator();
while (itB.hasNext()) {
BundleCandidate c = (BundleCandidate) itB.next();
MDResolvedResource c = (MDResolvedResource) itB.next();
Message.error("\t\t" + c.getRevision()
+ (found == c ? " (best match)" : ""));
}
@ -327,14 +221,12 @@ public abstract class BundleRepoResolver extends BasicResolver {
}
}
Message.info("'" + osgiAtt + "' requirement " + mrid.getName() + ";version="
+ mrid.getRevision() + " satisfied by " + found.bundleInfo.getSymbolicName()
+ mrid.getRevision() + " satisfied by "
+ ((MDResolvedResource) found).getResolvedModuleRevision().getId().getName()
+ ";" + found.getRevision());
}
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(found.bundleInfo,
profileProvider);
md.setPublicationDate(new Date(found.getLastModified()));
return md;
return found;
}
public ResolvedResource findArtifactRef(Artifact artifact, Date date) {
@ -361,9 +253,8 @@ public abstract class BundleRepoResolver extends BasicResolver {
String osgiAtt = (String) tokenValues.get(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME);
Map/* <String, Set<BundleCapabilityAndLocation>> */bundleCapabilityMap = (Map) getRepoDescriptor()
.getBundleByCapabilities().get(osgiAtt);
if (bundleCapabilityMap == null || bundleCapabilityMap.isEmpty()) {
Set/* <String> */capabilityValues = getRepoDescriptor().getCapabilityValues(osgiAtt);
if (capabilityValues == null || capabilityValues.isEmpty()) {
return Collections.EMPTY_LIST;
}
@ -372,20 +263,18 @@ public abstract class BundleRepoResolver extends BasicResolver {
}
if (IvyPatternHelper.MODULE_KEY.equals(token)) {
return bundleCapabilityMap.keySet();
return capabilityValues;
}
if (IvyPatternHelper.REVISION_KEY.equals(token)) {
String name = (String) tokenValues.get(IvyPatternHelper.MODULE_KEY);
List/* <String> */versions = new ArrayList/* <String> */();
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
.get(name);
if (bundleCapabilities != null) {
Iterator itBundle = bundleCapabilities.iterator();
while (itBundle.hasNext()) {
BundleCapabilityAndLocation bundleCapability = (BundleCapabilityAndLocation) itBundle
.next();
versions.add(bundleCapability.getVersion().toString());
Set/* <ModuleDescriptor> */mds = getRepoDescriptor().findModule(osgiAtt, name);
if (mds != null) {
Iterator itMd = mds.iterator();
while (itMd.hasNext()) {
ModuleDescriptor md = (ModuleDescriptor) itMd.next();
versions.add(md.getRevision());
}
}
return versions;
@ -399,8 +288,8 @@ public abstract class BundleRepoResolver extends BasicResolver {
if (osgiAtt.equals(BundleInfo.PACKAGE_TYPE)) {
return Collections.singletonList(BundleInfoAdapter.CONF_USE_PREFIX + name);
}
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
.get(name);
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
.findModule(osgiAtt, name);
if (bundleCapabilities == null) {
return Collections.EMPTY_LIST;
}
@ -474,9 +363,8 @@ public abstract class BundleRepoResolver extends BasicResolver {
}
values.put(BundleInfoAdapter.EXTRA_ATTRIBUTE_NAME, osgiAtt);
Map/* <String, Set<BundleCapabilityAndLocation>> */bundleCapabilityMap = (Map) getRepoDescriptor()
.getBundleByCapabilities().get(osgiAtt);
if (bundleCapabilityMap == null || bundleCapabilityMap.isEmpty()) {
Set/* <String> */capabilities = getRepoDescriptor().getCapabilityValues(osgiAtt);
if (capabilities == null || capabilities.isEmpty()) {
return Collections.EMPTY_SET;
}
@ -490,9 +378,8 @@ public abstract class BundleRepoResolver extends BasicResolver {
tokenSet.remove(IvyPatternHelper.MODULE_KEY);
String module = (String) criteria.get(IvyPatternHelper.MODULE_KEY);
if (module == null) {
Set/* <String> */names = bundleCapabilityMap.keySet();
Set/* <Map<String, String>> */tokenValues = new HashSet/* <Map<String, String>> */();
Iterator itNames = names.iterator();
Iterator itNames = capabilities.iterator();
while (itNames.hasNext()) {
String name = (String) itNames.next();
Map/* <String, String> */newCriteria = new HashMap/* <String, String> */(criteria);
@ -506,8 +393,8 @@ public abstract class BundleRepoResolver extends BasicResolver {
tokenSet.remove(IvyPatternHelper.REVISION_KEY);
String rev = (String) criteria.get(IvyPatternHelper.REVISION_KEY);
if (rev == null) {
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
.get(module);
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
.findModule(osgiAtt, module);
if (bundleCapabilities == null) {
return Collections.EMPTY_SET;
}
@ -531,8 +418,8 @@ public abstract class BundleRepoResolver extends BasicResolver {
values.put(IvyPatternHelper.CONF_KEY, BundleInfoAdapter.CONF_USE_PREFIX + module);
return Collections./* <Map<String, String>> */singleton(values);
}
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = (Set) bundleCapabilityMap
.get(module);
Set/* <BundleCapabilityAndLocation> */bundleCapabilities = getRepoDescriptor()
.findModule(osgiAtt, module);
if (bundleCapabilities == null) {
return Collections.EMPTY_SET;
}
@ -589,10 +476,4 @@ public abstract class BundleRepoResolver extends BasicResolver {
throw new UnsupportedOperationException();
}
// useless methods that must not be called
public ResolvedResource findIvyFileRef(DependencyDescriptor dd, ResolveData data) {
throw new UnsupportedOperationException();
}
}

View File

@ -114,100 +114,6 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
protected abstract ResolvedResource findResourceUsingPattern(ModuleRevisionId mrid,
String pattern, Artifact artifact, ResourceMDParser rmdparser, Date date);
public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
ModuleRevisionId mrid, Date date) {
String name = getName();
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
ResolvedResource found = null;
List sorted = getLatestStrategy().sort(rress);
List rejected = new ArrayList();
List foundBlacklisted = new ArrayList();
IvyContext context = IvyContext.getContext();
for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
ResolvedResource rres = (ResolvedResource) iter.previous();
// we start by filtering based on information already available,
// even though we don't even know if the resource actually exist.
// But checking for existence is most of the time more costly than checking
// name, blacklisting and first level version matching
if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) {
Message.debug("\t" + name + ": filtered by name: " + rres);
continue;
}
ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
ResolveData data = context.getResolveData();
if (data != null
&& data.getReport() != null
&& data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
Message.debug("\t" + name + ": blacklisted: " + rres);
rejected.add(rres.getRevision() + " (blacklisted)");
foundBlacklisted.add(foundMrid);
continue;
}
if (!versionMatcher.accept(mrid, foundMrid)) {
Message.debug("\t" + name + ": rejected by version matcher: " + rres);
rejected.add(rres.getRevision());
continue;
}
if (!rres.getResource().exists()) {
Message.debug("\t" + name + ": unreachable: " + rres
+ "; res=" + rres.getResource());
rejected.add(rres.getRevision() + " (unreachable)");
continue;
}
if ((date != null && rres.getLastModified() > date.getTime())) {
Message.verbose("\t" + name + ": too young: " + rres);
rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
continue;
}
if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision());
if (r == null) {
Message.debug("\t" + name
+ ": impossible to get module descriptor resource: " + rres);
rejected.add(rres.getRevision() + " (no or bad MD)");
continue;
}
ModuleDescriptor md = ((MDResolvedResource) r).getResolvedModuleRevision()
.getDescriptor();
if (md.isDefault()) {
Message.debug("\t" + name + ": default md rejected by version matcher"
+ "requiring module descriptor: " + rres);
rejected.add(rres.getRevision() + " (MD)");
continue;
} else if (!versionMatcher.accept(mrid, md)) {
Message.debug("\t" + name + ": md rejected by version matcher: " + rres);
rejected.add(rres.getRevision() + " (MD)");
continue;
} else {
found = r;
}
} else {
found = rres;
}
if (found != null) {
break;
}
}
if (found == null && !rejected.isEmpty()) {
logAttempt(rejected.toString());
}
if (found == null && !foundBlacklisted.isEmpty()) {
// all acceptable versions have been blacklisted, this means that an unsolvable conflict
// has been found
DependencyDescriptor dd = context.getDependencyDescriptor();
IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId());
ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId());
cm.handleAllBlacklistedRevisions(dd, foundBlacklisted);
}
return found;
}
protected Collection findNames(Map tokenValues, String token) {
Collection names = new HashSet();
names.addAll(findIvyNames(tokenValues, token));
@ -356,21 +262,6 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
protected abstract boolean exist(String path);
/**
* Filters names before returning them in the findXXXNames or findTokenValues method.
* <p>
* Remember to call the super implementation when overriding this method.
* </p>
*
* @param names
* the list to filter.
* @return the filtered list
*/
protected Collection filterNames(Collection names) {
getSettings().filterIgnore(names);
return names;
}
protected void findTokenValues(Collection names, List patterns, Map tokenValues, String token) {
//to be overridden by subclasses wanting to have listing features
}

View File

@ -58,6 +58,7 @@ import org.apache.ivy.core.resolve.ResolvedModuleRevision;
import org.apache.ivy.core.search.ModuleEntry;
import org.apache.ivy.core.search.OrganisationEntry;
import org.apache.ivy.core.search.RevisionEntry;
import org.apache.ivy.plugins.conflict.ConflictManager;
import org.apache.ivy.plugins.namespace.Namespace;
import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
import org.apache.ivy.plugins.parser.ModuleDescriptorParserRegistry;
@ -72,6 +73,7 @@ import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.util.MDResolvedResource;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
import org.apache.ivy.plugins.resolver.util.ResourceMDParser;
import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.Checks;
import org.apache.ivy.util.ChecksumHelper;
import org.apache.ivy.util.HostUtil;
@ -84,7 +86,7 @@ public abstract class BasicResolver extends AbstractResolver {
public static final String DESCRIPTOR_OPTIONAL = "optional";
public static final String DESCRIPTOR_REQUIRED = "required";
/**
* Exception thrown internally in getDependency to indicate a dependency is unresolved.
* <p>
@ -96,32 +98,33 @@ public abstract class BasicResolver extends AbstractResolver {
private boolean error;
/**
* Dependency has not been resolved.
* This is not an error and won't log any message.
* Dependency has not been resolved. This is not an error and won't log any message.
*/
public UnresolvedDependencyException() {
this("", false);
}
/**
* Dependency has not been resolved.
* This is an error and will log a message.
* Dependency has not been resolved. This is an error and will log a message.
*/
public UnresolvedDependencyException(String message) {
this(message, true);
}
/**
* Dependency has not been resolved.
* The boolean tells if it is an error or not, a message will be logged if non empty.
* Dependency has not been resolved. The boolean tells if it is an error or not, a message
* will be logged if non empty.
*/
public UnresolvedDependencyException(String message, boolean error) {
super(message);
this.error = error;
}
public boolean isError() {
return error;
}
}
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
private String workspaceName;
@ -179,21 +182,21 @@ public abstract class BasicResolver extends AbstractResolver {
return mr;
}
}
if (isForce()) {
dd = dd.clone(ModuleRevisionId.newInstance(
dd.getDependencyRevisionId(), "latest.integration"));
dd = dd.clone(ModuleRevisionId.newInstance(dd.getDependencyRevisionId(),
"latest.integration"));
}
DependencyDescriptor systemDd = dd;
DependencyDescriptor nsDd = fromSystem(dd);
context.setDependencyDescriptor(systemDd);
context.setResolveData(data);
clearIvyAttempts();
clearArtifactAttempts();
ModuleRevisionId systemMrid = systemDd.getDependencyRevisionId();
ModuleRevisionId nsMrid = nsDd.getDependencyRevisionId();
checkRevision(systemMrid);
boolean isDynamic = getAndCheckIsDynamic(systemMrid);
@ -203,27 +206,25 @@ public abstract class BasicResolver extends AbstractResolver {
rmr = findModuleInCache(systemDd, data);
if (rmr != null) {
if (rmr.getDescriptor().isDefault() && rmr.getResolver() != this) {
Message.verbose("\t" + getName() + ": found revision in cache: "
+ systemMrid
+ " (resolved by " + rmr.getResolver().getName()
+ "): but it's a default one, maybe we can find a better one");
Message.verbose("\t" + getName() + ": found revision in cache: " + systemMrid
+ " (resolved by " + rmr.getResolver().getName()
+ "): but it's a default one, maybe we can find a better one");
} else if (isForce() && rmr.getResolver() != this) {
Message.verbose("\t" + getName() + ": found revision in cache: "
+ systemMrid
+ " (resolved by " + rmr.getResolver().getName()
+ "): but we are in force mode, let's try to find one ourself");
Message.verbose("\t" + getName() + ": found revision in cache: " + systemMrid
+ " (resolved by " + rmr.getResolver().getName()
+ "): but we are in force mode, let's try to find one ourself");
} else {
Message.verbose("\t" + getName() + ": revision in cache: " + systemMrid);
return checkLatest(systemDd, checkForcedResolvedModuleRevision(rmr), data);
}
}
if (data.getOptions().isUseCacheOnly()) {
throw new UnresolvedDependencyException(
"\t" + getName() + " (useCacheOnly) : no ivy file found for " + systemMrid, false);
throw new UnresolvedDependencyException("\t" + getName()
+ " (useCacheOnly) : no ivy file found for " + systemMrid, false);
}
checkInterrupted();
ResolvedResource ivyRef = findIvyFileRef(nsDd, data);
checkInterrupted();
@ -232,35 +233,35 @@ public abstract class BasicResolver extends AbstractResolver {
ModuleDescriptor systemMd = null;
if (ivyRef == null) {
if (!isAllownomd()) {
throw new UnresolvedDependencyException(
"\t" + getName() + ": no ivy file found for " + systemMrid, false);
throw new UnresolvedDependencyException("\t" + getName()
+ ": no ivy file found for " + systemMrid, false);
}
nsMd = DefaultModuleDescriptor.newDefaultInstance(nsMrid, nsDd
.getAllDependencyArtifacts());
nsMd = DefaultModuleDescriptor.newDefaultInstance(nsMrid,
nsDd.getAllDependencyArtifacts());
ResolvedResource artifactRef = findFirstArtifactRef(nsMd, nsDd, data);
checkInterrupted();
if (artifactRef == null) {
throw new UnresolvedDependencyException("\t" + getName()
+ ": no ivy file nor artifact found for " + systemMrid, false);
throw new UnresolvedDependencyException("\t" + getName()
+ ": no ivy file nor artifact found for " + systemMrid, false);
} else {
long lastModified = artifactRef.getLastModified();
if (lastModified != 0 && nsMd instanceof DefaultModuleDescriptor) {
((DefaultModuleDescriptor) nsMd).setLastModified(lastModified);
}
Message.verbose("\t" + getName() + ": no ivy file found for " + systemMrid
+ ": using default data");
+ ": using default data");
if (isDynamic) {
nsMd.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(nsMrid,
artifactRef.getRevision()));
}
systemMd = toSystem(nsMd);
MetadataArtifactDownloadReport madr =
new MetadataArtifactDownloadReport(systemMd.getMetadataArtifact());
MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(
systemMd.getMetadataArtifact());
madr.setDownloadStatus(DownloadStatus.NO);
madr.setSearched(true);
rmr = new ResolvedModuleRevision(this, this, systemMd, madr, isForce());
getRepositoryCacheManager().cacheModuleDescriptor(this, artifactRef, toSystem(dd),
systemMd.getAllArtifacts()[0], null, getCacheOptions(data));
getRepositoryCacheManager().cacheModuleDescriptor(this, artifactRef,
toSystem(dd), systemMd.getAllArtifacts()[0], null, getCacheOptions(data));
}
} else {
if (ivyRef instanceof MDResolvedResource) {
@ -272,8 +273,7 @@ public abstract class BasicResolver extends AbstractResolver {
throw new UnresolvedDependencyException();
}
}
if (!rmr.getReport().isDownloaded()
&& rmr.getReport().getLocalFile() != null) {
if (!rmr.getReport().isDownloaded() && rmr.getReport().getLocalFile() != null) {
return checkLatest(systemDd, checkForcedResolvedModuleRevision(rmr), data);
} else {
nsMd = rmr.getDescriptor();
@ -290,15 +290,14 @@ public abstract class BasicResolver extends AbstractResolver {
defaultMd.setModuleRevisionId(revision);
defaultMd.setResolvedModuleRevisionId(revision);
} else {
Message.warn(
"consistency disabled with instance of non DefaultModuleDescriptor..."
+ " module info can't be updated, so consistency check will be done");
Message.warn("consistency disabled with instance of non DefaultModuleDescriptor..."
+ " module info can't be updated, so consistency check will be done");
checkDescriptorConsistency(nsMrid, nsMd, ivyRef);
checkDescriptorConsistency(systemMrid, systemMd, ivyRef);
}
}
rmr = new ResolvedModuleRevision(
this, this, systemMd, toSystem(rmr.getReport()), isForce());
rmr = new ResolvedModuleRevision(this, this, systemMd,
toSystem(rmr.getReport()), isForce());
}
}
@ -306,8 +305,10 @@ public abstract class BasicResolver extends AbstractResolver {
resolveAndCheckPublicationDate(systemDd, systemMd, systemMrid, data);
checkNotConvertedExclusionRule(systemMd, ivyRef, data);
cacheModuleDescriptor(systemMd, systemMrid, ivyRef, rmr);
if (ivyRef == null || ivyRef.getResource() != null) {
cacheModuleDescriptor(systemMd, systemMrid, ivyRef, rmr);
}
return checkLatest(systemDd, checkForcedResolvedModuleRevision(rmr), data);
} catch (UnresolvedDependencyException ex) {
if (ex.getMessage().length() > 0) {
@ -323,17 +324,16 @@ public abstract class BasicResolver extends AbstractResolver {
}
}
protected boolean shouldReturnResolvedModule(
DependencyDescriptor dd, ResolvedModuleRevision mr) {
protected boolean shouldReturnResolvedModule(DependencyDescriptor dd, ResolvedModuleRevision mr) {
// a resolved module revision has already been found by a prior dependency resolver
// let's see if it should be returned and bypass this resolver
ModuleRevisionId mrid = dd.getDependencyRevisionId();
boolean isDynamic = getSettings().getVersionMatcher().isDynamic(mrid);
boolean shouldReturn = mr.isForce();
shouldReturn |= !isDynamic && !mr.getDescriptor().isDefault();
shouldReturn &= !isForce();
return shouldReturn;
}
@ -344,63 +344,54 @@ public abstract class BasicResolver extends AbstractResolver {
if (!isForce() || rmr.isForce()) {
return rmr;
}
return new ResolvedModuleRevision(
rmr.getResolver(), rmr.getArtifactResolver(),
rmr.getDescriptor(), rmr.getReport(), true);
return new ResolvedModuleRevision(rmr.getResolver(), rmr.getArtifactResolver(),
rmr.getDescriptor(), rmr.getReport(), true);
}
private void cacheModuleDescriptor(ModuleDescriptor systemMd, ModuleRevisionId systemMrid,
ResolvedResource ivyRef, ResolvedModuleRevision rmr) {
RepositoryCacheManager cacheManager = getRepositoryCacheManager();
final ModuleDescriptorParser parser = systemMd.getParser();
// the metadata artifact which was used to cache the original metadata file
Artifact requestedMetadataArtifact =
ivyRef == null
? systemMd.getMetadataArtifact()
: parser.getMetadataArtifact(
ModuleRevisionId.newInstance(systemMrid, ivyRef.getRevision()),
ivyRef.getResource());
cacheManager.originalToCachedModuleDescriptor(this, ivyRef, requestedMetadataArtifact,
rmr, new ModuleDescriptorWriter() {
public void write(ResolvedResource originalMdResource, ModuleDescriptor md,
File src, File dest)
throws IOException, ParseException {
if (originalMdResource == null) {
// a basic ivy file is written containing default data
XmlModuleDescriptorWriter.write(md, dest);
} else {
// copy and update ivy file from source to cache
parser.toIvyFile(
new FileInputStream(src),
originalMdResource.getResource(), dest,
md);
long repLastModified = originalMdResource.getLastModified();
if (repLastModified > 0) {
dest.setLastModified(repLastModified);
// the metadata artifact which was used to cache the original metadata file
Artifact requestedMetadataArtifact = ivyRef == null ? systemMd.getMetadataArtifact()
: parser.getMetadataArtifact(
ModuleRevisionId.newInstance(systemMrid, ivyRef.getRevision()),
ivyRef.getResource());
cacheManager.originalToCachedModuleDescriptor(this, ivyRef, requestedMetadataArtifact, rmr,
new ModuleDescriptorWriter() {
public void write(ResolvedResource originalMdResource, ModuleDescriptor md,
File src, File dest) throws IOException, ParseException {
if (originalMdResource == null) {
// a basic ivy file is written containing default data
XmlModuleDescriptorWriter.write(md, dest);
} else {
// copy and update ivy file from source to cache
parser.toIvyFile(new FileInputStream(src),
originalMdResource.getResource(), dest, md);
long repLastModified = originalMdResource.getLastModified();
if (repLastModified > 0) {
dest.setLastModified(repLastModified);
}
}
}
}
});
});
}
private void checkNotConvertedExclusionRule(ModuleDescriptor systemMd, ResolvedResource ivyRef,
ResolveData data) {
if (!getNamespace().equals(Namespace.SYSTEM_NAMESPACE)
&& !systemMd.isDefault()
&& data.getSettings().logNotConvertedExclusionRule()
if (!getNamespace().equals(Namespace.SYSTEM_NAMESPACE) && !systemMd.isDefault()
&& data.getSettings().logNotConvertedExclusionRule()
&& systemMd instanceof DefaultModuleDescriptor) {
DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) systemMd;
if (dmd.isNamespaceUseful()) {
Message.warn(
"the module descriptor "
+ ivyRef.getResource()
+ " has information which can't be converted into "
+ "the system namespace. "
+ "It will require the availability of the namespace '"
+ getNamespace().getName() + "' to be fully usable.");
Message.warn("the module descriptor " + ivyRef.getResource()
+ " has information which can't be converted into "
+ "the system namespace. "
+ "It will require the availability of the namespace '"
+ getNamespace().getName() + "' to be fully usable.");
}
}
}
@ -411,34 +402,33 @@ public abstract class BasicResolver extends AbstractResolver {
if (data.getDate() != null) {
long pubDate = getPublicationDate(systemMd, systemDd, data);
if (pubDate > data.getDate().getTime()) {
throw new UnresolvedDependencyException(
"\t" + getName() + ": unacceptable publication date => was="
+ new Date(pubDate) + " required=" + data.getDate());
throw new UnresolvedDependencyException("\t" + getName()
+ ": unacceptable publication date => was=" + new Date(pubDate)
+ " required=" + data.getDate());
} else if (pubDate == -1) {
throw new UnresolvedDependencyException("\t" + getName()
+ ": impossible to guess publication date: artifact missing for "
+ systemMrid);
+ ": impossible to guess publication date: artifact missing for "
+ systemMrid);
}
systemMd.setResolvedPublicationDate(new Date(pubDate));
systemMd.setResolvedPublicationDate(new Date(pubDate));
}
}
private void checkModuleDescriptorRevision(ModuleDescriptor systemMd,
ModuleRevisionId systemMrid) {
if (!getSettings().getVersionMatcher().accept(systemMrid, systemMd)) {
throw new UnresolvedDependencyException(
"\t" + getName() + ": unacceptable revision => was="
+ systemMd.getResolvedModuleRevisionId().getRevision() + " required="
+ systemMrid.getRevision());
throw new UnresolvedDependencyException("\t" + getName()
+ ": unacceptable revision => was="
+ systemMd.getResolvedModuleRevisionId().getRevision() + " required="
+ systemMrid.getRevision());
}
}
private boolean getAndCheckIsDynamic(ModuleRevisionId systemMrid) {
boolean isDynamic = getSettings().getVersionMatcher().isDynamic(systemMrid);
if (isDynamic && !acceptLatest()) {
throw new UnresolvedDependencyException(
"dynamic revisions not handled by " + getClass().getName()
+ ". impossible to resolve " + systemMrid);
throw new UnresolvedDependencyException("dynamic revisions not handled by "
+ getClass().getName() + ". impossible to resolve " + systemMrid);
}
return isDynamic;
}
@ -446,10 +436,9 @@ public abstract class BasicResolver extends AbstractResolver {
private void checkRevision(ModuleRevisionId systemMrid) {
// check revision
int index = systemMrid.getRevision().indexOf("@");
if (index != -1
&& !systemMrid.getRevision().substring(index + 1).equals(workspaceName)) {
throw new UnresolvedDependencyException("\t" + getName()
+ ": unhandled revision => " + systemMrid.getRevision());
if (index != -1 && !systemMrid.getRevision().substring(index + 1).equals(workspaceName)) {
throw new UnresolvedDependencyException("\t" + getName() + ": unhandled revision => "
+ systemMrid.getRevision());
}
}
@ -458,27 +447,24 @@ public abstract class BasicResolver extends AbstractResolver {
// we get the resolved module revision id from the descriptor: it may contain extra
// attributes that were not included in the dependency constraint
ModuleRevisionId resolvedMrid = systemMd.getResolvedModuleRevisionId();
if (resolvedMrid.getRevision() == null
|| resolvedMrid.getRevision().length() == 0
if (resolvedMrid.getRevision() == null || resolvedMrid.getRevision().length() == 0
|| resolvedMrid.getRevision().startsWith("working@")) {
if (!isDynamic) {
resolvedMrid = ModuleRevisionId.newInstance(
resolvedMrid, dependencyConstraint.getRevision());
resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid,
dependencyConstraint.getRevision());
} else if (ivyRef == null) {
resolvedMrid = systemMd.getMetadataArtifact().getModuleRevisionId();
} else if (ivyRef.getRevision() == null || ivyRef.getRevision().length() == 0) {
resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@"
+ getName());
resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, "working@" + getName());
} else {
resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, ivyRef
.getRevision());
resolvedMrid = ModuleRevisionId.newInstance(resolvedMrid, ivyRef.getRevision());
}
}
if (isDynamic) {
Message.verbose("\t\t[" + toSystem(resolvedMrid).getRevision() + "] "
+ dependencyConstraint.getModuleId());
Message.verbose("\t\t[" + toSystem(resolvedMrid).getRevision() + "] "
+ dependencyConstraint.getModuleId());
}
systemMd.setResolvedModuleRevisionId(resolvedMrid);
systemMd.setResolvedModuleRevisionId(resolvedMrid);
checkModuleDescriptorRevision(systemMd, dependencyConstraint);
}
@ -487,7 +473,7 @@ public abstract class BasicResolver extends AbstractResolver {
Map allAttributes = new HashMap();
allAttributes.putAll(md.getQualifiedExtraAttributes());
allAttributes.putAll(askedMrid.getQualifiedExtraAttributes());
String revision = ivyRef.getRevision();
if (revision == null) {
Message.debug("no revision found in reference for " + askedMrid);
@ -503,9 +489,9 @@ public abstract class BasicResolver extends AbstractResolver {
revision = askedMrid.getRevision();
}
}
return ModuleRevisionId.newInstance(askedMrid.getOrganisation(), askedMrid.getName(),
askedMrid.getBranch(), revision, allAttributes);
askedMrid.getBranch(), revision, allAttributes);
}
public ResolvedModuleRevision parse(final ResolvedResource mdRef, DependencyDescriptor dd,
@ -513,10 +499,10 @@ public abstract class BasicResolver extends AbstractResolver {
DependencyDescriptor nsDd = dd;
dd = toSystem(nsDd);
ModuleRevisionId mrid = dd.getDependencyRevisionId();
ModuleDescriptorParser parser = ModuleDescriptorParserRegistry
.getInstance().getParser(mdRef.getResource());
ModuleDescriptorParser parser = ModuleDescriptorParserRegistry.getInstance().getParser(
mdRef.getResource());
if (parser == null) {
Message.warn("no module descriptor parser available for " + mdRef.getResource());
return null;
@ -547,9 +533,8 @@ public abstract class BasicResolver extends AbstractResolver {
}
Artifact moduleArtifact = parser.getMetadataArtifact(resolvedMrid, mdRef.getResource());
return getRepositoryCacheManager().cacheModuleDescriptor(
this, mdRef, dd, moduleArtifact, downloader,
getCacheOptions(data));
return getRepositoryCacheManager().cacheModuleDescriptor(this, mdRef, dd, moduleArtifact,
downloader, getCacheOptions(data));
}
protected ResourceMDParser getRMDParser(final DependencyDescriptor dd, final ResolveData data) {
@ -564,8 +549,7 @@ public abstract class BasicResolver extends AbstractResolver {
return new MDResolvedResource(resource, rev, rmr);
}
} catch (ParseException e) {
Message.warn("Failed to parse the file '" + resource + "': "
+ e.getMessage());
Message.warn("Failed to parse the file '" + resource + "': " + e.getMessage());
return null;
}
}
@ -576,10 +560,10 @@ public abstract class BasicResolver extends AbstractResolver {
protected ResourceMDParser getDefaultRMDParser(final ModuleId mid) {
return new ResourceMDParser() {
public MDResolvedResource parse(Resource resource, String rev) {
DefaultModuleDescriptor md =
DefaultModuleDescriptor.newDefaultInstance(new ModuleRevisionId(mid, rev));
MetadataArtifactDownloadReport madr =
new MetadataArtifactDownloadReport(md.getMetadataArtifact());
DefaultModuleDescriptor md = DefaultModuleDescriptor
.newDefaultInstance(new ModuleRevisionId(mid, rev));
MetadataArtifactDownloadReport madr = new MetadataArtifactDownloadReport(
md.getMetadataArtifact());
madr.setDownloadStatus(DownloadStatus.NO);
madr.setSearched(true);
return new MDResolvedResource(resource, rev, new ResolvedModuleRevision(
@ -613,7 +597,7 @@ public abstract class BasicResolver extends AbstractResolver {
+ md.getModuleRevisionId().getName() + "'; ");
ok = false;
}
if (mrid.getBranch() != null
if (mrid.getBranch() != null
&& !mrid.getBranch().equals(md.getModuleRevisionId().getBranch())) {
Message.error("\t" + getName() + ": bad branch name found in " + ivyRef.getResource()
+ ": expected='" + mrid.getBranch() + " found='"
@ -642,11 +626,11 @@ public abstract class BasicResolver extends AbstractResolver {
}
for (Iterator it = mrid.getExtraAttributes().entrySet().iterator(); it.hasNext();) {
Entry extra = (Entry) it.next();
if (extra.getValue() != null && !extra.getValue().equals(
md.getExtraAttribute((String) extra.getKey()))) {
if (extra.getValue() != null
&& !extra.getValue().equals(md.getExtraAttribute((String) extra.getKey()))) {
String errorMsg = "bad " + extra.getKey() + " found in " + ivyRef.getResource()
+ ": expected='" + extra.getValue() + "' found='"
+ md.getExtraAttribute((String) extra.getKey()) + "'";
+ ": expected='" + extra.getValue() + "' found='"
+ md.getExtraAttribute((String) extra.getKey()) + "'";
Message.error("\t" + getName() + ": " + errorMsg);
errors.append(errorMsg + ";");
ok = false;
@ -658,6 +642,127 @@ public abstract class BasicResolver extends AbstractResolver {
}
}
/**
* When the resolver has many choices, this function helps choosing one
*
* @param rress
* the list of resolved resource which the resolver found to fit the requirement
* @param rmdparser
* the parser of module descriptor
* @param mrid
* the module being resolved
* @param date
* the current date
* @return the selected resource
*/
public ResolvedResource findResource(ResolvedResource[] rress, ResourceMDParser rmdparser,
ModuleRevisionId mrid, Date date) {
String name = getName();
VersionMatcher versionMatcher = getSettings().getVersionMatcher();
ResolvedResource found = null;
List sorted = getLatestStrategy().sort(rress);
List rejected = new ArrayList();
List foundBlacklisted = new ArrayList();
IvyContext context = IvyContext.getContext();
for (ListIterator iter = sorted.listIterator(sorted.size()); iter.hasPrevious();) {
ResolvedResource rres = (ResolvedResource) iter.previous();
// we start by filtering based on information already available,
// even though we don't even know if the resource actually exist.
// But checking for existence is most of the time more costly than checking
// name, blacklisting and first level version matching
if (filterNames(new ArrayList(Collections.singleton(rres.getRevision()))).isEmpty()) {
Message.debug("\t" + name + ": filtered by name: " + rres);
continue;
}
ModuleRevisionId foundMrid = ModuleRevisionId.newInstance(mrid, rres.getRevision());
ResolveData data = context.getResolveData();
if (data != null && data.getReport() != null
&& data.isBlacklisted(data.getReport().getConfiguration(), foundMrid)) {
Message.debug("\t" + name + ": blacklisted: " + rres);
rejected.add(rres.getRevision() + " (blacklisted)");
foundBlacklisted.add(foundMrid);
continue;
}
if (!versionMatcher.accept(mrid, foundMrid)) {
Message.debug("\t" + name + ": rejected by version matcher: " + rres);
rejected.add(rres.getRevision());
continue;
}
if (rres.getResource() != null && !rres.getResource().exists()) {
Message.debug("\t" + name + ": unreachable: " + rres + "; res="
+ rres.getResource());
rejected.add(rres.getRevision() + " (unreachable)");
continue;
}
if ((date != null && rres.getLastModified() > date.getTime())) {
Message.verbose("\t" + name + ": too young: " + rres);
rejected.add(rres.getRevision() + " (" + rres.getLastModified() + ")");
continue;
}
if (versionMatcher.needModuleDescriptor(mrid, foundMrid)) {
ResolvedResource r = rmdparser.parse(rres.getResource(), rres.getRevision());
if (r == null) {
Message.debug("\t" + name + ": impossible to get module descriptor resource: "
+ rres);
rejected.add(rres.getRevision() + " (no or bad MD)");
continue;
}
ModuleDescriptor md = ((MDResolvedResource) r).getResolvedModuleRevision()
.getDescriptor();
if (md.isDefault()) {
Message.debug("\t" + name + ": default md rejected by version matcher"
+ "requiring module descriptor: " + rres);
rejected.add(rres.getRevision() + " (MD)");
continue;
} else if (!versionMatcher.accept(mrid, md)) {
Message.debug("\t" + name + ": md rejected by version matcher: " + rres);
rejected.add(rres.getRevision() + " (MD)");
continue;
} else {
found = r;
}
} else {
found = rres;
}
if (found != null) {
break;
}
}
if (found == null && !rejected.isEmpty()) {
logAttempt(rejected.toString());
}
if (found == null && !foundBlacklisted.isEmpty()) {
// all acceptable versions have been blacklisted, this means that an unsolvable conflict
// has been found
DependencyDescriptor dd = context.getDependencyDescriptor();
IvyNode parentNode = context.getResolveData().getNode(dd.getParentRevisionId());
ConflictManager cm = parentNode.getConflictManager(mrid.getModuleId());
cm.handleAllBlacklistedRevisions(dd, foundBlacklisted);
}
return found;
}
/**
* Filters names before returning them in the findXXXNames or findTokenValues method.
* <p>
* Remember to call the super implementation when overriding this method.
* </p>
*
* @param names
* the list to filter.
* @return the filtered list
*/
protected Collection filterNames(Collection names) {
getSettings().filterIgnore(names);
return names;
}
protected void clearIvyAttempts() {
ivyattempts.clear();
clearArtifactAttempts();
@ -727,9 +832,8 @@ public abstract class BasicResolver extends AbstractResolver {
clearArtifactAttempts();
DownloadReport dr = new DownloadReport();
for (int i = 0; i < artifacts.length; i++) {
ArtifactDownloadReport adr = cacheManager.download(
artifacts[i], artifactResourceResolver, downloader,
getCacheDownloadOptions(options));
ArtifactDownloadReport adr = cacheManager.download(artifacts[i],
artifactResourceResolver, downloader, getCacheDownloadOptions(options));
if (DownloadStatus.FAILED == adr.getDownloadStatus()) {
if (!ArtifactDownloadReport.MISSING_ARTIFACT.equals(adr.getDownloadDetails())) {
Message.warn("\t" + adr);
@ -750,11 +854,10 @@ public abstract class BasicResolver extends AbstractResolver {
protected void clearArtifactAttempts() {
artattempts.clear();
}
public ArtifactDownloadReport download(final ArtifactOrigin origin, DownloadOptions options) {
Checks.checkNotNull(origin, "origin");
return getRepositoryCacheManager().download(
origin.getArtifact(),
return getRepositoryCacheManager().download(origin.getArtifact(),
new ArtifactResourceResolver() {
public ResolvedResource resolve(Artifact artifact) {
try {
@ -768,11 +871,9 @@ public abstract class BasicResolver extends AbstractResolver {
return null;
}
}
},
downloader,
getCacheDownloadOptions(options));
}, downloader, getCacheDownloadOptions(options));
}
protected abstract Resource getResource(String source) throws IOException;
public boolean exists(Artifact artifact) {
@ -782,24 +883,22 @@ public abstract class BasicResolver extends AbstractResolver {
}
return false;
}
public ArtifactOrigin locate(Artifact artifact) {
ArtifactOrigin origin = getRepositoryCacheManager().getSavedArtifactOrigin(toSystem(artifact));
ArtifactOrigin origin = getRepositoryCacheManager().getSavedArtifactOrigin(
toSystem(artifact));
if (!ArtifactOrigin.isUnknown(origin)) {
return origin;
}
ResolvedResource artifactRef = getArtifactRef(artifact, null);
if (artifactRef != null && artifactRef.getResource().exists()) {
return new ArtifactOrigin(
artifact,
artifactRef.getResource().isLocal(),
artifactRef.getResource().getName());
return new ArtifactOrigin(artifact, artifactRef.getResource().isLocal(), artifactRef
.getResource().getName());
}
return null;
}
protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd,
ResolveData data) {
protected long getPublicationDate(ModuleDescriptor md, DependencyDescriptor dd, ResolveData data) {
if (md.getPublicationDate() != null) {
return md.getPublicationDate().getTime();
}
@ -903,7 +1002,7 @@ public abstract class BasicResolver extends AbstractResolver {
if (!ChecksumHelper.isKnownAlgorithm(algorithm)) {
throw new IllegalArgumentException("Unknown checksum algorithm: " + algorithm);
}
Resource csRes = resource.clone(resource.getName() + "." + algorithm);
if (csRes.exists()) {
Message.debug(algorithm + " file found for " + resource + ": checking...");
@ -940,8 +1039,7 @@ public abstract class BasicResolver extends AbstractResolver {
} else {
resource = new URLResource(url);
}
ret = new ResolvedResource(resource, artifact.getModuleRevisionId()
.getRevision());
ret = new ResolvedResource(resource, artifact.getModuleRevisionId().getRevision());
}
return ret;
} finally {
@ -964,11 +1062,11 @@ public abstract class BasicResolver extends AbstractResolver {
public void setCheckconsistency(boolean checkConsitency) {
checkconsistency = checkConsitency;
}
public void setForce(boolean force) {
this.force = force;
}
public boolean isForce() {
return force;
}
@ -978,28 +1076,27 @@ public abstract class BasicResolver extends AbstractResolver {
}
public void setAllownomd(boolean b) {
Message.deprecated(
"allownomd is deprecated, please use descriptor=\""
+ (b ? DESCRIPTOR_OPTIONAL : DESCRIPTOR_REQUIRED) + "\" instead");
Message.deprecated("allownomd is deprecated, please use descriptor=\""
+ (b ? DESCRIPTOR_OPTIONAL : DESCRIPTOR_REQUIRED) + "\" instead");
allownomd = b;
}
/**
* Sets the module descriptor presence rule.
* Should be one of {@link #DESCRIPTOR_REQUIRED} or {@link #DESCRIPTOR_OPTIONAL}.
*
* @param descriptorRule the descriptor rule to use with this resolver.
* Sets the module descriptor presence rule. Should be one of {@link #DESCRIPTOR_REQUIRED} or
* {@link #DESCRIPTOR_OPTIONAL}.
*
* @param descriptorRule
* the descriptor rule to use with this resolver.
*/
public void setDescriptor(String descriptorRule) {
if (DESCRIPTOR_REQUIRED.equals(descriptorRule)) {
allownomd = false;
allownomd = false;
} else if (DESCRIPTOR_OPTIONAL.equals(descriptorRule)) {
allownomd = true;
allownomd = true;
} else {
throw new IllegalArgumentException(
"unknown descriptor rule '" + descriptorRule
+ "'. Allowed rules are: "
+ Arrays.asList(new String[] {DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL}));
throw new IllegalArgumentException("unknown descriptor rule '" + descriptorRule
+ "'. Allowed rules are: "
+ Arrays.asList(new String[] {DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL}));
}
}
@ -1024,9 +1121,8 @@ public abstract class BasicResolver extends AbstractResolver {
public void setChecksums(String checksums) {
this.checksums = checksums;
}
private final ArtifactResourceResolver artifactResourceResolver
= new ArtifactResourceResolver() {
private final ArtifactResourceResolver artifactResourceResolver = new ArtifactResourceResolver() {
public ResolvedResource resolve(Artifact artifact) {
artifact = fromSystem(artifact);
return getArtifactRef(artifact, null);
@ -1039,8 +1135,7 @@ public abstract class BasicResolver extends AbstractResolver {
dest.delete();
}
File part = new File(dest.getAbsolutePath() + ".part");
if (resource.getName().equals(
String.valueOf(artifact.getUrl()))) {
if (resource.getName().equals(String.valueOf(artifact.getUrl()))) {
if (part.getParentFile() != null) {
part.getParentFile().mkdirs();
}
@ -1049,11 +1144,10 @@ public abstract class BasicResolver extends AbstractResolver {
getAndCheck(resource, part);
}
if (!part.renameTo(dest)) {
throw new IOException(
"impossible to move part file to definitive one: "
+ part + " -> " + dest);
throw new IOException("impossible to move part file to definitive one: " + part
+ " -> " + dest);
}
}
};

View File

@ -20,7 +20,6 @@ package org.apache.ivy.osgi.core;
import java.util.Map;
import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
import org.apache.ivy.osgi.repo.ExecutionEnvironmentProfile;
import junit.framework.TestCase;

View File

@ -24,16 +24,16 @@ import java.util.Iterator;
import junit.framework.TestCase;
import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
import org.apache.ivy.osgi.repo.BundleRepo;
import org.apache.ivy.osgi.repo.BundleRepoDescriptor;
import org.apache.ivy.util.Message;
public class OBRParserTest extends TestCase {
public void testParse() throws Exception {
BundleRepo repo = OBRXMLParser
BundleRepoDescriptor repo = OBRXMLParser
.parse(new FileInputStream(new File("test/test-obr/obr.xml")));
assertNotNull(repo);
System.out.println(repo.getBundles().size() + " bundles successfully parsed, "
System.out.println(repo.getModules().size() + " bundles successfully parsed, "
+ Message.getProblems().size() + " errors");
Iterator itPb = Message.getProblems().iterator();
while (itPb.hasNext()) {

View File

@ -49,7 +49,7 @@ import org.apache.ivy.osgi.core.BundleInfo;
import org.apache.ivy.osgi.core.BundleInfoAdapter;
import org.apache.ivy.osgi.core.ManifestParser;
import org.apache.ivy.osgi.obr.OBRResolver;
import org.apache.ivy.osgi.repo.BundleRepoResolver.RequirementStrategy;
import org.apache.ivy.osgi.repo.RepoDescriptorBasedResolver.RequirementStrategy;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.DualResolver;
import org.apache.ivy.plugins.resolver.FileSystemResolver;
@ -285,7 +285,7 @@ public class OBRResolverTest extends TestCase {
DefaultModuleDescriptor md = BundleInfoAdapter.toModuleDescriptor(bundleInfo, null);
ResolveReport resolveReport = ivy.resolve(md,
new ResolveOptions().setConfs(new String[] {conf}).setOutputReport(false));
assertFalse("resolve failed " + resolveReport.getProblemMessages(),
assertFalse("resolve failed " + resolveReport.getAllProblemMessages(),
resolveReport.hasError());
Set/* <ModuleRevisionId> */actual = new HashSet/* <ModuleRevisionId> */();
List/* <Artifact> */artifacts = resolveReport.getArtifacts();

View File

@ -32,6 +32,7 @@ import javax.xml.transform.stream.StreamResult;
import junit.framework.TestCase;
import org.apache.ivy.core.settings.IvySettings;
import org.apache.ivy.osgi.core.ExecutionEnvironmentProfileProvider;
import org.apache.ivy.osgi.obr.xml.OBRXMLParser;
import org.apache.ivy.osgi.obr.xml.OBRXMLWriter;
import org.apache.ivy.plugins.repository.file.FileRepository;
@ -43,10 +44,11 @@ public class BundleRepoTest extends TestCase {
public void testFS() throws Exception {
FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
BundleRepo repo = new BundleRepo();
BundleRepoDescriptor repo = new BundleRepoDescriptor(
ExecutionEnvironmentProfileProvider.getInstance());
repo.populate(it.iterator());
BundleRepo repo2 = OBRXMLParser.parse(new FileInputStream(
BundleRepoDescriptor repo2 = OBRXMLParser.parse(new FileInputStream(
"test/test-repo/bundlerepo/repo.xml"));
assertEquals(repo, repo2);
@ -55,10 +57,11 @@ public class BundleRepoTest extends TestCase {
public void testFileRepo() throws Exception {
RepositoryManifestIterable it = new RepositoryManifestIterable(new FileRepository(new File(
"test/test-repo/bundlerepo").getAbsoluteFile()));
BundleRepo repo = new BundleRepo();
BundleRepoDescriptor repo = new BundleRepoDescriptor(
ExecutionEnvironmentProfileProvider.getInstance());
repo.populate(it.iterator());
BundleRepo repo2 = OBRXMLParser.parse(new FileInputStream(
BundleRepoDescriptor repo2 = OBRXMLParser.parse(new FileInputStream(
"test/test-repo/bundlerepo/repo.xml"));
assertEquals(repo, repo2);
@ -74,18 +77,20 @@ public class BundleRepoTest extends TestCase {
+ "/[organisation]/[module]/[revision]/[type]s/[artifact]-[revision].[ext]");
fileSystemResolver.setSettings(new IvySettings());
ResolverManifestIterable it = new ResolverManifestIterable(fileSystemResolver);
BundleRepo repo = new BundleRepo();
BundleRepoDescriptor repo = new BundleRepoDescriptor(
ExecutionEnvironmentProfileProvider.getInstance());
repo.populate(it.iterator());
BundleRepo repo2 = OBRXMLParser
.parse(new FileInputStream("test/test-repo/ivyrepo/repo.xml"));
BundleRepoDescriptor repo2 = OBRXMLParser.parse(new FileInputStream(
"test/test-repo/ivyrepo/repo.xml"));
assertEquals(repo, repo2);
}
public void testXMLSerialisation() throws SAXException, ParseException, IOException {
FSManifestIterable it = new FSManifestIterable(new File("test/test-repo/bundlerepo"), "");
BundleRepo repo = new BundleRepo();
BundleRepoDescriptor repo = new BundleRepoDescriptor(
ExecutionEnvironmentProfileProvider.getInstance());
repo.populate(it.iterator());
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();
@ -100,10 +105,10 @@ public class BundleRepoTest extends TestCase {
StreamResult stream = new StreamResult(out);
hd.setResult(stream);
OBRXMLWriter.writeBundles(repo.getBundles().iterator(), hd);
OBRXMLWriter.writeManifests(it.iterator(), hd, false);
ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray());
BundleRepo repo2 = OBRXMLParser.parse(in);
BundleRepoDescriptor repo2 = OBRXMLParser.parse(in);
assertEquals(repo, repo2);
}

View File

@ -30,53 +30,53 @@
</capability>
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing" />
</capability>
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle)" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing.optional" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing-optional&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-optional&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing-optional?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-optional&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing.optional" />
</capability>
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle)" optional="true" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing.transitiveoptional" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing-transitiveoptional&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-transitiveoptional&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing-transitiveoptional?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-transitiveoptional&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing.transitiveoptional" />
</capability>
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle.importing.optional)" optional="true" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing.version" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing-version&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-version&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing-version?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-version&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing.version" />
</capability>
<require name="package" filter="(&amp;(package=org.apache.ivy.osgi.testbundle)(version&gt;=1.2.3))" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing.rangeversion" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing-rangeversion&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-rangeversion&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing-rangeversion?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-rangeversion&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing.rangeversion" />
</capability>
<require name="package" filter="(&amp;(package=org.apache.ivy.osgi.testbundle)(version&gt;=1.0.0)(version&lt;2.0.0))" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing.use" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing-use&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-use&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing-use?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-use&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing.use" />
</capability>
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle.use)" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.require" version="1.1.1"
uri="ivy://org.apache.ivy.osgi/testbundle-require&amp;rev=1.1.1&amp;type=jar&amp;art=testbundle-require&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-require?&amp;rev=1.1.1&amp;type=jar&amp;art=testbundle-require&amp;ext=jar">
<require name="bundle" filter="(&amp;(symbolicname=org.apache.ivy.osgi.testbundle.importing.version)(version&gt;=3.2.1))" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.use" version="2.2.2"
uri="ivy://org.apache.ivy.osgi/testbundle-use&amp;rev=2.2.2&amp;type=jar&amp;art=testbundle-use&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-use?rev=2.2.2&amp;type=jar&amp;art=testbundle-use&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.use" />
<p n="version" v="2.2.2" />
@ -85,17 +85,17 @@
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle.importing)" optional="true" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.exporting.ambiguity" version="3.3.3"
uri="ivy://org.apache.ivy.osgi/testbundle-exporting-ambiguity&amp;rev=3.3.3&amp;type=jar&amp;art=testbundle-exporting-ambiguity&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-exporting-ambiguity?rev=3.3.3&amp;type=jar&amp;art=testbundle-exporting-ambiguity&amp;ext=jar">
<capability name="package">
<p n="package" v="org.apache.ivy.osgi.testbundle.importing.version" />
</capability>
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.importing.ambiguity" version="3.2.1"
uri="ivy://org.apache.ivy.osgi/testbundle-importing-ambiguity&amp;rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-ambiguity&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-importing-ambiguity?rev=3.2.1&amp;type=jar&amp;art=testbundle-importing-ambiguity&amp;ext=jar">
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle.importing.version)" />
</resource>
<resource symbolicname="org.apache.ivy.osgi.testbundle.require.ambiguity" version="1.1.1"
uri="ivy://org.apache.ivy.osgi/testbundle-require-ambiguity&amp;rev=1.1.1&amp;type=jar&amp;art=testbundle-require-ambiguity&amp;ext=jar">
uri="ivy://org.apache.ivy.osgi/testbundle-require-ambiguity?rev=1.1.1&amp;type=jar&amp;art=testbundle-require-ambiguity&amp;ext=jar">
<require name="bundle" filter="(&amp;(symbolicname=org.apache.ivy.osgi.testbundle.importing.version)(version&gt;=3.2.1))" />
<require name="package" filter="(package=org.apache.ivy.osgi.testbundle.importing.version)" />
</resource>