[EMAIL PROTECTED] wrote:
Author: stevel
Date: Thu Jan 11 14:01:51 2007
New Revision: 495399
URL: http://svn.apache.org/viewvc?view=rev&rev=495399
Log:
Extra diagnostics. Dump all types in a namespace if the one you ask for isnt known. Good for
identifying typos, and helps you differentiate "library not yet loaded" from "task
unknown"
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?view=diff&rev=495399&r1=495398&r2=495399
==============================================================================
--- ant/core/trunk/WHATSNEW (original)
+++ ant/core/trunk/WHATSNEW Thu Jan 11 14:01:51 2007
@@ -63,6 +63,10 @@
* Allow <mapper refid> to refer directly to a FileNameMapper instance.
+* If you try and use a type in a namespace (or an antlib), and the type is not
+ recognized but there are other definitions in that namespace, Ant lists what
+ the known definitions are. This helps you find spelling errors.
/**
- * Print unknown definition.
+ * Print unknown definition.forking
*/
private void printUnknownDefinition(
PrintWriter out, String componentName, String dirListing) {
boolean isAntlib = componentName.indexOf(MagicNames.ANTLIB_PREFIX) ==
0;
+ String uri=ProjectHelper.extractUriFromComponentName(componentName);
out.println("Cause: The name is undefined.");
out.println("Action: Check the spelling.");
out.println("Action: Check that any custom tasks/types have been
declared.");
out.println("Action: Check that any <presetdef>/<macrodef>"
+ " declarations have taken place.");
- if (isAntlib) {
- out.println();
- out.println("This appears to be an antlib declaration. ");
- out.println("Action: Check that the implementing library exists in one
of:");
- out.println(dirListing);
+ if(uri.length()>0) {
+ List matches = antTypeTable.findMatches(uri);
+ if(matches.size()>0) {
+ out.println();
+ out.println("The definitions in the namespace "+uri+" are:");
+ for(Iterator it=matches.iterator();it.hasNext();) {
+ AntTypeDefinition def=(AntTypeDefinition) it.next();
+ String local =
ProjectHelper.extractNameFromComponentName(def.getName());
+ out.println(" "+local);
+ }
+ } else {
+ out.println("No types or tasks have been defined in this namespace
yet");
+ if (isAntlib) {
+ out.println();
+ out.println("This appears to be an antlib declaration. ");
+ out.println("Action: Check that the implementing library exists
in one of:");
+ out.println(dirListing);
+ }
+ }
}
}
This is what the trace is:
BUILD FAILED - at 11/01/07 22:07
/home/slo/Projects/SmartFrog/Forge/core/components/database/build.xml:67:
Problem: failed to create task or type
antlib:org.smartfrog.tools.ant:unknown
Cause: The name is undefined.
Action: Check the spelling.
Action: Check that any custom tasks/types have been declared.
Action: Check that any <presetdef>/ <macrodef> declarations have taken
place.
The definitions in the namespace antlib:org.smartfrog.tools.ant are:
parse
waitfordaemon
gui
ping
stopdaemon
undeploy
tourl
daemonfound
daemon-debug
run
faultingwaitfor
deploy
functionaltest
console-debug
gui-debug
startdaemon
security
management-console
sign
It lets you see what is in a namespace, and whether anything at all is
in there.
I've pulled the bit that tells you how to add an antlib to the classpath
if there is stuff in the namespace. Instead I assume that the lib is
loaded, and that you've just got the spelling wrong. If someone declares
presets or macros in the same namespace then
that will be an invalid assumption.
I'd like to sort the listing, but that would mean implementing a
comparator for the type definitions, or converting their short names to
a string list and sorting that.
-steve
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]