Author: bodewig
Date: Sun Feb 5 07:30:49 2012
New Revision: 1240669
URL: http://svn.apache.org/viewvc?rev=1240669&view=rev
Log:
make sure Project#createTask has read defaults.properties. PR 50788
Added:
ant/core/trunk/src/tests/antunit/core/createtask-test.xml (with props)
Modified:
ant/core/trunk/WHATSNEW
ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
Modified: ant/core/trunk/WHATSNEW
URL:
http://svn.apache.org/viewvc/ant/core/trunk/WHATSNEW?rev=1240669&r1=1240668&r2=1240669&view=diff
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Sun Feb 5 07:30:49 2012
@@ -123,7 +123,11 @@ Fixed bugs:
fields rather than UTF-8 filenames and the EFS-Flag.
* 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:
--------------
Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?rev=1240669&r1=1240668&r2=1240669&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Sun Feb
5 07:30:49 2012
@@ -855,6 +855,14 @@ public class ComponentHelper {
return; // Already processed
}
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();
definer.setProject(project);
definer.init();
Added: ant/core/trunk/src/tests/antunit/core/createtask-test.xml
URL:
http://svn.apache.org/viewvc/ant/core/trunk/src/tests/antunit/core/createtask-test.xml?rev=1240669&view=auto
==============================================================================
--- ant/core/trunk/src/tests/antunit/core/createtask-test.xml (added)
+++ ant/core/trunk/src/tests/antunit/core/createtask-test.xml Sun Feb 5
07:30:49 2012
@@ -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>
Propchange: ant/core/trunk/src/tests/antunit/core/createtask-test.xml
------------------------------------------------------------------------------
svn:eol-style = native