You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by xa...@apache.org on 2008/03/28 17:19:26 UTC
svn commit: r642277 - in /ant/ivy/core/trunk:
src/java/org/apache/ivy/plugins/parser/xml/
test/java/org/apache/ivy/plugins/parser/xml/
Author: xavier
Date: Fri Mar 28 09:19:23 2008
New Revision: 642277
URL: http://svn.apache.org/viewvc?rev=642277&view=rev
Log:
introduce hints section in dependencies, as discussed on mailing list (part of IVY-784)
still need to update documentation, and update XmlModuleDescriptorWriter to be able to write overrides
Modified:
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/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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -185,15 +185,15 @@
private static final int EXTRA_INFO = 12;
- private static final int ENGINE_HINTS = 13;
-
- private static final int MEDIATION = 14;
+ private static final int HINTS = 13;
private int state = NONE;
private final URL xmlURL;
private StringBuffer buffer;
+
+ private String descriptorVersion;
@@ -301,20 +301,26 @@
} else if ("dependencies".equals(qName)) {
dependenciesStarted(attributes);
} else if ("conflicts".equals(qName)) {
+ if (!descriptorVersion.startsWith("1.")) {
+ Message.deprecated("using conflicts section is deprecated: "
+ + "please use hints section instead. Ivy file URL: " + xmlURL);
+ }
state = CONFLICT;
checkConfigurations();
- } else if ("engine-hints".equals(qName)) {
- state = ENGINE_HINTS;
- checkConfigurations();
- } else if ("mediation".equals(qName)) {
- state = MEDIATION;
+ } 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) {
+ } 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);
+ }
state = EXCLUDE;
parseRule(qName, attributes);
getMd().addExcludeRule((ExcludeRule) confAware);
@@ -325,9 +331,10 @@
} else if ("mapped".equals(qName)) {
dd.addDependencyConfiguration(conf, ivy.substitute(attributes
.getValue("name")));
- } else if ("manager".equals(qName) && state == CONFLICT) {
- managerStarted(attributes);
- } else if ("override".equals(qName) && state == MEDIATION) {
+ } else if (("conflict".equals(qName) && state == HINTS)
+ || "manager".equals(qName) && state == CONFLICT) {
+ managerStarted(attributes, state == CONFLICT ? "name" : "manager");
+ } else if ("override".equals(qName) && state == HINTS) {
mediationOverrideStarted(attributes);
} else if ("include".equals(qName) && state == CONF) {
includeConfStarted(attributes);
@@ -347,13 +354,13 @@
return qName.indexOf(':') != -1;
}
- private void managerStarted(Attributes attributes) {
+ private void managerStarted(Attributes attributes, String managerAtt) {
String org = ivy.substitute(attributes.getValue("org"));
org = org == null ? PatternMatcher.ANY_EXPRESSION : org;
String mod = ivy.substitute(attributes.getValue("module"));
mod = mod == null ? PatternMatcher.ANY_EXPRESSION : mod;
ConflictManager cm;
- String name = ivy.substitute(attributes.getValue("name"));
+ String name = ivy.substitute(attributes.getValue(managerAtt));
String rev = ivy.substitute(attributes.getValue("rev"));
if (rev != null) {
String[] revs = rev.split(",");
@@ -368,7 +375,7 @@
return;
}
} else {
- addError("bad conflict manager: no name nor rev");
+ addError("bad conflict manager: no manager nor rev");
return;
}
String matcherName = ivy.substitute(attributes.getValue("matcher"));
@@ -631,11 +638,11 @@
}
private void ivyModuleStarted(Attributes attributes) throws SAXException {
- String version = attributes.getValue("version");
- int versionIndex = ALLOWED_VERSIONS.indexOf(version);
+ descriptorVersion = attributes.getValue("version");
+ int versionIndex = ALLOWED_VERSIONS.indexOf(descriptorVersion);
if (versionIndex == -1) {
- addError("invalid version " + version);
- throw new SAXException("invalid version " + version);
+ addError("invalid version " + descriptorVersion);
+ throw new SAXException("invalid version " + descriptorVersion);
}
if (versionIndex >= ALLOWED_VERSIONS.indexOf("1.3")) {
Message.debug("post 1.3 ivy file: using " + PatternMatcher.EXACT
@@ -793,7 +800,7 @@
}
}
confAware = null;
- } else if (state == EXCLUDE) {
+ } else if ("exclude".equals(qName) && state == EXCLUDE) {
if (confAware.getConfigurations().length == 0) {
String[] confs = getMd().getConfigurationsNames();
for (int i = 0; i < confs.length; i++) {
@@ -801,6 +808,8 @@
}
}
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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -150,7 +150,15 @@
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>");
+ }
+ out.println("\t</dependencies>");
}
}
@@ -158,7 +166,7 @@
ExcludeRule[] excludes = md.getAllExcludeRules();
if (excludes.length > 0) {
for (int j = 0; j < excludes.length; j++) {
- out.print("\t\t<exclude");
+ out.print("\t\t\t<exclude");
out.print(" org=\""
+ XMLHelper.escape(excludes[j].getId().getModuleId().getOrganisation())
+ "\"");
@@ -185,7 +193,6 @@
out.println("/>");
}
}
- out.println("\t</dependencies>");
}
private static void printDependencyExcludeRules(ModuleDescriptor md, PrintWriter out,
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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -36,6 +36,24 @@
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
+ <xs:complexType name="global-exclude">
+ <xs:sequence>
+ <xs:element name="conf" minOccurs="0" maxOccurs="unbounded">
+ <xs:complexType>
+ <xs:attribute name="name" type="xs:string" use="required"/>
+ </xs:complexType>
+ </xs:element>
+ </xs:sequence>
+ <xs:attribute name="org" type="xs:string"/>
+ <xs:attribute name="module" type="xs:string"/>
+ <xs:attribute name="artifact" type="xs:string"/>
+ <xs:attribute name="type" type="xs:string"/>
+ <xs:attribute name="ext" type="xs:string"/>
+ <xs:attribute name="conf" type="xs:string"/>
+ <xs:attribute name="matcher" type="xs:string"/>
+ <xs:anyAttribute namespace="##other" processContents="lax" />
+ </xs:complexType>
+
<xs:element name="ivy-module">
<xs:complexType>
<xs:sequence>
@@ -210,24 +228,32 @@
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
</xs:element>
- <xs:element name="exclude" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="conf" minOccurs="0" maxOccurs="unbounded">
- <xs:complexType>
- <xs:attribute name="name" type="xs:string" use="required"/>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- <xs:attribute name="org" type="xs:string"/>
- <xs:attribute name="module" type="xs:string"/>
- <xs:attribute name="artifact" type="xs:string"/>
- <xs:attribute name="type" type="xs:string"/>
- <xs:attribute name="ext" type="xs:string"/>
- <xs:attribute name="conf" type="xs:string"/>
- <xs:attribute name="matcher" type="xs:string"/>
- <xs:anyAttribute namespace="##other" processContents="lax" />
- </xs:complexType>
+ <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>
</xs:sequence>
<xs:attribute name="defaultconf" type="xs:string"/>
@@ -247,27 +273,6 @@
<xs:attribute name="matcher" type="xs:string"/>
<xs:anyAttribute namespace="##other" processContents="lax" />
</xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- <xs:element name="engine" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="mediation" minOccurs="0">
- <xs:complexType>
- <xs:sequence>
- <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>
</xs:sequence>
</xs:complexType>
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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -101,11 +101,12 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1" conf="*->@"/>
- <exclude module="${excludemodule}" matcher="${excludematcher}" conf="${myvar}" />
- <exclude org="${excludeorg}" module="test" artifact="${excludeartifact}" type="${excludetype}" ext="jar" />
+ <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>
</dependencies>
- <conflicts>
- <manager org="${yourorg}" module="${yourmodule}" name="${all}" matcher="${regexp}"/>
- <manager org="theirorg" module="theirmodule1" rev="${theirrev}"/>
- </conflicts>
</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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -101,11 +101,12 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1" conf="*->@"/>
- <exclude module="*servlet*" matcher="glob" conf="myconf1" />
- <exclude org="acme" module="test" artifact="test" type="source" ext="jar" />
+ <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>
</dependencies>
- <conflicts>
- <manager org="yourorg" module=".*" name="all" matcher="regexp"/>
- <manager org="theirorg" module="theirmodule1" rev="1.0, 1.1"/>
- </conflicts>
</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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -64,7 +64,9 @@
<exclude org="*" module="*" name="toexclude" type="*" ext="*" matcher="exact"/>
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1" conf="*->*"/>
- <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"/>
+ </hints>
</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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -99,16 +99,12 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1" conf="*->@"/>
- <exclude module="*servlet*" matcher="glob" conf="myconf1" />
- <exclude org="acme" module="test" artifact="test" type="source" ext="jar" />
- </dependencies>
- <conflicts>
- <manager org="yourorg" module=".*" name="all" matcher="regexp"/>
- <manager org="theirorg" module="theirmodule1" rev="1.0, 1.1"/>
- </conflicts>
- <engine-hints>
- <mediation>
+ <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" />
- </mediation>
- </engine-hints>
+ </hints>
+ </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=642277&r1=642276&r2=642277&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 Fri Mar 28 09:19:23 2008
@@ -97,11 +97,12 @@
</dependency>
<dependency org="yourorg" name="yourmodule11" rev="11.1" conf="*->@"/>
- <exclude module="*servlet*" matcher="glob" conf="myconf1"/>
- <exclude org="acme" module="test" artifact="test" type="source" ext="jar"/>
+ <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>
</dependencies>
- <conflicts>
- <manager org="yourorg" module=".*" name="all" matcher="regexp"/>
- <manager org="theirorg" module="theirmodule1" rev="1.0, 1.1"/>
- </conflicts>
</ivy-module>