Author: xavier
Date: Thu Apr 3 02:24:54 2008
New Revision: 644236
URL: http://svn.apache.org/viewvc?rev=644236&view=rev
Log:
complete IVY-784 and IVY-753:
- move override exclude and conflict directly under dependencies element
- implement override writing in module descriptor writer, to make sure
dependencyManagement handling in poms are written to cache in ivy file format
as they should
- update documentation
Added:
ant/ivy/core/trunk/doc/ivyfile/conflict.html (with props)
ant/ivy/core/trunk/doc/ivyfile/override.html (with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/doc/ivyfile/conflicts.html
ant/ivy/core/trunk/doc/ivyfile/manager.html
ant/ivy/core/trunk/doc/toc.json
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-withvar.xml
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update.xml
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-write-full.xml
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Thu Apr 3 02:24:54 2008
@@ -67,7 +67,7 @@
=====================================
- NEW: Retain original dependency constraint rules in resolved ivy file
(IVY-739)
- NEW: Add a new resolve mode (optionally per module) to utilize dynamic
constraint rule metadata (IVY-740)
-- NEW: Add transitive dependency version and branch override mechanism
(IVY-784) (not completed yet)
+- NEW: Add transitive dependency version and branch override mechanism
(IVY-784)
- IMPROVEMENT: Make Ivy standalone runnable with no required dependencies
(IVY-757)
- IMPROVEMENT: add branch attribute in ivy:install task (IVY-727)
@@ -81,7 +81,7 @@
- FIX: multiple cleancache and inline retrieve error (IVY-778)
- FIX: buildlist evicts modules with the same name, but different organisation
(IVY-731)
- FIX: Out of memory/Stack overflow for new highly coupled project (IVY-595)
-- FIX: Compatibility with maven's dependencyMangement (IVY-753) (not completed
yet)
+- FIX: Compatibility with maven's dependencyMangement (IVY-753)
- FIX: ivy:settings fails when override is not set to 'true' (IVY-771)
- FIX: NPE when specifying both resolveId and inline in an Ivy:Resolve
(IVY-776)
- FIX: repreport task not working against a repository structured by branches
(IVY-716)
Added: ant/ivy/core/trunk/doc/ivyfile/conflict.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/ivyfile/conflict.html?rev=644236&view=auto
==============================================================================
--- ant/ivy/core/trunk/doc/ivyfile/conflict.html (added)
+++ ant/ivy/core/trunk/doc/ivyfile/conflict.html Thu Apr 3 02:24:54 2008
@@ -0,0 +1,66 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
+<!--
+ 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.
+-->
+<html>
+<head>
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+ <script type="text/javascript">var xookiConfig = {level: 1};</script>
+ <script type="text/javascript" src="../xooki/xooki.js"></script>
+</head>
+<body>
+ <textarea id="xooki-source">
+<b>Tag:</b> conflict <b>Parent:</b> <a
href="../ivyfile/dependencies.html">dependencies</a><br/>
+<br/>
+<span class="since">(since 2.0)</span>
+
+Specify a a conflict manager for one or several dependencies.
+The way to specify a conflict manager is by giving indication to which
dependencies the conflict manager applies (by giving organisation and module
names or name regexp), and then specifying the conflict manager, either by
giving its name or by specifying a fixed revision list, in which case a fixed
conflicts manager is used.
+
+The list of built-in conflict managers available is listed on the <a
href="../configuration/conflict-managers.html">conflict manager configuration
page</a>.
+
+Conflicts manager are used during the resolve operation, i.e. when ivy analyse
the graph of dependencies and download corresponding ivy files and artifacts.
The fact to manage conflict at resolve time enables to minimize downloads: when
a module is evicted by a conflict manager, it is not downloaded.
+
+There are two things optimized during conflict resolution: download of
artifacts and download of ivy files. The first is always ensured by ivy, i.e.
artifacts of a module evicted will never be downloaded. The second is not as
simple to handle because to know what are the conflicts ivy needs to know the
dependency graph, and to know the dependency graph, it has to download ivy
files. But ivy is highly optimized on this too, and it tries to evict modules
as soon as possible.
+That's why the order of dependencies is important for download optimization.
Indeed ivy traverses the dependency graph in the order in which dependencies
are declared in the ivy files, and each time it encounters a dependency on a
module, it first check if there is a conflict on this module, and if this is
the case, it asks the conflict manager to resolve the conflict. Then if the
module is evicted, it does not download its ivy file, and the whole branch is
not traversed, which can saves a lot of time.
+
+If no specific conflict manager is defined, a default conflict manager is used
for all modules.
+
+The current default conflict manager is the "latest-revision" conflict manager.
+
+<h1>Attributes</h1>
+<table class="ivy-attributes">
+<thead>
+ <tr><th class="ivy-att">Attribute</th><th
class="ivy-att-desc">Description</th><th class="ivy-att-req">Required</th></tr>
+</thead>
+<tbody>
+ <tr><td>org</td><td>the name, or an expression matching the name of
organisation to which this conflict manager should apply (see matcher attribute
below)</td>
+ <td>No, defaults to * (match all)</td></tr>
+ <tr><td>module</td><td>the name, or an expression matching the name of
module to which this conflict manager should apply (see matcher attribute
below)</td>
+ <td>No, defaults to * (match all)</td></tr>
+ <tr><td>manager</td><td>the name of the conflict manager to use</td>
+ <td rowspan="2">Exactly one of two</td></tr>
+ <tr><td>rev</td><td>a comma separated list of revisions this conflict
manager should select</td></tr>
+ <tr><td>matcher</td><td>the <a href="../concept.html#matcher">matcher</a>
to use to match the modules for which the conflict manager should be used</td>
+ <td>No, defaults to exact</td></tr>
+</tbody>
+</table>
+</textarea>
+<script type="text/javascript">xooki.postProcess();</script>
+</body>
+</html>
Propchange: ant/ivy/core/trunk/doc/ivyfile/conflict.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/doc/ivyfile/conflict.html
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/core/trunk/doc/ivyfile/conflicts.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/ivyfile/conflicts.html?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/ivyfile/conflicts.html (original)
+++ ant/ivy/core/trunk/doc/ivyfile/conflicts.html Thu Apr 3 02:24:54 2008
@@ -27,6 +27,8 @@
<textarea id="xooki-source">
<b>Tag:</b> conflicts <b>Parent:</b> <a
href="../ivyfile.html">ivy-module</a><br/><br/>
+<span class="since">(since 2.0)</span> the conflicts section is deprecated.
Use the [[ivyfile/conflict]] instead.
+
Container for conflict manager elements, used to indicate how conflicts should
be resolved
for this module. <br/><br/>
Modified: ant/ivy/core/trunk/doc/ivyfile/manager.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/ivyfile/manager.html?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/ivyfile/manager.html (original)
+++ ant/ivy/core/trunk/doc/ivyfile/manager.html Thu Apr 3 02:24:54 2008
@@ -27,6 +27,8 @@
<textarea id="xooki-source">
<b>Tag:</b> manager <b>Parent:</b> <a
href="../ivyfile/conflicts.html">conflicts</a><br/>
<br/>
+<span class="since">(since 2.0)</span> the conflicts section is deprecated.
Use the [[ivyfile/conflict]] instead.
+
Specify a a conflict manager for one or several dependencies.<br/>
The way to specify a conflict manager is by giving indication to which
dependencies
the conflict manager applies (by giving organisation and module names or name
regexp),
Added: ant/ivy/core/trunk/doc/ivyfile/override.html
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/ivyfile/override.html?rev=644236&view=auto
==============================================================================
--- ant/ivy/core/trunk/doc/ivyfile/override.html (added)
+++ ant/ivy/core/trunk/doc/ivyfile/override.html Thu Apr 3 02:24:54 2008
@@ -0,0 +1,61 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
+<!--
+ 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.
+-->
+<html>
+<head>
+ <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
+ <script type="text/javascript">var xookiConfig = {level: 1};</script>
+ <script type="text/javascript" src="../xooki/xooki.js"></script>
+</head>
+<body>
+ <textarea id="xooki-source">
+<b>Tag:</b> override <b>Parent:</b> <a
href="../ivyfile/dependencies.html">dependencies</a><br/>
+<br/>
+<span class="since">(since 2.0)</span>
+
+Specify an override mediation rule, overriding the revision and/or branch
requested for a transitive dependency.
+
+This can be useful when a direct dependency is bringing a transitive
dependency for which you want to change the revision, without actually
declaring a dependency on it (because the module doesn't actually depend on it)
and without using conflict management for this purpose (maybe because there is
no conflict at all, or because you want to by pass conflict management for this
particular transitive dependency).
+
+Overriding is done before any else, in a phase called dependency descriptor
mediation. The transitive dependency then behave exactly as if it were declared
with the new value.
+
+Note that even though no attribute is required, it makes no sense to set no
attributes at all. It would mean that overriding is triggered for all
transitive dependencies, but doesn't override anything. Most of the time, at
least org or module should be set to override only a subset of transitive
dependencies, and at least branch or rev should be set to actually override
something.
+
+<h1>Attributes</h1>
+<table class="ivy-attributes">
+<thead>
+ <tr><th class="ivy-att">Attribute</th><th
class="ivy-att-desc">Description</th><th class="ivy-att-req">Required</th></tr>
+</thead>
+<tbody>
+ <tr><td>org</td><td>the name, or an expression matching the name of
organisation to which overriding should be applied (see matcher attribute
below)</td>
+ <td>No, defaults to * (match all)</td></tr>
+ <tr><td>module</td><td>the name, or an expression matching the name of
module to which overriding should be applied (see matcher attribute below)</td>
+ <td>No, defaults to * (match all)</td></tr>
+ <tr><td>branch</td><td>the branch to set for all the overriden dependency
descriptors</td>
+ <td>No, by default branch is not overriden</td></tr>
+ <tr><td>rev</td><td>the revision to set for all the overriden dependency
descriptors</td>
+ <td>No, by default revision is not overriden</td></tr>
+ <tr><td>matcher</td><td>the <a href="../concept.html#matcher">matcher</a>
to use to match the modules for which the conflict manager should be used</td>
+ <td>No, defaults to exact</td></tr>
+</tbody>
+</table>
+</textarea>
+<script type="text/javascript">xooki.postProcess();</script>
+</body>
+</html>
Propchange: ant/ivy/core/trunk/doc/ivyfile/override.html
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: ant/ivy/core/trunk/doc/ivyfile/override.html
------------------------------------------------------------------------------
svn:mime-type = text/plain
Modified: ant/ivy/core/trunk/doc/toc.json
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/doc/toc.json?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/doc/toc.json (original)
+++ ant/ivy/core/trunk/doc/toc.json Thu Apr 3 02:24:54 2008
@@ -546,6 +546,20 @@
"children": [
]
+ },
+ {
+ "id":"ivyfile/override",
+ "title":"override",
+ "children": [
+
+ ]
+ },
+ {
+ "id":"ivyfile/conflict",
+ "title":"conflict",
+ "children": [
+
+ ]
}
]
},
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/DefaultModuleDescriptor.java
Thu Apr 3 02:24:54 2008
@@ -36,8 +36,10 @@
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.core.module.id.ModuleRules;
import org.apache.ivy.core.module.status.StatusManager;
import org.apache.ivy.plugins.conflict.ConflictManager;
+import org.apache.ivy.plugins.matcher.MapMatcher;
import org.apache.ivy.plugins.matcher.MatcherHelper;
import org.apache.ivy.plugins.matcher.PatternMatcher;
import org.apache.ivy.plugins.namespace.NameSpaceHelper;
@@ -159,8 +161,9 @@
nmd.setDefault(md.isDefault());
if (md instanceof DefaultModuleDescriptor) {
DefaultModuleDescriptor dmd = (DefaultModuleDescriptor) md;
- nmd.conflictManagers.putAll(dmd.conflictManagers);
-
nmd.dependencyDescriptorMediators.putAll(dmd.dependencyDescriptorMediators);
+ nmd.conflictManagers = (ModuleRules) dmd.conflictManagers.clone();
+ nmd.dependencyDescriptorMediators =
+ (ModuleRules) dmd.dependencyDescriptorMediators.clone();
} else {
Message.warn(
"transformed module descriptor is not a default module
descriptor: "
@@ -199,10 +202,9 @@
private boolean isDefault = false;
- private Map conflictManagers = new LinkedHashMap(); // Map (ModuleId -> )
+ private ModuleRules conflictManagers = new ModuleRules();
- private Map/*<ModuleId, DependencyDescriptorMediator>*/
dependencyDescriptorMediators
- = new LinkedHashMap();
+ private ModuleRules dependencyDescriptorMediators = new ModuleRules();
private List licenses = new ArrayList(); // List(License)
@@ -438,21 +440,6 @@
isDefault = b;
}
- private static class ModuleIdMatcher {
- private PatternMatcher matcher;
-
- private ModuleId mid;
-
- public ModuleIdMatcher(PatternMatcher matcher, ModuleId mid) {
- this.matcher = matcher;
- this.mid = mid;
- }
-
- public boolean matches(ModuleId mid) {
- return MatcherHelper.matches(matcher, this.mid, mid);
- }
- }
-
/**
* regular expressions as explained in Pattern class may be used in
ModuleId organisation and
* name
@@ -463,33 +450,29 @@
*/
public void addConflictManager(ModuleId moduleId, PatternMatcher matcher,
ConflictManager manager) {
- conflictManagers.put(new ModuleIdMatcher(matcher, moduleId), manager);
+ conflictManagers.defineRule(new MapMatcher(moduleId.getAttributes(),
matcher), manager);
}
public ConflictManager getConflictManager(ModuleId moduleId) {
- for (Iterator iter = conflictManagers.keySet().iterator();
iter.hasNext();) {
- ModuleIdMatcher matcher = (ModuleIdMatcher) iter.next();
- if (matcher.matches(moduleId)) {
- return (ConflictManager) conflictManagers.get(matcher);
- }
- }
- return null;
+ return (ConflictManager) conflictManagers.getRule(moduleId);
}
public void addDependencyDescriptorMediator(ModuleId moduleId,
PatternMatcher matcher,
DependencyDescriptorMediator ddm) {
- dependencyDescriptorMediators.put(new ModuleIdMatcher(matcher,
moduleId), ddm);
+ dependencyDescriptorMediators.defineRule(
+ new MapMatcher(moduleId.getAttributes(), matcher), ddm);
}
public DependencyDescriptor mediate(DependencyDescriptor dd) {
- for (Iterator iter =
dependencyDescriptorMediators.keySet().iterator(); iter.hasNext();) {
- ModuleIdMatcher matcher = (ModuleIdMatcher) iter.next();
- if (matcher.matches(dd.getDependencyId())) {
- dd = ((DependencyDescriptorMediator)
dependencyDescriptorMediators.get(matcher))
- .mediate(dd);
- }
+ Object[] mediators =
dependencyDescriptorMediators.getRules(dd.getDependencyId());
+ for (int i = 0; i < mediators.length; i++) {
+ dd = ((DependencyDescriptorMediator) mediators[i]).mediate(dd);
}
return dd;
+ }
+
+ public ModuleRules/*<DependencyDescriptorMediator>*/
getAllDependencyDescriptorMediators() {
+ return (ModuleRules) dependencyDescriptorMediators.clone();
}
public void addLicense(License license) {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/descriptor/ModuleDescriptor.java
Thu Apr 3 02:24:54 2008
@@ -26,6 +26,7 @@
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.core.module.id.ModuleRules;
import org.apache.ivy.plugins.conflict.ConflictManager;
import org.apache.ivy.plugins.latest.ArtifactInfo;
import org.apache.ivy.plugins.parser.ModuleDescriptorParser;
@@ -222,6 +223,18 @@
* @return an array of [EMAIL PROTECTED] ExcludeRule} this module
descriptor holds
*/
public ExcludeRule[] getAllExcludeRules();
+
+ /**
+ * Returns all the dependency descriptor mediators used by this [EMAIL
PROTECTED] ModuleDescriptor}, as an
+ * instance of [EMAIL PROTECTED] ModuleRules}.
+ * <p>
+ * All rules in the [EMAIL PROTECTED] ModuleRules} object returned are
+ * [EMAIL PROTECTED] DependencyDescriptorMediator}.
+ * </p>
+ *
+ * @return all the dependency descriptor mediators used by this [EMAIL
PROTECTED] ModuleDescriptor}.
+ */
+ public ModuleRules/*<DependencyDescriptorMediator>*/
getAllDependencyDescriptorMediators();
/**
* Returns the list of xml namespaces used by extra attributes, as Map
from prefix to namespace
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleId.java Thu
Apr 3 02:24:54 2008
@@ -17,11 +17,14 @@
*/
package org.apache.ivy.core.module.id;
+import java.util.HashMap;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import org.apache.ivy.core.IvyPatternHelper;
+
/**
* Identifies a module, without revision information
*
@@ -70,6 +73,8 @@
private String name;
private int hash;
+
+ private Map/*<String, String>*/ attributes = new HashMap();
/**
* Constructor.
@@ -82,6 +87,8 @@
}
this.organisation = organisation;
this.name = name;
+ attributes.put(IvyPatternHelper.ORGANISATION_KEY, organisation);
+ attributes.put(IvyPatternHelper.MODULE_KEY, name);
}
/**
@@ -146,6 +153,17 @@
*/
public String encodeToString() {
return getOrganisation() + ENCODE_SEPARATOR + getName();
+ }
+
+ /**
+ * Returns a Map of all attributes of this module id.
+ * The Map keys are attribute names as Strings, and values are
corresponding attribute values
+ * (as String too).
+ *
+ * @return A Map instance containing all the attributes and their values.
+ */
+ public Map getAttributes() {
+ return attributes;
}
/**
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/core/module/id/ModuleRules.java
Thu Apr 3 02:24:54 2008
@@ -17,8 +17,11 @@
*/
package org.apache.ivy.core.module.id;
+import java.util.ArrayList;
+import java.util.Collections;
import java.util.Iterator;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
import org.apache.ivy.plugins.matcher.MapMatcher;
@@ -50,6 +53,16 @@
private Map/*<MapMatcher,Object>*/ rules = new LinkedHashMap();
/**
+ * Constructs an empty ModuleRules.
+ */
+ public ModuleRules() {
+ }
+
+ private ModuleRules(Map/*<MapMatcher,Object>*/ rules) {
+ this.rules = new LinkedHashMap(rules);
+ }
+
+ /**
* Defines a new rule for the given condition.
*
* @param condition
@@ -65,6 +78,34 @@
}
/**
+ * Returns the rule object matching the given [EMAIL PROTECTED] ModuleId},
or <code>null</code>
+ * if no rule applies.
+ *
+ * @param mid
+ * the [EMAIL PROTECTED] ModuleId} to search the rule for.
+ * Must not be <code>null</code>.
+ * @return the rule object matching the given [EMAIL PROTECTED] ModuleId},
or <code>null</code>
+ * if no rule applies.
+ * @see #getRule(ModuleId, Filter)
+ */
+ public Object getRule(ModuleId mid) {
+ return getRule(mid, NoFilter.INSTANCE);
+ }
+
+ /**
+ * Returns the rules objects matching the given [EMAIL PROTECTED]
ModuleId}, or an empty array
+ * if no rule applies.
+ *
+ * @param mid
+ * the [EMAIL PROTECTED] ModuleId} to search the rule for.
+ * Must not be <code>null</code>.
+ * @return an array of rule objects matching the given [EMAIL PROTECTED]
ModuleId}.
+ */
+ public Object[] getRules(ModuleId mid) {
+ return getRules(new ModuleRevisionId(mid, "", ""), NoFilter.INSTANCE);
+ }
+
+ /**
* Returns the rule object matching the given [EMAIL PROTECTED]
ModuleRevisionId}, or <code>null</code>
* if no rule applies.
*
@@ -133,6 +174,36 @@
}
/**
+ * Returns the rules object matching the given [EMAIL PROTECTED]
ModuleRevisionId} and accepted by the
+ * given [EMAIL PROTECTED] Filter}, or an empty array if no rule applies.
+ *
+ * @param mrid
+ * the [EMAIL PROTECTED] ModuleRevisionId} to search the rule
for.
+ * Must not be <code>null</code>.
+ * @param filter
+ * the filter to use to filter the rule to return. The [EMAIL
PROTECTED] Filter#accept(Object)}
+ * method will be called only with rule objects matching the
given
+ * [EMAIL PROTECTED] ModuleRevisionId}. Must not be
<code>null</code>.
+ * @return an array of rule objects matching the given [EMAIL PROTECTED]
ModuleRevisionId}.
+ */
+ public Object[] getRules(ModuleRevisionId mrid, Filter filter) {
+ Checks.checkNotNull(mrid, "mrid");
+ Checks.checkNotNull(filter, "filter");
+
+ List matchingRules = new ArrayList();
+ for (Iterator iter = rules.keySet().iterator(); iter.hasNext();) {
+ MapMatcher midm = (MapMatcher) iter.next();
+ if (midm.matches(mrid.getAttributes())) {
+ Object rule = rules.get(midm);
+ if (filter.accept(rule)) {
+ matchingRules.add(rule);
+ }
+ }
+ }
+ return matchingRules.toArray();
+ }
+
+ /**
* Dump the list of rules to [EMAIL PROTECTED] Message#debug(String)}
*
* @param prefix
@@ -149,5 +220,21 @@
}
}
}
+
+ /**
+ * Returns an unmodifiable view of all the rules defined on this
ModuleRules.
+ * <p>
+ * The rules are returned in a Map where they keys are the MapMatchers
matching the rules
+ * object, and the values are the rules object themselves.
+ * </p>
+ *
+ * @return an unmodifiable view of all the rules defined on this
ModuleRules.
+ */
+ public Map/*<MapMatcher,Object>*/ getAllRules() {
+ return Collections.unmodifiableMap(rules);
+ }
+ public Object clone() {
+ return new ModuleRules(rules);
+ }
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/matcher/MapMatcher.java
Thu Apr 3 02:24:54 2008
@@ -17,6 +17,7 @@
*/
package org.apache.ivy.plugins.matcher;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
@@ -54,5 +55,13 @@
public String toString() {
return attributes + " (" + pm.getName() + ")";
+ }
+
+ public Map getAttributes() {
+ return Collections.unmodifiableMap(attributes);
+ }
+
+ public PatternMatcher getPatternMatcher() {
+ return pm;
}
}
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorParser.java
Thu Apr 3 02:24:54 2008
@@ -185,8 +185,6 @@
private static final int EXTRA_INFO = 12;
- private static final int HINTS = 13;
-
private int state = NONE;
private final URL xmlURL;
@@ -307,20 +305,13 @@
}
state = CONFLICT;
checkConfigurations();
- } else if ("hints".equals(qName)) {
- state = HINTS;
} else if ("artifact".equals(qName)) {
artifactStarted(qName, attributes);
} else if ("include".equals(qName) && state == DEP) {
addIncludeRule(qName, attributes);
} else if ("exclude".equals(qName) && state == DEP) {
addExcludeRule(qName, attributes);
- } else if ("exclude".equals(qName) && (state == DEPS || state
== HINTS)) {
- if (state == DEPS) {
- Message.deprecated(
- "using exclude directly under dependencies is
deprecated: "
- + "please use hints section. Ivy file URL: " +
xmlURL);
- }
+ } else if ("exclude".equals(qName) && state == DEPS) {
state = EXCLUDE;
parseRule(qName, attributes);
getMd().addExcludeRule((ExcludeRule) confAware);
@@ -331,10 +322,10 @@
} else if ("mapped".equals(qName)) {
dd.addDependencyConfiguration(conf,
ivy.substitute(attributes
.getValue("name")));
- } else if (("conflict".equals(qName) && state == HINTS)
+ } else if (("conflict".equals(qName) && state == DEPS)
|| "manager".equals(qName) && state == CONFLICT) {
managerStarted(attributes, state == CONFLICT ? "name" :
"manager");
- } else if ("override".equals(qName) && state == HINTS) {
+ } else if ("override".equals(qName) && state == DEPS) {
mediationOverrideStarted(attributes);
} else if ("include".equals(qName) && state == CONF) {
includeConfStarted(attributes);
@@ -808,8 +799,6 @@
}
}
confAware = null;
- state = HINTS;
- } else if ("hints".equals(qName) && state == HINTS) {
state = DEPS;
} else if ("dependency".equals(qName) && state == DEP) {
if (dd.getModuleConfigurations().length == 0) {
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/XmlModuleDescriptorWriter.java
Thu Apr 3 02:24:54 2008
@@ -28,14 +28,19 @@
import java.util.Map.Entry;
import org.apache.ivy.Ivy;
+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.DependencyArtifactDescriptor;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
+import org.apache.ivy.core.module.descriptor.DependencyDescriptorMediator;
import org.apache.ivy.core.module.descriptor.ExcludeRule;
import org.apache.ivy.core.module.descriptor.IncludeRule;
import org.apache.ivy.core.module.descriptor.ModuleDescriptor;
+import
org.apache.ivy.core.module.descriptor.OverrideDependencyDescriptorMediator;
+import org.apache.ivy.plugins.matcher.MapMatcher;
+import org.apache.ivy.util.Message;
import org.apache.ivy.util.XMLHelper;
import org.apache.ivy.util.extendable.ExtendableItem;
@@ -150,23 +155,55 @@
out.println("\t\t</dependency>");
}
}
- boolean hasHints = md.getAllExcludeRules().length > 0;
- if (hasHints) {
- out.println("\t\t<hints>");
- }
printAllExcludes(md, out);
- if (hasHints) {
- out.println("\t\t</hints>");
- }
+ printAllMediators(md, out);
out.println("\t</dependencies>");
}
}
+ private static void printAllMediators(ModuleDescriptor md, PrintWriter
out) {
+ Map/*<MapMatcher, DependencyDescriptorMediator>*/ mediators
+ = md.getAllDependencyDescriptorMediators().getAllRules();
+
+ for (Iterator iterator = mediators.entrySet().iterator();
iterator.hasNext();) {
+ Map.Entry mediatorRule = (Map.Entry) iterator.next();
+ MapMatcher matcher = (MapMatcher) mediatorRule.getKey();
+ DependencyDescriptorMediator mediator =
+ (DependencyDescriptorMediator) mediatorRule.getValue();
+
+ if (mediator instanceof OverrideDependencyDescriptorMediator) {
+ OverrideDependencyDescriptorMediator oddm =
+ (OverrideDependencyDescriptorMediator) mediator;
+
+ out.print("\t\t<override");
+ out.print(" org=\"" + XMLHelper.escape(
+ (String)
matcher.getAttributes().get(IvyPatternHelper.ORGANISATION_KEY))
+ + "\"");
+ out.print(" module=\"" + XMLHelper.escape(
+ (String)
matcher.getAttributes().get(IvyPatternHelper.MODULE_KEY))
+ + "\"");
+ out.print(" matcher=\"" + XMLHelper.escape(
+ matcher.getPatternMatcher().getName())
+ + "\"");
+ if (oddm.getBranch() != null) {
+ out.print(" branch=\"" +
XMLHelper.escape(oddm.getBranch()) + "\"");
+ }
+ if (oddm.getVersion() != null) {
+ out.print(" rev=\"" + XMLHelper.escape(oddm.getVersion())
+ "\"");
+ }
+ out.println("/>");
+ } else {
+ Message.verbose("ignoring unhandled
DependencyDescriptorMediator: "
+ + mediator.getClass());
+ }
+ }
+ }
+
private static void printAllExcludes(ModuleDescriptor md, PrintWriter out)
{
ExcludeRule[] excludes = md.getAllExcludeRules();
if (excludes.length > 0) {
for (int j = 0; j < excludes.length; j++) {
- out.print("\t\t\t<exclude");
+ out.print("\t\t<exclude");
out.print(" org=\""
+
XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation())
+ "\"");
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd
(original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/plugins/parser/xml/ivy.xsd Thu
Apr 3 02:24:54 2008
@@ -229,31 +229,24 @@
</xs:complexType>
</xs:element>
<xs:element name="exclude"
type="global-exclude" minOccurs="0" maxOccurs="unbounded" />
- <xs:element name="hints"
minOccurs="0">
- <xs:complexType>
-
<xs:sequence>
-
<xs:element name="exclude" type="global-exclude" minOccurs="0"
maxOccurs="unbounded" />
-
<xs:element name="conflict" minOccurs="0" maxOccurs="unbounded">
-
<xs:complexType>
-
<xs:attribute name="org" type="xs:string"/>
-
<xs:attribute name="module" type="xs:string"/>
-
<xs:attribute name="manager" type="xs:string"/>
-
<xs:attribute name="rev" type="xs:string"/>
-
<xs:attribute name="matcher" type="xs:string"/>
-
<xs:anyAttribute namespace="##other" processContents="lax"
/>
-
</xs:complexType>
-
</xs:element>
-
<xs:element name="override" minOccurs="0" maxOccurs="unbounded">
-
<xs:complexType>
-
<xs:attribute name="org" type="xs:string"/>
-
<xs:attribute name="module" type="xs:string"/>
-
<xs:attribute name="matcher" type="xs:string"/>
-
<xs:attribute name="rev" type="xs:string"/>
-
<xs:attribute name="branch" type="xs:string"/>
-
</xs:complexType>
-
</xs:element>
-
</xs:sequence>
- </xs:complexType>
+ <xs:element name="override"
minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute
name="org" type="xs:string"/>
+ <xs:attribute
name="module" type="xs:string"/>
+ <xs:attribute
name="matcher" type="xs:string"/>
+ <xs:attribute
name="rev" type="xs:string"/>
+ <xs:attribute
name="branch" type="xs:string"/>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="conflict"
minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute
name="org" type="xs:string"/>
+ <xs:attribute
name="module" type="xs:string"/>
+ <xs:attribute
name="manager" type="xs:string"/>
+ <xs:attribute
name="rev" type="xs:string"/>
+ <xs:attribute
name="matcher" type="xs:string"/>
+ <xs:anyAttribute
namespace="##other" processContents="lax" />
+ </xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute
name="defaultconf" type="xs:string"/>
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-withvar.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-withvar.xml?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-withvar.xml
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update-withvar.xml
Thu Apr 3 02:24:54 2008
@@ -101,12 +101,10 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1"
conf="*->@"/>
- <hints>
- <exclude module="${excludemodule}"
matcher="${excludematcher}" conf="${myvar}"/>
- <exclude org="${excludeorg}" module="test"
artifact="${excludeartifact}" type="${excludetype}" ext="jar"/>
- <conflict org="${yourorg}" module="${yourmodule}"
matcher="${regexp}" manager="${all}"/>
- <conflict org="theirorg" module="theirmodule1"
rev="${theirrev}"/>
- <override org="yourorg" module=".*1" matcher="regexp"
branch="BRANCH" rev="1.0"/>
- </hints>
+ <exclude module="${excludemodule}" matcher="${excludematcher}"
conf="${myvar}"/>
+ <exclude org="${excludeorg}" module="test"
artifact="${excludeartifact}" type="${excludetype}" ext="jar"/>
+ <override org="yourorg" module=".*1" matcher="regexp" branch="BRANCH"
rev="1.0"/>
+ <conflict org="${yourorg}" module="${yourmodule}"
matcher="${regexp}" manager="${all}"/>
+ <conflict org="theirorg" module="theirmodule1"
rev="${theirrev}"/>
</dependencies>
</ivy-module>
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update.xml?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update.xml
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-update.xml
Thu Apr 3 02:24:54 2008
@@ -101,12 +101,10 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1"
conf="*->@"/>
- <hints>
- <exclude module="*servlet*" matcher="glob"
conf="myconf1"/>
- <exclude org="acme" module="test" artifact="test"
type="source" ext="jar"/>
- <conflict org="yourorg" module=".*" matcher="regexp"
manager="all"/>
- <conflict org="theirorg" module="theirmodule1"
rev="1.0, 1.1"/>
- <override org="yourorg" module=".*1" matcher="regexp"
branch="BRANCH" rev="1.0"/>
- </hints>
+ <exclude module="*servlet*" matcher="glob" conf="myconf1" />
+ <exclude org="acme" module="test" artifact="test" type="source"
ext="jar" />
+ <override org="yourorg" module=".*1" matcher="regexp" branch="BRANCH"
rev="1.0" />
+ <conflict org="yourorg" module=".*" matcher="regexp"
manager="all" />
+ <conflict org="theirorg" module="theirmodule1" rev="1.0, 1.1"/>
</dependencies>
</ivy-module>
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-write-full.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-write-full.xml?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-write-full.xml
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test-write-full.xml
Thu Apr 3 02:24:54 2008
@@ -64,9 +64,8 @@
<exclude org="*" module="*" name="toexclude" type="*"
ext="*" matcher="exact"/>
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1"
conf="*->*"/>
- <hints>
- <exclude org="*" module="*servlet*" artifact="*"
type="*" ext="*" conf="myconf1" matcher="glob"/>
- <exclude org="acme" module="test" artifact="test"
type="source" ext="jar" matcher="exact"/>
- </hints>
+ <exclude org="*" module="*servlet*" artifact="*" type="*"
ext="*" conf="myconf1" matcher="glob"/>
+ <exclude org="acme" module="test" artifact="test" type="source"
ext="jar" matcher="exact"/>
+ <override org="yourorg" module=".*1" matcher="regexp"
branch="BRANCH" rev="1.0"/>
</dependencies>
</ivy-module>
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/test.xml Thu
Apr 3 02:24:54 2008
@@ -99,12 +99,10 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1"
conf="*->@"/>
- <hints>
- <exclude module="*servlet*" matcher="glob"
conf="myconf1" />
- <exclude org="acme" module="test" artifact="test"
type="source" ext="jar" />
- <conflict org="yourorg" module=".*" matcher="regexp"
manager="all" />
- <conflict org="theirorg" module="theirmodule1"
rev="1.0, 1.1"/>
- <override org="yourorg" module=".*1" matcher="regexp"
branch="BRANCH" rev="1.0" />
- </hints>
+ <exclude module="*servlet*" matcher="glob" conf="myconf1" />
+ <exclude org="acme" module="test" artifact="test" type="source"
ext="jar" />
+ <override org="yourorg" module=".*1" matcher="regexp" branch="BRANCH"
rev="1.0" />
+ <conflict org="yourorg" module=".*" matcher="regexp"
manager="all" />
+ <conflict org="theirorg" module="theirmodule1" rev="1.0, 1.1"/>
</dependencies>
</ivy-module>
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/updated.xml?rev=644236&r1=644235&r2=644236&view=diff
==============================================================================
--- ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
(original)
+++ ant/ivy/core/trunk/test/java/org/apache/ivy/plugins/parser/xml/updated.xml
Thu Apr 3 02:24:54 2008
@@ -97,12 +97,10 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1"
conf="*->@"/>
- <hints>
- <exclude module="*servlet*" matcher="glob"
conf="myconf1"/>
- <exclude org="acme" module="test" artifact="test"
type="source" ext="jar"/>
- <conflict org="yourorg" module=".*" matcher="regexp"
manager="all"/>
- <conflict org="theirorg" module="theirmodule1"
rev="1.0, 1.1"/>
- <override org="yourorg" module=".*1" matcher="regexp"
branch="BRANCH" rev="1.0"/>
- </hints>
+ <exclude module="*servlet*" matcher="glob" conf="myconf1"/>
+ <exclude org="acme" module="test" artifact="test" type="source"
ext="jar"/>
+ <override org="yourorg" module=".*1" matcher="regexp" branch="BRANCH"
rev="1.0"/>
+ <conflict org="yourorg" module=".*" matcher="regexp"
manager="all"/>
+ <conflict org="theirorg" module="theirmodule1" rev="1.0, 1.1"/>
</dependencies>
</ivy-module>