Browse Source

* <macrodef> with redefined default values was incorrect. (Fix for

31215 had a bug). Bugzilla report 35109.
PR: 35109


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@278376 13f79535-47bb-0310-9956-ffa450edef68
master
Peter Reilly 20 years ago
parent
commit
2a816a5361
4 changed files with 63 additions and 4 deletions
  1. +15
    -0
      WHATSNEW
  2. +17
    -0
      src/etc/testcases/taskdefs/macrodef.xml
  3. +26
    -4
      src/main/org/apache/tools/ant/taskdefs/MacroDef.java
  4. +5
    -0
      src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java

+ 15
- 0
WHATSNEW View File

@@ -233,6 +233,21 @@ Other changes:
* Try to make subprojects of custom Project subclasses instances of the
same type. Bugzilla report 17901.

Changes from Ant 1.6.4 to current Ant 1.6 CVS version
=====================================================

Changes that could break older environments:
--------------------------------------------

Fixed bugs:
-----------

* <move> was unable to replace existing files or write into
existing directories. Bugzilla report 34962.

* <macrodef> with redefined default values was incorrect. (Fix for
31215 had a bug). Bugzilla report 35109.

Changes from Ant 1.6.3 to Ant 1.6.4
===================================



+ 17
- 0
src/etc/testcases/taskdefs/macrodef.xml View File

@@ -220,7 +220,24 @@
<explicit/>
</sequential>
</macrodef>
</target>

<property name="default.override" value="old"/>
<macrodef name="simple.override">
<attribute name="attr" default="${default.override}"/>
<sequential>
<echo>value is @{attr}</echo>
</sequential>
</macrodef>

<target name="override.default">
<antcall target="override.call">
<param name="default.override" value="new"/>
</antcall>
</target>

<target name="override.call">
<simple.override/>
</target>

<target name="backtraceoff">


+ 26
- 4
src/main/org/apache/tools/ant/taskdefs/MacroDef.java View File

@@ -715,13 +715,14 @@ public class MacroDef extends AntlibDefinition {
}

/**
* similar equality method for macrodef, ignores project and
* same or similar equality method for macrodef, ignores project and
* runtime info.
*
* @param obj an <code>Object</code> value
* @param same if true test for sameness, otherwise just similiar
* @return a <code>boolean</code> value
*/
public boolean similar(Object obj) {
private boolean sameOrSimilar(Object obj, boolean same) {
if (obj == this) {
return true;
}
@@ -742,7 +743,8 @@ public class MacroDef extends AntlibDefinition {
// Allow two macro definitions with the same location
// to be treated as similar - bugzilla 31215
if (other.getLocation() != null
&& other.getLocation().equals(getLocation())) {
&& other.getLocation().equals(getLocation())
&& !same) {
return true;
}
if (text == null) {
@@ -778,6 +780,26 @@ public class MacroDef extends AntlibDefinition {
return true;
}

/**
* Similar method for this definition
*
* @param obj another definition
* @return true if the definitions are similar
*/
public boolean similar(Object obj) {
return sameOrSimilar(obj, false);
}

/**
* Equality method for this definition
*
* @param obj another definition
* @return true if the definitions are the same
*/
public boolean sameDefinition(Object obj) {
return sameOrSimilar(obj, true);
}

/**
* extends AntTypeDefinition, on create
* of the object, the template macro definition
@@ -822,7 +844,7 @@ public class MacroDef extends AntlibDefinition {
return false;
}
MyAntTypeDefinition otherDef = (MyAntTypeDefinition) other;
return macroDef.similar(otherDef.macroDef);
return macroDef.sameDefinition(otherDef.macroDef);
}

/**


+ 5
- 0
src/testcases/org/apache/tools/ant/taskdefs/MacroDefTest.java View File

@@ -109,6 +109,11 @@ public class MacroDefTest extends BuildFileTest {
"attribute.description",
"description is hello world");
}
public void testOverrideDefault() {
expectLog(
"override.default",
"value is new");
}
public void testImplicit() {
expectLog(
"implicit", "Before implicitIn implicitAfter implicit");


Loading…
Cancel
Save