Using ant tasks to deploy, undeploy apps, etc. requires one to copy and paste taskdefs from the documentation into their build.xml which is messy. The docs also instruct the user to copy the catalina-ant.jar file into the $ANT_HOME/lib directory, which is unnecessary if you specify the classpath in your taskdef element and should be avoided when possible. I propose that we have a centralized ant project file will solve these problems for the with a single line of code. Then update the manager-how-to doc to specify how to import this .xml file which is much cleaner. With this solution, the user would need the following code in their ant build script to use the tasks. I assume here that they have set the catalina.home property elsewhere (hopefully their build.properties file): <import file="${catalina.home}/bin/catalina-tasks.xml"/> Another possible solution to this problem is to use taskdef and specify the resource catalina.tasks (under org.apache.catalina.ant) and then specify the classpath inline. However, this also includes the JspC task which has a good deal of dependencies and requires you to import a lot of jar files to run. I believe that this solution represents a good balance of consideration for these issues. The new "catalina-tasks.xml" file will live in $CATALINA_HOME/bin which will import everything in catalina.tasks, including JspC and also import the needed jar files. It will also self-discover the correct catalina.home if it was not previously specified. Drawbacks to this approach: This will slow the build more than excluding JspC because the JspC taskdef will load more classes than just the pure Catalina tasks. Bonuses of this approach: This makes JspC available as well and also prevents the need for either: a.) another catalina.tasks file that does not contains JspC (e.g., "pure-catalina.tasks") b.) the removal of JspC from catalina.tasks (I don't know the dependencies here) or c.) putting a taskdef line in the catalina-imports.xml file for each task that we want to import instead of using a bulk include like I am proposing now.
Created attachment 14656 [details] jakarta-tomcat-catalina/webapps/docs/manager-howto.xml from 20050406 nightly Removed instructions to copy catalina-ant.jar to the $ANT_HOME/lib. Removed code that declares Tomcat taskdefs in example build.xml. Added import of $CATALINA_HOME/bin/catalina-tasks.xml to top of example build.xml to replace taskdefs that were removed.
Created attachment 14657 [details] jakarta-tomcat-catalina/catalina/src/bin/catalina-tasks.xml proposed new file ant build script for importing to simplify taskdefs and class location
Hey, wonderfull shortcut! I see at weekend to commit it and update doc Thanks Peter PS: I have test it and currently a shorter classpath is enough :-) <project name="Catalina Ant Tasks"> <!-- set catalina.home if it's not already set --> <dirname property="catalina.home.bin.dir" file="${ant.file.imported}"/> <property name="catalina.home" value="${catalina.home.bin.dir}/.."/> <taskdef resource="org/apache/catalina/ant/catalina.tasks"> <classpath> <fileset dir="${catalina.home}/server/lib"> <include name="catalina-ant.jar"/> </fileset> </classpath> </taskdef> </project>
> PS: I have test it and currently a shorter classpath is enough :-) hmm. You might want to check your CLASSPATH, $ANT_HOME/lib and ANT_ARGS (for -lib statments) maybe. When I ran it, it needed classes for JspC. Oh wait, I may have run it against 5.0.28 however. That would be awsome if that's all it needed! :) if that's the case in the nightly then we should be able to get away with: <project name="Catalina Ant Tasks"> <!-- set catalina.home if it's not already set --> <dirname property="catalina.home.bin.dir" file="${ant.file.imported}"/> <property name="catalina.home" value="${catalina.home.bin.dir}/.."/> <taskdef resource="org/apache/catalina/ant/catalina.tasks" classpath=${catalina.home}/server/lib/catalina-ant.jar"/> </project> Even if not, we can cause it to have a faster load by isolating the jars that it really needs (catalina-ant.jar plus the ones for JspC). I'll have to experiement with this more after I have slept. Thanks! Daniel
Peter, or whoever commits this: *if* this patch requires a specific version of Ant, e.g 1.6 or later, please make sure to note that as well in the docs.
(In reply to comment #5) > Peter, or whoever commits this: *if* this patch requires a specific version of > Ant, e.g 1.6 or later, please make sure to note that as well in the docs. yea, I was just thinking that. We should do some testing on older versions of ant and make sure it works there as well. If not document the latest required version.
Yes, I document this only for version > 1.6 and I thing that new ant import method is a real nice addon :-)
Before we commit this, let's refine the dependencies. I was really busy this weekend and didn't get a chance to do it but I will have the chance tonight.
When you get back to this, feel free to reopen/resolve the item.
Created attachment 15341 [details] jakarta-tomcat-catalina/catalina/src/bin/catalina-tasks.xml proposed new file Updated to only import the jar files that are used.
Sorry I took so long on this. I got the dependencies isolated down to these 5 jars: bin/commons-logging-api.jar common/lib/jasper-compiler.jar common/lib/jasper-runtime.jar common/lib/servlet-api.jar server/lib/catalina-ant.jar The documentation diff is still good since it hasn't changed since Mon Jan 31 12:16:57 2005 UTC (4 months ago). Works great and uses the same jar files on both 5.0 and 5.5 builds. I think it's ready to go! :) Daniel
This was applied by Peter Rossbach on June 24th, so I'm closing this issue ;)