Index: ivy-2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java
===================================================================
--- ivy-2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java (revision 1378253)
+++ ivy-2.3.x/test/java/org/apache/ivy/core/resolve/ResolveTest.java (working copy)
@@ -3863,7 +3863,7 @@
public void testResolveExcludesConf3() throws Exception {
ResolveReport report = ivy.resolve(new File(
- "test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml"),
+ "test/repositories/1/org2/mod2.6/ivys/ivy-0.14.xml").toURL(),
getResolveOptions(new String[] {"exclude"}));
ModuleDescriptor md = report.getModuleDescriptor();
assertEquals(ModuleRevisionId.newInstance("org2", "mod2.6", "0.14"), md
Index: ivy-2.3.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
===================================================================
--- ivy-2.3.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java (revision 1377749)
+++ ivy-2.3.x/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java (working copy)
@@ -65,6 +65,7 @@
import org.apache.ivy.plugins.resolver.ChainResolver.ResolvedModuleRevisionArtifactInfo;
import org.apache.ivy.plugins.resolver.util.HasLatestStrategy;
import org.apache.ivy.plugins.resolver.util.ResolvedResource;
+import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.Checks;
import org.apache.ivy.util.Message;
@@ -581,6 +582,10 @@
return AbstractResolver.this.getSettings().getMatcher(matcherName);
}
+ public VersionMatcher getVersionMatcher() {
+ return AbstractResolver.this.getSettings().getVersionMatcher();
+ }
+
public Namespace getNamespace(String namespace) {
return AbstractResolver.this.getSettings().getNamespace(namespace);
}
Index: ivy-2.3.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java
===================================================================
--- ivy-2.3.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java (revision 1377749)
+++ ivy-2.3.x/src/java/org/apache/ivy/plugins/parser/ParserSettings.java (working copy)
@@ -29,6 +29,7 @@
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.plugins.namespace.Namespace;
import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.version.VersionMatcher;
public interface ParserSettings {
@@ -42,6 +43,8 @@
PatternMatcher getMatcher(String matcherName);
+ VersionMatcher getVersionMatcher();
+
Namespace getNamespace(String namespace);
StatusManager getStatusManager();
Index: ivy-2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
===================================================================
--- ivy-2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (revision 1377749)
+++ ivy-2.3.x/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java (working copy)
@@ -26,6 +26,7 @@
import java.net.URL;
import java.text.ParseException;
import java.util.Arrays;
+import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Locale;
@@ -71,13 +72,15 @@
import org.apache.ivy.plugins.repository.url.URLResource;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.FileSystemResolver;
-import org.apache.ivy.util.FileUtil;
+import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.DateUtil;
+import org.apache.ivy.util.FileUtil;
import org.apache.ivy.util.Message;
import org.apache.ivy.util.XMLHelper;
import org.apache.ivy.util.extendable.ExtendableItemHelper;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
/**
* Parses an xml ivy file and output a ModuleDescriptor. For dependency and performance reasons, it
@@ -86,7 +89,7 @@
public class XmlModuleDescriptorParser extends AbstractModuleDescriptorParser {
static final String[] DEPENDENCY_REGULAR_ATTRIBUTES = new String[] {"org", "name", "branch",
"branchConstraint", "rev", "revConstraint", "force", "transitive", "changing", "conf"};
-
+
public static final String MODULE_INHERITANCE_REPOSITORY = "module-inheritance-repository";
private static final XmlModuleDescriptorParser INSTANCE = new XmlModuleDescriptorParser();
@@ -156,13 +159,14 @@
DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
ns = dmd.getNamespace();
}
- XmlModuleDescriptorUpdater.update(is, res, destFile,
- new UpdateOptions()
- .setSettings(IvyContext.getContext().getSettings())
- .setStatus(md.getStatus())
- .setRevision(md.getResolvedModuleRevisionId().getRevision())
- .setPubdate(md.getResolvedPublicationDate())
- .setUpdateBranch(false)
+ XmlModuleDescriptorUpdater.update(
+ is,
+ res,
+ destFile,
+ new UpdateOptions().setSettings(IvyContext.getContext().getSettings())
+ .setStatus(md.getStatus())
+ .setRevision(md.getResolvedModuleRevisionId().getRevision())
+ .setPubdate(md.getResolvedPublicationDate()).setUpdateBranch(false)
.setNamespace(ns));
} catch (SAXException e) {
ParseException ex = new ParseException("exception occurred while parsing " + res, 0);
@@ -175,6 +179,66 @@
}
}
+ private static class MinimalParentParser extends DefaultHandler {
+ private ModuleRevisionId mrid;
+
+ /* how and what do we have to parse */
+ private ParserSettings settings;
+
+ private URL descriptorURL;
+
+ private MinimalParentParser(ParserSettings ivySettings) {
+ settings = ivySettings;
+ }
+
+ private void parse() throws ParseException, IOException {
+ try {
+ XMLHelper.parse(descriptorURL, null, this);
+ } catch (ParserConfigurationException ex) {
+ IllegalStateException ise = new IllegalStateException(ex.getMessage() + " in "
+ + descriptorURL);
+ ise.initCause(ex);
+ throw ise;
+ } catch (Exception ex) {
+ ParseException pe = new ParseException(ex.getMessage() + " in " + descriptorURL, 0);
+ pe.initCause(ex);
+ throw pe;
+ }
+ }
+
+ public void startElement(String uri, String localName, String qName, Attributes attributes)
+ throws SAXException {
+ try {
+ if ("info".equals(qName)) {
+ infoStarted(attributes);
+ }
+ } catch (Exception ex) {
+ if (ex instanceof SAXException) {
+ throw (SAXException) ex;
+ }
+ SAXException sax = new SAXException("Problem occurred while parsing ivy file: "
+ + ex.getMessage(), ex);
+ sax.initCause(ex);
+ throw sax;
+ }
+ }
+
+ private void infoStarted(Attributes attributes) {
+ String org = settings.substitute(attributes.getValue("organisation"));
+ String module = settings.substitute(attributes.getValue("module"));
+ String revision = settings.substitute(attributes.getValue("revision"));
+ mrid = ModuleRevisionId.newInstance(org, module, revision);
+ }
+
+ private ModuleRevisionId getModuleRevisionId() {
+ return mrid;
+ }
+
+ private void setInput(URL descriptorURL) {
+ this.descriptorURL = descriptorURL;
+ }
+ }
+
public static class Parser extends AbstractParser {
public static final class State {
public static final int NONE = 0;
@@ -198,37 +262,48 @@
public static final int EXCLUDE = 9;
public static final int DEPS = 10;
-
+
public static final int DESCRIPTION = 11;
public static final int EXTRA_INFO = 12;
-
+
private State() {
}
}
- protected static final List ALLOWED_VERSIONS = Arrays.asList(
- new String[] {"1.0", "1.1", "1.2", "1.3", "1.4", "2.0", "2.1", "2.2"});
+ protected static final List ALLOWED_VERSIONS = Arrays.asList(new String[] {"1.0", "1.1",
+ "1.2", "1.3", "1.4", "2.0", "2.1", "2.2"});
/* how and what do we have to parse */
private ParserSettings settings;
+
private boolean validate = true;
+
private URL descriptorURL;
- private InputStream descriptorInput;
+ private InputStream descriptorInput;
/* Parsing state */
private int state = State.NONE;
+
private PatternMatcher defaultMatcher;
+
private DefaultDependencyDescriptor dd;
+
private ConfigurationAware confAware;
+
private MDArtifact artifact;
+
private String conf;
+
private boolean artifactsDeclared = false;
+
private StringBuffer buffer;
+
private String descriptorVersion;
+
private String[] publicationsDefaultConf;
-
+
public Parser(ModuleDescriptorParser parser, ParserSettings ivySettings) {
super(parser);
settings = ivySettings;
@@ -246,8 +321,7 @@
this.validate = validate;
}
- public void parse() throws ParseException,
- IOException {
+ public void parse() throws ParseException, IOException {
try {
URL schemaURL = validate ? getSchemaURL() : null;
if (descriptorURL != null) {
@@ -258,14 +332,15 @@
checkConfigurations();
replaceConfigurationWildcards();
getMd().setModuleArtifact(
- DefaultArtifact.newIvyArtifact(
- getMd().getResolvedModuleRevisionId(), getMd().getPublicationDate()));
+ DefaultArtifact.newIvyArtifact(getMd().getResolvedModuleRevisionId(), getMd()
+ .getPublicationDate()));
if (!artifactsDeclared) {
String[] confs = getMd().getConfigurationsNames();
for (int i = 0; i < confs.length; i++) {
- getMd().addArtifact(confs[i],
- new MDArtifact(getMd(), getMd().getModuleRevisionId().getName(),
- "jar", "jar"));
+ getMd().addArtifact(
+ confs[i],
+ new MDArtifact(getMd(), getMd().getModuleRevisionId().getName(), "jar",
+ "jar"));
}
}
getMd().check();
@@ -304,8 +379,9 @@
} else if (state == State.INFO && "extends".equals(qName)) {
extendsStarted(attributes);
} else if (state == State.INFO && "license".equals(qName)) {
- getMd().addLicense(new License(settings.substitute(attributes.getValue("name")),
- settings.substitute(attributes.getValue("url"))));
+ getMd().addLicense(
+ new License(settings.substitute(attributes.getValue("name")), settings
+ .substitute(attributes.getValue("url"))));
} else if (state == State.INFO && "description".equals(qName)) {
getMd().setHomePage(settings.substitute(attributes.getValue("homepage")));
state = State.DESCRIPTION;
@@ -326,7 +402,8 @@
} else if ("conflicts".equals(qName)) {
if (!descriptorVersion.startsWith("1.")) {
Message.deprecated("using conflicts section is deprecated: "
- + "please use hints section instead. Ivy file URL: " + descriptorURL);
+ + "please use hints section instead. Ivy file URL: "
+ + descriptorURL);
}
state = State.CONFLICT;
checkConfigurations();
@@ -345,8 +422,8 @@
} else if ("conf".equals(qName)) {
confStarted(attributes);
} else if ("mapped".equals(qName)) {
- dd.addDependencyConfiguration(conf, settings.substitute(attributes
- .getValue("name")));
+ dd.addDependencyConfiguration(conf,
+ settings.substitute(attributes.getValue("name")));
} else if (("conflict".equals(qName) && state == State.DEPS)
|| "manager".equals(qName) && state == State.CONFLICT) {
managerStarted(attributes, state == State.CONFLICT ? "name" : "manager");
@@ -369,7 +446,8 @@
}
/**
- * Default parent location to check (for dev ONLY)
+ * Default parent location to check (for dev ONLY)
+ *
* @return a relative path to a parent module descriptor
*/
protected String getDefaultParentLocation() {
@@ -377,44 +455,46 @@
}
/**
- * Handle extends elements.
- * It checks :
- *
- * - filesystem based on location attribute, if no one is specified it will check the default parent location
- * - cache to find a resolved parent descriptor
- * - ask repositories to retrieve the parent module descriptor
- *
- * @param attributes
- * @throws ParseException
+ * Handle extends elements. It checks :
+ *
+ * - filesystem based on location attribute, if no one is specified it will check the
+ * default parent location
+ * - cache to find a resolved parent descriptor
+ * - ask repositories to retrieve the parent module descriptor
+ *
+ *
+ * @param attributes
+ * @throws ParseException
*/
protected void extendsStarted(Attributes attributes) throws ParseException {
String parentOrganisation = settings.substitute(attributes.getValue("organisation"));
String parentModule = settings.substitute(attributes.getValue("module"));
- String parentRevision = attributes.getValue("revision") != null ? settings.substitute(attributes
- .getValue("revision")) : Ivy.getWorkingRevision();
- String location = attributes.getValue("location") != null ? settings.substitute(attributes
- .getValue("location")) : getDefaultParentLocation();
+ String parentRevision = attributes.getValue("revision") != null ? settings
+ .substitute(attributes.getValue("revision")) : Ivy.getWorkingRevision();
+ String location = attributes.getValue("location") != null ? settings
+ .substitute(attributes.getValue("location")) : getDefaultParentLocation();
ModuleDescriptor parent = null;
- String extendType = attributes.getValue("extendType") != null ? settings.substitute(attributes.getValue(
- "extendType").toLowerCase(Locale.US)) : "all";
+ String extendType = attributes.getValue("extendType") != null ? settings
+ .substitute(attributes.getValue("extendType").toLowerCase(Locale.US)) : "all";
List/* */extendTypes = Arrays.asList(extendType.split(","));
ModuleId parentMid = new ModuleId(parentOrganisation, parentModule);
ModuleRevisionId parentMrid = new ModuleRevisionId(parentMid, parentRevision);
-
- //check on filesystem based on location attribute (for dev ONLY)
+ // check on filesystem based on location attribute (for dev ONLY)
try {
- DependencyResolver parentResolver = checkParentModuleOnFilesystem(location, parentMrid);
+ DependencyResolver parentResolver = checkParentModuleOnFilesystem(location,
+ parentMrid);
if (parentResolver != null) {
- parent = resolveParentFromModuleInheritanceRepository(parentResolver, parentMrid);
+ parent = resolveParentFromModuleInheritanceRepository(parentResolver,
+ parentMrid);
}
} catch (IOException e) {
- Message.warn("Unable to parse included ivy file " + location + ": "
- + e.getMessage());
+ Message.warn("Unable to parse included ivy file " + location + ": "
+ + e.getMessage());
}
-
+
// if not found, tries to resolve using repositories
if (parent == null) {
try {
@@ -423,7 +503,7 @@
Message.warn("Unable to parse included ivy file for " + parentMrid.toString());
}
}
-
+
// if still not found throw an exception
if (parent == null) {
throw new ParseException("Unable to parse included ivy file for "
@@ -431,8 +511,7 @@
}
DefaultExtendsDescriptor ed = new DefaultExtendsDescriptor(
- parent.getModuleRevisionId(),
- parent.getResolvedModuleRevisionId(),
+ parent.getModuleRevisionId(), parent.getResolvedModuleRevisionId(),
attributes.getValue("location"),
(String[]) extendTypes.toArray(new String[extendTypes.size()]));
getMd().addInheritedDescriptor(ed);
@@ -441,9 +520,13 @@
}
/**
- * Merge current module with a given module descriptor and specify what should be inherited through extendTypes argument
- * @param extendTypes specify what should be inherited
- * @param parent a given parent module descriptor
+ * Merge current module with a given module descriptor and specify what should be inherited
+ * through extendTypes argument
+ *
+ * @param extendTypes
+ * specify what should be inherited
+ * @param parent
+ * a given parent module descriptor
*/
protected void mergeWithOtherModuleDescriptor(List/* */extendTypes,
ModuleDescriptor parent) throws ParseException {
@@ -454,7 +537,7 @@
if (extendTypes.contains("info")) {
mergeInfo(parent);
}
-
+
if (extendTypes.contains("configurations")) {
mergeConfigurations(parent);
}
@@ -475,7 +558,9 @@
/**
* Merge everything from a given parent
- * @param parent a given parent module desciptor
+ *
+ * @param parent
+ * a given parent module desciptor
*/
protected void mergeAll(ModuleDescriptor parent) {
mergeInfo(parent);
@@ -487,7 +572,9 @@
/**
* Explain how to inherit metadatas related to info element
- * @param parent a given parent module decriptor
+ *
+ * @param parent
+ * a given parent module decriptor
*/
protected void mergeInfo(ModuleDescriptor parent) {
ModuleRevisionId parentMrid = parent.getModuleRevisionId();
@@ -501,8 +588,7 @@
mergeValue(parentMrid.getBranch(), currentMrid.getBranch()),
mergeRevisionValue(parentMrid.getRevision(), currentMrid.getRevision()),
mergeValues(parentMrid.getQualifiedExtraAttributes(),
- currentMrid.getQualifiedExtraAttributes())
- );
+ currentMrid.getQualifiedExtraAttributes()));
descriptor.setModuleRevisionId(mergedMrid);
descriptor.setResolvedModuleRevisionId(mergedMrid);
@@ -513,19 +599,19 @@
descriptor.setNamespace(parentNamespace);
}
}
-
+
private static String mergeRevisionValue(String inherited, String override) {
- if (override==null || override.equals(Ivy.getWorkingRevision())) {
+ if (override == null || override.equals(Ivy.getWorkingRevision())) {
return inherited;
} else {
return override;
}
}
-
+
private static String mergeValue(String inherited, String override) {
return override == null ? inherited : override;
}
-
+
private static Map mergeValues(Map inherited, Map overrides) {
LinkedHashMap dup = new LinkedHashMap(inherited.size() + overrides.size());
dup.putAll(inherited);
@@ -535,8 +621,11 @@
/**
* Describes how to merge configurations elements
- * @param sourceMrid the source module revision id
- * @param configurations array of configurations to be inherited
+ *
+ * @param sourceMrid
+ * the source module revision id
+ * @param configurations
+ * array of configurations to be inherited
*/
protected void mergeConfigurations(ModuleDescriptor parent) {
ModuleRevisionId sourceMrid = parent.getModuleRevisionId();
@@ -544,7 +633,7 @@
for (int i = 0; i < configurations.length; i++) {
Configuration configuration = configurations[i];
Message.debug("Merging configuration with: " + configuration.getName());
- //copy configuration from parent descriptor
+ // copy configuration from parent descriptor
getMd().addConfiguration(new Configuration(configuration, sourceMrid));
}
@@ -557,7 +646,9 @@
/**
* Describes how dependencies should be inherited
- * @param dependencies array of dependencies to inherit
+ *
+ * @param dependencies
+ * array of dependencies to inherit
*/
protected void mergeDependencies(DependencyDescriptor[] dependencies) {
DefaultModuleDescriptor md = getMd();
@@ -571,7 +662,9 @@
/**
* Describes how to merge description
- * @param description description going to be inherited
+ *
+ * @param description
+ * description going to be inherited
*/
protected void mergeDescription(String description) {
String current = getMd().getDescription();
@@ -579,10 +672,12 @@
getMd().setDescription(description);
}
}
-
+
/**
* Describes how to merge licenses
- * @param licenses licenses going to be inherited
+ *
+ * @param licenses
+ * licenses going to be inherited
*/
public void mergeLicenses(License[] licenses) {
for (int i = 0; i < licenses.length; i++) {
@@ -591,18 +686,21 @@
}
/**
- * Check if parent module is reachable using location attribute (for dev purpose).
- * If parent module is reachable it will be registered in module inheritance repository
- * @param location a given location
- * @param parentMrid
+ * Check if parent module is reachable using location attribute (for dev purpose). If parent
+ * module is reachable it will be registered in module inheritance repository
+ *
+ * @param location
+ * a given location
+ * @param parentMrid
* @throws IOException
- * @throws ParseException
+ * @throws ParseException
*/
- protected DependencyResolver checkParentModuleOnFilesystem(String location, ModuleRevisionId parentMrid) throws IOException {
+ protected DependencyResolver checkParentModuleOnFilesystem(String location,
+ ModuleRevisionId parentMrid) throws IOException {
if (!"file".equals(descriptorURL.getProtocol())) {
return null;
}
-
+
File file = new File(location);
if (!file.isAbsolute()) {
URL url = new URL(descriptorURL, location);
@@ -612,30 +710,78 @@
file = new File(url.getPath());
}
}
-
+
file = FileUtil.normalize(file.getAbsolutePath());
if (!file.exists()) {
- Message.verbose("Parent module doesn't exist on the filesystem: " + file.getAbsolutePath());
+ Message.verbose("Parent module doesn't exist on the filesystem: "
+ + file.getAbsolutePath());
+ return null;
+ }
+
+ if (!isExpectedParentInLocation(parentMrid, file)) {
return null;
}
-
+ // else
FileSystemResolver parentModuleResolver = new FileSystemResolver();
- parentModuleResolver.setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
+ parentModuleResolver
+ .setName(getModuleInheritanceRepositoryParentResolverName(parentMrid));
parentModuleResolver.addIvyPattern(file.getAbsolutePath());
parentModuleResolver.setSettings(IvyContext.getContext().getSettings());
+ IvyContext.getContext().getSettings().addResolver(parentModuleResolver);
return parentModuleResolver;
}
+ private boolean isExpectedParentInLocation(ModuleRevisionId expectedParentMrid, File file) {
+ try {
+ ModuleRevisionId actualParentMrid = parseModuleRevisionIdFromDescriptor(settings,
+ file.toURL());
+ if (expectedParentMrid.getModuleId().equals(actualParentMrid.getModuleId())) {
+ VersionMatcher versionMatcher = settings.getVersionMatcher();
+ if (versionMatcher.accept(expectedParentMrid, actualParentMrid)) {
+ return true;
+ }
+ }
+ // else
+ Object[] args = new Object[] {file.getAbsolutePath(), expectedParentMrid,
+ actualParentMrid};
+ String message = String
+ .format(
+ "Unexpected ModuleRevisionId found for parent module at source location %1$s. Expected: %2$s. Actual: %3$s. Not attempting to parse the parent using the path specified by the extends@location attribute. Instead only locating the published parent through a regular resolver.",
+ args);
+ Message.info(message);
+ return false;
+ } catch (Throwable t) {
+ Object[] args = new Object[] {file.getAbsolutePath(), expectedParentMrid, t};
+ String message = String
+ .format(
+ "Exception caught while trying to parse parent module at source location %1$s. Not attempting to parse the parent using the path specified by the extends@location attribute. Instead only locating the published parent through a regular resolver. Expected ModuleRevisionId: %2$s. Exception: %3$s.",
+ args);
+ Message.info(message);
+ return false;
+ }
+ }
+
+ private ModuleRevisionId parseModuleRevisionIdFromDescriptor(ParserSettings ivySettings,
+ URL xmlURL) throws ParseException, IOException {
+ MinimalParentParser parser = new MinimalParentParser(ivySettings);
+ parser.setInput(xmlURL);
+ parser.parse();
+ return parser.getModuleRevisionId();
+ }
+
/**
* Describe how to parse a {@link ModuleDescriptor} by asking repositories
- * @param parentMrid a given {@link ModuleRevisionId} to find
- * @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor} was found
+ *
+ * @param parentMrid
+ * a given {@link ModuleRevisionId} to find
+ * @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor}
+ * was found
* @throws ParseException
*/
- protected ModuleDescriptor parseOtherIvyFile(ModuleRevisionId parentMrid) throws ParseException {
- Message.debug(
- "Trying to parse included ivy file by asking repository for module :"
- + parentMrid.toString());
+ protected ModuleDescriptor parseOtherIvyFile(ModuleRevisionId parentMrid)
+ throws ParseException {
+ Message.debug("Trying to parse included ivy file by asking repository for module :"
+ + parentMrid.toString());
DependencyDescriptor dd = new DefaultDependencyDescriptor(parentMrid, true);
ResolveData data = IvyContext.getContext().getResolveData();
if (data == null) {
@@ -656,16 +802,20 @@
/**
* Resolve parent module from module inheritance repository
- * @param parentMrid a given {@link ModuleRevisionId} to find
- * @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor} was found
+ *
+ * @param parentMrid
+ * a given {@link ModuleRevisionId} to find
+ * @return a {@link ModuleDescriptor} if found. Return null if no {@link ModuleDescriptor}
+ * was found
* @throws ParseException
*/
- protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(DependencyResolver resolver, ModuleRevisionId parentMrid) throws ParseException {
- Message.debug("Trying to resolve included ivy file from module inheritance repository " );
+ protected ModuleDescriptor resolveParentFromModuleInheritanceRepository(
+ DependencyResolver resolver, ModuleRevisionId parentMrid) throws ParseException {
+ Message.debug("Trying to resolve included ivy file from module inheritance repository ");
DependencyDescriptor dd = new DefaultDependencyDescriptor(parentMrid, true);
ResolveEngine engine = IvyContext.getContext().getIvy().getResolveEngine();
ResolveOptions options = new ResolveOptions();
- //not sure we need to download parent module
+ // not sure we need to download parent module
options.setDownload(false);
ResolveData data = new ResolveData(engine, options);
@@ -677,8 +827,9 @@
return null;
}
}
-
- private static String getModuleInheritanceRepositoryParentResolverName(ModuleRevisionId parentMrid) {
+
+ private static String getModuleInheritanceRepositoryParentResolverName(
+ ModuleRevisionId parentMrid) {
return MODULE_INHERITANCE_REPOSITORY + "-" + parentMrid.toString();
}
@@ -748,28 +899,27 @@
addError("unknown matcher: " + matcherName);
return;
}
- getMd().addDependencyDescriptorMediator(
- new ModuleId(org, mod), matcher,
+ getMd().addDependencyDescriptorMediator(new ModuleId(org, mod), matcher,
new OverrideDependencyDescriptorMediator(branch, rev));
}
- protected void includeConfStarted(Attributes attributes)
- throws SAXException, IOException, ParserConfigurationException, ParseException {
+ protected void includeConfStarted(Attributes attributes) throws SAXException, IOException,
+ ParserConfigurationException, ParseException {
URL url = settings.getRelativeUrlResolver().getURL(descriptorURL,
- settings.substitute(attributes.getValue("file")),
- settings.substitute(attributes.getValue("url")));
-
+ settings.substitute(attributes.getValue("file")),
+ settings.substitute(attributes.getValue("url")));
+
if (url == null) {
throw new SAXException("include tag must have a file or an url attribute");
}
-
+
// create a new temporary parser to read the configurations from
// the specified file.
Parser parser = new Parser(getModuleDescriptorParser(), settings);
parser.setInput(url);
- parser.setMd(new DefaultModuleDescriptor(getModuleDescriptorParser(),
- new URLResource(url)));
- XMLHelper.parse(url , null, parser);
+ parser.setMd(new DefaultModuleDescriptor(getModuleDescriptorParser(), new URLResource(
+ url)));
+ XMLHelper.parse(url, null, parser);
// add the configurations from this temporary parser to this module descriptor
Configuration[] configs = parser.getModuleDescriptor().getConfigurations();
@@ -787,8 +937,7 @@
setDefaultConf(parser.getDefaultConf());
}
if (parser.getMd().isMappingOverride()) {
- Message.debug("enabling mapping-override from imported configurations"
- + " file");
+ Message.debug("enabling mapping-override from imported configurations" + " file");
getMd().setMappingOverride(true);
}
}
@@ -800,18 +949,17 @@
String visibility = settings.substitute(attributes.getValue("visibility"));
String ext = settings.substitute(attributes.getValue("extends"));
String transitiveValue = attributes.getValue("transitive");
- boolean transitive = (transitiveValue == null) ? true : Boolean
- .valueOf(attributes.getValue("transitive")).booleanValue();
+ boolean transitive = (transitiveValue == null) ? true : Boolean.valueOf(
+ attributes.getValue("transitive")).booleanValue();
String deprecated = attributes.getValue("deprecated");
Configuration configuration = new Configuration(conf,
- Configuration.Visibility
- .getVisibility(visibility == null ? "public"
- : visibility), settings.substitute(attributes
- .getValue("description")), ext == null ? null : ext
- .split(","), transitive, deprecated);
+ Configuration.Visibility.getVisibility(visibility == null ? "public"
+ : visibility), settings.substitute(attributes
+ .getValue("description")), ext == null ? null : ext.split(","),
+ transitive, deprecated);
ExtendableItemHelper.fillExtraAttributes(settings, configuration, attributes,
- new String[] {"name", "visibility", "extends", "transitive",
- "description", "deprecated"});
+ new String[] {"name", "visibility", "extends", "transitive", "description",
+ "deprecated"});
getMd().addConfiguration(configuration);
break;
case State.PUB:
@@ -857,8 +1005,8 @@
}
boolean force = Boolean.valueOf(settings.substitute(attributes.getValue("force")))
.booleanValue();
- boolean changing = Boolean.valueOf(
- settings.substitute(attributes.getValue("changing"))).booleanValue();
+ boolean changing = Boolean
+ .valueOf(settings.substitute(attributes.getValue("changing"))).booleanValue();
String transitiveValue = settings.substitute(attributes.getValue("transitive"));
boolean transitive = (transitiveValue == null) ? true : Boolean.valueOf(
@@ -867,40 +1015,41 @@
String name = settings.substitute(attributes.getValue("name"));
String branch = settings.substitute(attributes.getValue("branch"));
String branchConstraint = settings.substitute(attributes.getValue("branchConstraint"));
-
-// if (branchConstraint == null) {
-// // there was no branch constraint before, so we should
-// // set the branchConstraint to the current default branch
-// branchConstraint = settings.getDefaultBranch(ModuleId.newInstance(org, name));
-// }
+
+ // if (branchConstraint == null) {
+ // // there was no branch constraint before, so we should
+ // // set the branchConstraint to the current default branch
+ // branchConstraint = settings.getDefaultBranch(ModuleId.newInstance(org, name));
+ // }
String rev = settings.substitute(attributes.getValue("rev"));
String revConstraint = settings.substitute(attributes.getValue("revConstraint"));
-
- Map extraAttributes = ExtendableItemHelper.getExtraAttributes(
- settings, attributes, DEPENDENCY_REGULAR_ATTRIBUTES);
+
+ Map extraAttributes = ExtendableItemHelper.getExtraAttributes(settings, attributes,
+ DEPENDENCY_REGULAR_ATTRIBUTES);
- ModuleRevisionId revId = ModuleRevisionId.newInstance(org, name, branch, rev,
+ ModuleRevisionId revId = ModuleRevisionId.newInstance(org, name, branch, rev,
extraAttributes);
ModuleRevisionId dynamicId = null;
if ((revConstraint == null) && (branchConstraint == null)) {
// no dynamic constraints defined, so dynamicId equals revId
- dynamicId = ModuleRevisionId.newInstance(org, name, branch, rev,
- extraAttributes, false);
+ dynamicId = ModuleRevisionId.newInstance(org, name, branch, rev, extraAttributes,
+ false);
} else {
if (branchConstraint == null) {
// this situation occurs when there was no branch defined
// in the original dependency descriptor. So the dynamicId
// shouldn't contain a branch neither
dynamicId = ModuleRevisionId.newInstance(org, name, null, revConstraint,
- extraAttributes, false);
+ extraAttributes, false);
} else {
- dynamicId = ModuleRevisionId.newInstance(org, name, branchConstraint,
- revConstraint, extraAttributes);
+ dynamicId = ModuleRevisionId.newInstance(org, name, branchConstraint,
+ revConstraint, extraAttributes);
}
}
-
- dd = new DefaultDependencyDescriptor(getMd(), revId, dynamicId, force, changing, transitive);
+
+ dd = new DefaultDependencyDescriptor(getMd(), revId, dynamicId, force, changing,
+ transitive);
getMd().addDependency(dd);
String confs = settings.substitute(attributes.getValue("conf"));
if (confs != null && confs.length() > 0) {
@@ -908,7 +1057,7 @@
}
}
- protected void artifactStarted(String qName, Attributes attributes)
+ protected void artifactStarted(String qName, Attributes attributes)
throws MalformedURLException {
if (state == State.PUB) {
// this is a published artifact
@@ -920,8 +1069,8 @@
ext = ext != null ? ext : type;
String url = settings.substitute(attributes.getValue("url"));
artifact = new MDArtifact(getMd(), artName, type, ext, url == null ? null
- : new URL(url), ExtendableItemHelper.getExtraAttributes(
- settings, attributes, new String[] {"ext", "type", "name", "conf"}));
+ : new URL(url), ExtendableItemHelper.getExtraAttributes(settings,
+ attributes, new String[] {"ext", "type", "name", "conf"}));
String confs = settings.substitute(attributes.getValue("conf"));
// only add confs if they are specified. if they aren't, endElement will
// handle this
@@ -966,13 +1115,11 @@
protected void configurationStarted(Attributes attributes) {
state = State.CONF;
- setDefaultConfMapping(settings
- .substitute(attributes.getValue("defaultconfmapping")));
+ setDefaultConfMapping(settings.substitute(attributes.getValue("defaultconfmapping")));
setDefaultConf(settings.substitute(attributes.getValue("defaultconf")));
- getMd()
- .setMappingOverride(Boolean.valueOf(
- settings.substitute(attributes.getValue("confmappingoverride")))
- .booleanValue());
+ getMd().setMappingOverride(
+ Boolean.valueOf(settings.substitute(attributes.getValue("confmappingoverride")))
+ .booleanValue());
}
protected void infoStarted(Attributes attributes) {
@@ -981,28 +1128,32 @@
String module = settings.substitute(attributes.getValue("module"));
String revision = settings.substitute(attributes.getValue("revision"));
String branch = settings.substitute(attributes.getValue("branch"));
- getMd().setModuleRevisionId(ModuleRevisionId.newInstance(org, module, branch,
- revision, ExtendableItemHelper.getExtraAttributes(settings, attributes,
- new String[] {
- "organisation", "module", "revision", "status", "publication",
- "branch", "namespace", "default", "resolver"})));
+ getMd().setModuleRevisionId(
+ ModuleRevisionId.newInstance(
+ org,
+ module,
+ branch,
+ revision,
+ ExtendableItemHelper.getExtraAttributes(settings, attributes, new String[] {
+ "organisation", "module", "revision", "status", "publication",
+ "branch", "namespace", "default", "resolver"})));
String namespace = settings.substitute(attributes.getValue("namespace"));
if (namespace != null) {
Namespace ns = settings.getNamespace(namespace);
if (ns == null) {
- Message.warn("namespace not found for " + getMd().getModuleRevisionId()
- + ": " + namespace);
+ Message.warn("namespace not found for " + getMd().getModuleRevisionId() + ": "
+ + namespace);
} else {
getMd().setNamespace(ns);
}
}
String status = settings.substitute(attributes.getValue("status"));
- getMd().setStatus(status == null ? settings.getStatusManager().getDefaultStatus()
- : status);
- getMd().setDefault(Boolean.valueOf(settings.substitute(attributes.getValue("default")))
- .booleanValue());
+ getMd().setStatus(
+ status == null ? settings.getStatusManager().getDefaultStatus() : status);
+ getMd().setDefault(
+ Boolean.valueOf(settings.substitute(attributes.getValue("default"))).booleanValue());
String pubDate = settings.substitute(attributes.getValue("publication"));
if (pubDate != null && pubDate.length() > 0) {
try {
@@ -1032,12 +1183,11 @@
+ " as default matcher");
defaultMatcher = settings.getMatcher(PatternMatcher.EXACT_OR_REGEXP);
}
-
+
for (int i = 0; i < attributes.getLength(); i++) {
if (attributes.getQName(i).startsWith("xmlns:")) {
getMd().addExtraAttributeNamespace(
- attributes.getQName(i).substring("xmlns:".length()),
- attributes.getValue(i));
+ attributes.getQName(i).substring("xmlns:".length()), attributes.getValue(i));
}
}
}
@@ -1048,13 +1198,13 @@
parseRule(tag, attributes);
}
- protected void addIncludeRule(String tag, Attributes attributes)
+ protected void addIncludeRule(String tag, Attributes attributes)
throws MalformedURLException {
state = State.ARTIFACT_INCLUDE;
parseRule(tag, attributes);
}
- protected void addExcludeRule(String tag, Attributes attributes)
+ protected void addExcludeRule(String tag, Attributes attributes)
throws MalformedURLException {
state = State.ARTIFACT_EXCLUDE;
parseRule(tag, attributes);
@@ -1077,7 +1227,7 @@
ext = ext != null ? ext : type;
if (state == State.DEP_ARTIFACT) {
String url = settings.substitute(attributes.getValue("url"));
- Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, attributes,
+ Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, attributes,
new String[] {"name", "type", "ext", "url", "conf"});
confAware = new DefaultDependencyArtifactDescriptor(dd, name, type, ext,
url == null ? null : new URL(url), extraAtt);
@@ -1088,7 +1238,7 @@
String module = settings.substitute(attributes.getValue("module"));
module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
- Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, attributes,
+ Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, attributes,
new String[] {"org", "module", "name", "type", "ext", "matcher", "conf"});
confAware = new DefaultIncludeRule(aid, matcher, extraAtt);
} else { // _state == ARTIFACT_EXCLUDE || EXCLUDE
@@ -1098,7 +1248,7 @@
String module = settings.substitute(attributes.getValue("module"));
module = module == null ? PatternMatcher.ANY_EXPRESSION : module;
ArtifactId aid = new ArtifactId(new ModuleId(org, module), name, type, ext);
- Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, attributes,
+ Map extraAtt = ExtendableItemHelper.getExtraAttributes(settings, attributes,
new String[] {"org", "module", "name", "type", "ext", "matcher", "conf"});
confAware = new DefaultExcludeRule(aid, matcher, extraAtt);
}
@@ -1150,20 +1300,17 @@
return matcher;
}
-
public void characters(char[] ch, int start, int length) throws SAXException {
if (buffer != null) {
buffer.append(ch, start, length);
- }
+ }
}
-
public void endElement(String uri, String localName, String qName) throws SAXException {
if (state == State.PUB && "artifact".equals(qName)
&& artifact.getConfigurations().length == 0) {
- String[] confs = publicationsDefaultConf == null
- ? getMd().getConfigurationsNames()
- : publicationsDefaultConf;
+ String[] confs = publicationsDefaultConf == null ? getMd().getConfigurationsNames()
+ : publicationsDefaultConf;
for (int i = 0; i < confs.length; i++) {
artifact.addConfiguration(confs[i].trim());
getMd().addArtifact(confs[i].trim(), artifact);
Index: ivy-2.3.x/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java
===================================================================
--- ivy-2.3.x/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java (revision 1377749)
+++ ivy-2.3.x/src/java/org/apache/ivy/core/cache/ParserSettingsMonitor.java (working copy)
@@ -33,6 +33,7 @@
import org.apache.ivy.plugins.namespace.Namespace;
import org.apache.ivy.plugins.parser.ParserSettings;
import org.apache.ivy.plugins.resolver.DependencyResolver;
+import org.apache.ivy.plugins.version.VersionMatcher;
import org.apache.ivy.util.Message;
/**
@@ -122,6 +123,10 @@
public StatusManager getStatusManager() {
return delegatedSettings.getStatusManager();
}
+
+ public VersionMatcher getVersionMatcher() {
+ return delegatedSettings.getVersionMatcher();
+ }
public File resolveFile(String filename) {
return delegatedSettings.resolveFile(filename);