Hello all, 

Ive been working alot with the idea of scripting languages and how they fit
into the community (especially Java scripting languages). I started to look at
when XML is misused and when something like Jython might be a better idea. The
end result was an article on the new java.net site that you can find here:

http://today.java.net/pub/a/today/2003/06/10/jython.html

The last example is about ANT. I spoke to Erik (hatcher) and James (duncan
davidson) about the whole abuse of XML in ANT proper not to mention all of the
stuff on the ant-contrib project. Essentially the idea is that you can use XML
if you are doing straight ahead stuff. But if you are going to do things like
use for loops and write conditionals, you would be better off using a real
scripting language for several reasons. Mainly that the sytax is easier to read
and write and you dont have to implement code to support custom code structures
in XML. 

Cool. That said, I went to write a fictional example of how you could replace
the XML in ANT and run it straight from Jython. I was thinking about a huge
development effort to write some "glue" between AND and Jython. Then I realized
that since its Jython and Jython can talk to Java objects and ANT has
underlying Java objects there IS NO GLUE CODE!!! Here is a basic out of the box
working example calling ANT from Jython: 


project = Project()
copyTask = Copy()
copyTask.project = project
copyTask.file = File("C:\\java\\jython_ant\\src\HelloJython.java")
copyTask.todir = File("C:\\java\\jython_ant\\temp")
copyTask.execute()

Now thats kind of ugly. You have to know alot of the ANT internals to get this
to work. Also, theres too many ant calls muddying up the script. So you can
make a helper method like this: 

def copyWrapper(file, toDir, project):
    copyTask = Copy()
    copyTask.project = project
    copyTask.file = File(file)
    copyTask.todir = File(toDir)
    copyTask.execute()

Then you can call it from your Jython and script(!!!) like this: 

copyWrapper("C:\\java\\jython_ant\\src\HelloJython.java",
"C:\\java\\jython_ant\\temp", project)

This would be even cleaner if you abstract out the variables/properties into
XML.

The point is that calling ANT from Jython is much easier than I initially
thought (you dont have to write ant translation stuff) but harder than I
secondly thought (you have to write some wrappers or something somewhere to
make the code legible). 

So, since I am a long time ANT user, but only a recent ANT developer, Im
looking for some help. I would like to get interested folks together and figure
out the best combination of ANT classes to extend or reimplement and Jython
code to make this Jython stuff a woprking reality and see where it goes. 

Just to finish off, what I really like about this approach is the whole
community aspect. The Jython stuff will be using the same codebase. Using the
same ANT installation you can call ANT from XML or Jython. Additionally, if we
do this right, well be able to plug in any Java scrpting language of choice
(like JRuby). Then, the whole argument of the use of XML goes away and the
purists and iconoclasts can all have their way-- without forking ANT. 

So there you have it. Sorry for the long rant. Lets see what kind of momentum
we can get on this. 

-jonathan



















=====
Jonathan Simon
Home - 732.777.0377  <----------- New!!!
Work - 646.674.2060
Cell - 732.718.8844
Music - www.mp3.com/jonathan_simon

__________________________________
Do you Yahoo!?
Yahoo! Calendar - Free online calendar with sync to Outlook(TM).
http://calendar.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to