Bug 34361 - Using Manager ant tasks is messy
Summary: Using Manager ant tasks is messy
Status: RESOLVED FIXED
Alias: None
Product: Tomcat 5
Classification: Unclassified
Component: Webapps:Manager (show other bugs)
Version: Nightly Build
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-07 23:17 UTC by Daniel Santos
Modified: 2005-07-22 07:16 UTC (History)
0 users



Attachments
jakarta-tomcat-catalina/webapps/docs/manager-howto.xml from 20050406 nightly (6.00 KB, patch)
2005-04-07 23:29 UTC, Daniel Santos
Details | Diff
jakarta-tomcat-catalina/catalina/src/bin/catalina-tasks.xml proposed new file (614 bytes, text/plain)
2005-04-07 23:31 UTC, Daniel Santos
Details
jakarta-tomcat-catalina/catalina/src/bin/catalina-tasks.xml proposed new file (768 bytes, text/plain)
2005-06-09 00:24 UTC, Daniel Santos
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Santos 2005-04-07 23:17:18 UTC
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.
Comment 1 Daniel Santos 2005-04-07 23:29:15 UTC
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.
Comment 2 Daniel Santos 2005-04-07 23:31:57 UTC
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
Comment 3 Peter Rossbach 2005-04-08 08:10:30 UTC
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>
Comment 4 Daniel Santos 2005-04-08 09:34:14 UTC
> 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
Comment 5 Yoav Shapira 2005-04-08 13:33:03 UTC
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.
Comment 6 Daniel Santos 2005-04-08 15:45:25 UTC
(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.
Comment 7 Peter Rossbach 2005-04-08 22:04:41 UTC
Yes,

I document this only for version > 1.6 and I thing that new
ant import method is a real nice addon :-)
Comment 8 Daniel Santos 2005-04-11 17:53:08 UTC
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.
Comment 9 Yoav Shapira 2005-06-01 04:11:15 UTC
When you get back to this, feel free to reopen/resolve the item.
Comment 10 Daniel Santos 2005-06-09 00:24:38 UTC
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.
Comment 11 Daniel Santos 2005-06-09 01:00:19 UTC
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
Comment 12 Yoav Shapira 2005-07-22 15:16:17 UTC
This was applied by Peter Rossbach on June 24th, so I'm closing this issue ;)