Browse Source

make sure Project#createTask has read defaults.properties. PR 50788

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@1240669 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 13 years ago
parent
commit
6aa0a70ff7
3 changed files with 63 additions and 1 deletions
  1. +5
    -1
      WHATSNEW
  2. +8
    -0
      src/main/org/apache/tools/ant/ComponentHelper.java
  3. +50
    -0
      src/tests/antunit/core/createtask-test.xml

+ 5
- 1
WHATSNEW View File

@@ -123,7 +123,11 @@ Fixed bugs:
fields rather than UTF-8 filenames and the EFS-Flag. fields rather than UTF-8 filenames and the EFS-Flag.


* Access to DirectoryScanner's default excludes wasn't synchronized. * Access to DirectoryScanner's default excludes wasn't synchronized.
BigZilla Report 52188.
Bugzilla Report 52188.

* When a Project instance was created by a custom tasks its
createTask method didn't work.
Bugzilla Report 50788.


Other changes: Other changes:
-------------- --------------


+ 8
- 0
src/main/org/apache/tools/ant/ComponentHelper.java View File

@@ -855,6 +855,14 @@ public class ComponentHelper {
return; // Already processed return; // Already processed
} }
checkedNamespaces.add(uri); checkedNamespaces.add(uri);

if (antTypeTable.size() == 0) {
// Project instance doesn't know the tasks and types
// defined in defaults.properties, likely created by the
// user - without those definitions it cannot parse antlib
// files as taskdef, typedef and friends are unknown
initDefaultDefinitions();
}
Typedef definer = new Typedef(); Typedef definer = new Typedef();
definer.setProject(project); definer.setProject(project);
definer.init(); definer.init();


+ 50
- 0
src/tests/antunit/core/createtask-test.xml View File

@@ -0,0 +1,50 @@
<?xml version="1.0"?>
<!--
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.
-->
<project xmlns:au="antlib:org.apache.ant.antunit" default="antunit">

<import file="../antunit-base.xml"/>

<target name="setUp">
<mkdir dir="${input}"/>
<mkdir dir="${output}"/>
</target>

<target name="-create-task" depends="setUp">
<mkdir dir="${input}/org/apache/ant/example"/>
<echo file="${input}/org/apache/ant/example/Foo.java"><![CDATA[
package org.apache.ant.example;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
public class Foo extends Task {
public void execute() {
new Project().createTask("Delete");
}
}
]]></echo>
<javac srcdir="${input}" destdir="${output}"/>
<taskdef name="foo" classname="org.apache.ant.example.Foo">
<classpath location="${output}"/>
</taskdef>
</target>

<target name="testCreateTaskInFreshProject"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=50788"
depends="-create-task">
<foo/>
</target>
</project>

Loading…
Cancel
Save