-----Original Message-----
From: Christopher Schultz [mailto:ch...@christopherschultz.net]
Sent: Monday, April 02, 2012 4:24 PM
To: Tomcat Developers List
Subject: Re: Improving Ant Task for JSP Compilation

Nick,

On 3/31/12 4:34 PM, Nick Williams wrote:
> This morning I filed issues 53011 and 53012, about general
> improvements to the Ant task used for compiling JSPs. These two issues
> are rather important to our team, and are making using the compiler
> rather difficult. In the interest of both improving Tomcat and meeting
> our needs as quickly as possible, I am interested in possibly
> contributing code changes to effect these improvements, and possible
> others.

Great!

> I read the information at http://tomcat.apache.org/getinvolved.html
> and related links, and understand that my first step is building
> Tomcat and my second is proposing patches to the other developers
> (presumably by attaching them to the issues I filed). If I'm missing
> anything so far, please let me know.

That sounds like a good start.

Remember that everything you do should be in Tomcat's 'trunk'. Here's the
svn root for that:
http://svn.apache.org/repos/asf/tomcat/trunk

All patches should be against trunk (they'll get back-ported to 7.0.x and
possibly 6.0.x).

> What I'd really like is a little further guidance about this
> particular feature in Tomcat. Who is really familiar with it that I
> can ask questions of if I don't understand something I see?

Perhaps the best thing to do is look at the svn history for the files
involved. Start with org.apache.jasper.JspC and the related files like
Compiler, etc. to see who has updated them recently. Mostly, it's best to
ask questions on this list and let anyone answer them who can, rather than
trying to directly contact any one person.

> What do the developers on the list think about the ideas proposed in
> these two issues?
>
> Bug 53011 - Ant Jasper task fails after one error

+1 - seems reasonable. I've added some comments to the bug.

> Bug 53012 - Ant Jasper task does not name including file when
>             included file has compile error

+1 also seems reasonable. Check the current behavior of the trunk to
make sure this isn't already in there.

> I believe they
> make Tomcat better, but that's just because they meet our immediate needs.

That's host these projects grow: patches are always welcome. Basically
anything that doesn't a) violate the servlet specification or b)
significantly impact performance or c) require sweeping changes to the code
is fair game.

Thanks,
-chris

---------------------------------------------------------------------


Alright, I've analyzed the o.a.tools.ant.Task, o.a.tools.ant.taskdefs.Java,
o.a.tools.ant.taskdefs.Javac, o.a.jasper.JspC, o.a.jasper.compiler.Compiler,
and the classes in o.a.catalina.ant. I learned a lot ... in some cases more
than I wanted to. ;-)

Here are some of my observations:

- JspC is the only Ant task in Tomcat that doesn't actually extend
o.a.tools.ant.Task. All the other tasks extend Task, but not JspC. JspC just
happens to implement enough methods that Ant will blindly execute it. This
is likely the primary cause behind 53032.

- JspC does a lot of things "wrong" for executing in Ant-world. I'm sure
it's all perfectly right for its original intended purpose, but it's "wrong"
in Ant-world. The way it logs, handles files and classpaths, etc. are all
counter to standards used in Ant. The getFork() method it implements isn't
even related to Ant; it's implementing the getFork() method in
o.a.jasper.Options. This all makes 53011, 53012 and 53031 difficult (at
best) to solve.

- JspC is so tightly coupled with the other things in Tomcat that I believe
it would be next to impossible to retrofit it to be a "well-behaved" Ant
task. For that matter, I believe it would be next to impossible to even
/use/ it in a new well-behaved Ant task.

- I have not yet figured out exactly how compile errors are output to
determine if 53012 is already fixed in trunk. I'm still investigating.


With those, here are my general recommendations:

- Create a new class o.a.catalina.ant.JspCompileTask extends
o.a.catalina.ant.BaseRedirectionHelperTask (which extends
o.a.tools.ant.Task). This class will do a lot of the same things that JspC
does, but in a simpler way, making some assumptions because it knows that
it's always running within an Ant project. It will still have most of the
plethora of options that JspC has, such as compilerSourceVM, compile,
getStringsAsCharArray, etc. It will accept a Classpath for use in the
compilation phase of JSPs. It will fork upon request, but not by default,
just like java/javac/junit. It will fail on error by default, but not
required, and will have an errorProperty, just like java/javac/junit. It
will fail only after all errors, just like java/javac/junit, but will have a
failFast option to fail after a single error if desired (off by default).

- Change o.a.jasper.compiler.Compiler to make the log field non-final and
add a setter for the log field. The compiler uses o.a.juli.logging for all
of its logging, but Ant does not understand how these logging message are
output and flags them all as wornings. Making this field mutable is
necessary to provide a mechanism for converting juli logging messages to
Ant-recognizable logging messages.

- Change o.a.jasper.compiler.Compiler (or wherever it ends up being) to fix
how errors are generated when classes fail to compile, to make sure we
include the include-stack (53012). I know JspC is the one /outputting/ the
error, but it's getting generated somewhere else, and I haven't found that
yet.

- Add any helper classes necessary to support JspCompileTask to
o.a.catalina.ant.jasper.


Then there will need to be these decisions made (not necessarily now, but
eventually):

- Does the JspCompileTask get included in o/a/catalina/ant/antlib.xml? If
so, what should the task name be (the answer to this might depend on the
answer to the next question)? Currently, JspC is not defined as a task in
this file.

- Does the JspCompileTask get included in o/a/catalina/ant/catalina.tasks
(which is included in /bin/catalina-task.xml)? If so, what about the
existence of the jasper (JspC) and jasper2 (also JspC) tasks already in this
file? Do we take out those definitions and replace them with JspCompileTask?
Or do we supplement them with JspCompileTask, and name JspCompileTask
something other than "jasper" or "jasper2?"


So there's my progress so far, and my thoughts on what needs to be done. The
good news is that I think, since this will be /mostly/ new files, that it
should be easy to back-port these changes to 6.0 (if desired) and 7.0 (I
hope).

Thoughts? We don't have to be sure about anything right now, but I don't
want to start coding much until we have a general consensus that we're
heading in the right direction.

Nick

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to