Author: xavier
Date: Wed Jul 9 00:45:23 2008
New Revision: 675108
URL: http://svn.apache.org/viewvc?rev=675108&view=rev
Log:
FIX: Referenced resolver not found in macro (IVY-860)
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro+ref2.xml
(with props)
Modified:
ant/ivy/core/trunk/CHANGES.txt
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
Modified: ant/ivy/core/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/CHANGES.txt?rev=675108&r1=675107&r2=675108&view=diff
==============================================================================
--- ant/ivy/core/trunk/CHANGES.txt (original)
+++ ant/ivy/core/trunk/CHANGES.txt Wed Jul 9 00:45:23 2008
@@ -95,6 +95,7 @@
- IMPROVEMENT: Change allownomd and skipbuildwithoutivy into a more
semantically correct name (IVY-297)
- IMPROVEMENT: Smarter determination if an expression is exact or not for
RegexpPatternMatcher and GlobPatternMatcher
+- FIX: Referenced resolver not found in macro (IVY-860)
- FIX: Ivy files are not retrieved when using useOrigin=true (IVY-713)
- FIX: NPE in Ivy:install task if the repository cache dir has been cleared
(IVY-843)
- FIX: Maven version ranges with ( ) are not supported (IVY-678) (thanks to
Michael Kebe)
Modified:
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java?rev=675108&r1=675107&r2=675108&view=diff
==============================================================================
---
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
(original)
+++
ant/ivy/core/trunk/src/java/org/apache/ivy/core/settings/XmlSettingsParser.java
Wed Jul 9 00:45:23 2008
@@ -471,8 +471,7 @@
String name = (String) attributes.get("name");
if (name == null) {
attributes.put("name", "@{name}");
- } else if (configurator.isTopLevelMacroRecord()
- && name.indexOf("@{name}") != -1) {
+ } else if (name.indexOf("@{name}") != -1) {
attributes.put("name", name);
} else {
attributes.put("name", "@{name}-" + name);
@@ -486,7 +485,7 @@
}
String name = (String) attributes.get("ref");
Object child = null;
- if ("resolvers".equals(currentConfiguratorTag)) {
+ if ("resolvers".equals(currentConfiguratorTag) ||
"resolver".equals(qName)) {
child = ivy.getResolver(name);
if (child == null) {
throw new IllegalArgumentException("unknown resolver " +
name
Modified: ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java?rev=675108&r1=675107&r2=675108&view=diff
==============================================================================
--- ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java (original)
+++ ant/ivy/core/trunk/src/java/org/apache/ivy/util/Configurator.java Wed Jul
9 00:45:23 2008
@@ -142,6 +142,8 @@
private List children = new ArrayList();
+ private Object object;
+
public MacroRecord(String name) {
this.name = name;
}
@@ -159,6 +161,12 @@
children.add(child);
return child;
}
+
+ public MacroRecord recordChild(String name, Object object) {
+ MacroRecord child = recordChild(name);
+ child.object = object;
+ return child;
+ }
public Map getAttributes() {
return attributes;
@@ -167,6 +175,10 @@
public List getChildren() {
return children;
}
+
+ public Object getObject() {
+ return object;
+ }
}
public static class MacroDef {
@@ -204,6 +216,12 @@
private Object play(Configurator conf, MacroRecord macroRecord, Map
attValues,
Map childrenRecords) {
+ if (macroRecord.getObject() != null) {
+ // this is a recorded reference, we can add the referenced
object directly
+ conf.addChild(macroRecord.getName(), macroRecord.getObject());
+ conf.endCreateChild();
+ return macroRecord.getObject();
+ }
conf.startCreateChild(macroRecord.getName());
Map attributes = macroRecord.getAttributes();
for (Iterator iter = attributes.keySet().iterator();
iter.hasNext();) {
@@ -541,8 +559,13 @@
private Object addChild(ObjectDescriptor parentOD, Class childClass,
String name, Object child)
throws InstantiationException, IllegalAccessException,
InvocationTargetException {
Object parent = parentOD.getObject();
- Method addChild;
- addChild = parentOD.getAddMethod(childClass);
+ if (parent instanceof MacroRecord) {
+ MacroRecord record = (MacroRecord) parent;
+ MacroRecord recordChild = record.recordChild(name, child);
+ setCurrent(recordChild, name);
+ return recordChild;
+ }
+ Method addChild = parentOD.getAddMethod(childClass);
if (addChild != null) {
if (child == null) {
child = childClass.newInstance();
Modified:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java?rev=675108&r1=675107&r2=675108&view=diff
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
(original)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/XmlSettingsParserTest.java
Wed Jul 9 00:45:23 2008
@@ -41,6 +41,7 @@
import org.apache.ivy.plugins.resolver.ChainResolver;
import org.apache.ivy.plugins.resolver.DependencyResolver;
import org.apache.ivy.plugins.resolver.FileSystemResolver;
+import org.apache.ivy.plugins.resolver.IBiblioResolver;
import org.apache.ivy.plugins.resolver.MockResolver;
import org.apache.ivy.plugins.version.ChainVersionMatcher;
import org.apache.ivy.plugins.version.MockVersionMatcher;
@@ -383,6 +384,27 @@
assertTrue(shared instanceof FileSystemResolver);
}
+ public void testMacroAndRef2() throws Exception {
+ // test case for IVY-860
+ IvySettings settings = new IvySettings();
+ XmlSettingsParser parser = new XmlSettingsParser(settings);
+
parser.parse(XmlSettingsParserTest.class.getResource("ivysettings-macro+ref2.xml"));
+
+ DependencyResolver macrores = settings.getResolver("macroresolver");
+ assertNotNull(macrores);
+ assertTrue(macrores instanceof ChainResolver);
+
+ DependencyResolver testResolver = settings.getResolver("test");
+ assertNotNull(testResolver);
+ assertTrue(testResolver instanceof IBiblioResolver);
+
+ ChainResolver chain = (ChainResolver) macrores;
+ List subresolvers = chain.getResolvers();
+ assertNotNull(subresolvers);
+ assertEquals(1, subresolvers.size());
+ assertEquals(testResolver, subresolvers.get(0));
+ }
+
public void testInclude() throws Exception {
IvySettings settings = new IvySettings();
XmlSettingsParser parser = new XmlSettingsParser(settings);
Added:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro+ref2.xml
URL:
http://svn.apache.org/viewvc/ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro%2Bref2.xml?rev=675108&view=auto
==============================================================================
---
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro+ref2.xml
(added)
+++
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro+ref2.xml
Wed Jul 9 00:45:23 2008
@@ -0,0 +1,32 @@
+<!--
+ 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.
+-->
+<ivysettings>
+ <resolvers>
+ <ibiblio name="test"/>
+ </resolvers>
+ <macrodef name="myresolver">
+ <attribute name="name"/>
+ <chain>
+ <resolver ref="test" />
+ </chain>
+ </macrodef>
+ <resolvers>
+ <myresolver name="macroresolver"/>
+ </resolvers>
+</ivysettings>
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro+ref2.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
ant/ivy/core/trunk/test/java/org/apache/ivy/core/settings/ivysettings-macro+ref2.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain