diff --git a/docs/ant_task_guidelines.html b/docs/ant_task_guidelines.html index 975a2da5d..ae1b4518a 100644 --- a/docs/ant_task_guidelines.html +++ b/docs/ant_task_guidelines.html @@ -6,27 +6,26 @@ Apache Ant Task Design Guidelines
-There is an ant build file check.xml in the main ant directory with runs +There is an Ant build file check.xml in the main ant directory with runs checkstyle over - ant's source code. + Ant's source code.
-The ant1.x tasks are very inconsistent regarding naming of attributes --some tasks use source, others src. -Here is a list of preferred attribute names. - -
failonerror @@ -123,7 +116,7 @@ Here is a list of preferred attribute names. boolean to control whether failure to execute should throw a BuildException or just print an error. Parameter validation failures should always throw an error, regardless - of this flag + of this flag. |
Yes, this is a very short list. Try and be vaguely consistent with the core tasks, at the very least. @@ -165,27 +159,33 @@ tasks, at the very least. Try and make it possible for people to supply a classpath to your task, if you need external libraries, rather than make them add everything to -the ANT_HOME\lib directory. This lets people keep the external libraries -in their ant-based project, rather than force all users to make changes -to their ant system configuration. +the ANT_HOME/lib directory. This lets people keep the external libraries +in their Ant-based project, rather than force all users to make changes +to their Ant system configuration.
-The other common re-use mechanism in ant is for one task to create and
-configure another. This is fairly simple.
+The other common re-use mechanism in Ant is for one task to create and
+configure another. This is fairly simple. There are facilities available in
+Ant's API to have the tasks instantiated by their familiar names
+("java", "exec", etc.). It is recommended that you
+not use this approach because of the entirely real possibility that a
+user has overridden the name to point to a different class entirely. Use direct
+constructor calls (or reflection) to instantiate your subtask. Since Ant 1.6.3,
+you can call org.apache.tools.ant.Task#bindToOwner()
+to "mask" a helper task as its parent.
-What is problematic is code which is dependent on Java1.3 features --java.lang.reflect.Proxy, or Java1.4 features - java.io.nio for example. -Be also aware of extra -methods in older classes - like StringBuffer#append(StringBuffer). -These can not be used directly by any code and still be able to compile -and run on a Java 1.2 system. -If a new method in an existing class -is to be used, it must be used via reflection and the -NoSuchMethodException handled somehow. -
-What if code simply does not work on Java1.2? It can happen. It will +Ant 1.5 and lower was designed to support Java 1.1. Ant 1.6 and higher +is designed to support Java 1.2: to build on it, to run on it. Sometimes +functionality of tasks have to degrade in that environment--usually due to +library limitations; such behaviour change must always be noted in the +documentation. +
+What is problematic is code which is dependent on Java 1.3 features; +e.g. java.lang.reflect.Proxy, or Java 1.4 features; e.g. java.io.nio. +Be also aware of extra methods in older classes; +e.g. StringBuffer#append(StringBuffer). These cannot be used directly +by any code and still be able to compile and run on a Java 1.2 system. +If a new method in an existing class is to be used, it must be used via +reflection and the NoSuchMethodException handled somehow. +
+What if code simply does not work on Java 1.2? It can happen. It will probably be OK to have the task as an optional task, with compilation -restricted to Java1.3 or later through build.xml modifications. +restricted to Java 1.3 or later through build.xml modifications. Better still, use reflection to link to the classes at run time.
Java 1.4 adds a new optional change to the language itself, the assert keyword, which is only enabled if the compiler is told to compile 1.4 version source. Clearly with the 1.2 compatibility requirement, -Ant tasks can not use this keyword. They also need to move away from +Ant tasks cannot use this keyword. They also need to move away from using the JUnit assert() method and call assertTrue() instead.
@@ -233,26 +231,25 @@ For historical reasons, addText(String text) is called to set the task's nested text, without any property expansion taking place. Call Project.replaceProperties() to do this manually. -
-One thing we can not do is move existing tasks around or delete them. +One thing we must not do is move existing tasks around or delete them. Remember that Ant has a Java API as well as an XML language. We don't want to break that API, or anything that subclasses existing Ant tasks. When refactoring, you need to leave facades where the original classes were. so @@ -261,9 +258,9 @@ existing code does not break.
@@ -281,7 +278,6 @@ To test a single task, use the one shot ant run-single-test
-Dtestcase=${testname}
where ${testname}
is the name of your test class.
-
The test cases are also used by the committers to verify that changes @@ -293,18 +289,18 @@ utterly essential to many users.
-Remember also that Ant 1.x is designed to compile and run on Java1.2, so +Remember also that Ant 1.x is designed to compile and run on Java 1.2, so you should test on Java 1.2 as well as any later version which you use. You ought to be able to download an old SDK from Sun for this purpose.
Finally, run a full build test
before and after you start
-developing your project, to make sure you havent broken anything else by
+developing your project, to make sure you haven't broken anything else by
accident.
The fairly laissez-faire license of Apache is not currently considered -compabitible with -either the GPL or the Lesser GPL of the Free Software Foundation -the -Gnu project. These licenses have stricter terms, "copyleft", which are -not in the Apache Software Foundation license. +compatible with +either the GPL or the Lesser GPL of the Free Software Foundation--the +Gnu project. These licenses have stricter terms, "copyleft", +which are not in the Apache Software Foundation license. This permits people and organisations to build -commercial and closed source applications atop the Apache libraries and -source. +commercial and closed source applications atop the Apache libraries and source.
Because the Gnu GPL license immediately extends to cover any larger -application (or library, in the case of GLPL) into which it is -incorporated, the Ant team can not incorporate any task based upon GPL +application (or library, in the case of LGPL) into which it is +incorporated, the Ant team cannot incorporate any task based upon GPL or LGPL source into the Ant codebase. You are free to submit it, but it will be politely and firmly rejected. @@ -353,44 +348,39 @@ programs, as you are just executing them at this point, not linking to them.
Even if we cannot include your task into the Apache codebase, we can -still point to where you host it -just submit a diff to +still point to where you host it; just submit a diff to xdocs/external.html pointing to your task.
-If your task links directly to proprietary code, we have a differnt +If your task links directly to proprietary code, we have a different problem: it is really hard to build the tasks. Please use reflection. -
If you are thinking of writing a task, posting a note on your thoughts -to the list can be informative -you well get other peoples insight and -maybe some half written task to do the basics, all without writing a +to the list can be informative--you will get other peoples' insights and +maybe some half-written task to do the basics, all without writing a line of code. -
-You may create your patch file using either of the following approaches. -The committers recommend you to take the first approach. +You may create your patch file using either of the following approaches +(the committers recommend the first):
Use Ant to generate a patch file to Ant:
@@ -432,8 +422,7 @@ into separate tasks.We also like submissions to be added to -bugzilla, so that they -dont get lost. Please submit them by first filing the report with a +bugzilla, so that they dont get lost. Please submit them by first filing the report with a meaningful name, then adding files as attachments. Use CVS diff files please!
@@ -447,18 +436,18 @@ to be neglected.
Checklists
These are the things you should verify before submitting patches and new -tasks. Things don't have to be perfect, it may take a couple of +tasks. Things don't have to be perfect; it may take a couple of iterations before a patch or submission is committed, and these items can be addressed in the process. But by the time the code is committed, everything including the documentation and some test cases will have -been done, so by getting them out the way up front can save time. +been done, so getting them out the way up front can save time. The committers look more favourably on patches and submissions with test cases, while documentation helps sell the reason for a task.Checklist before submitting a patch
Copyright © 2001-2003,2005 Apache Software Foundation. All rights +
Copyright © 2001-2003, 2005 Apache Software Foundation. All rights Reserved.