Adding additional ant tasks

34 views
Skip to first unread message

chris

unread,
Apr 25, 2011, 10:53:30 AM4/25/11
to Aardvark
Hi:

How would one go about adding additional ant taskdefs to a vark file?
I have a vark file that needs to deploy war files on tomcat and I
don't know how to make the tomcat commands visible to my vark script.
I've placed the catalina-ant.jar file in my $AARDVARK_HOME/lib
directory. From going through the aardvark source it appears that I'd
need to do something with AntlibTypeLoader.addAntlib(). Is there
something I'm missing, or is this something that's planned?

Thanks

Chris

Brian Chang

unread,
Apr 25, 2011, 3:10:08 PM4/25/11
to aardv...@googlegroups.com
I have a way for you to do it in 0.3.3, which i haven't released.

Let me make sure I've pushed it all to GitHub, and then you can build 0.3.3 from source.


Sent from my iPhone

Brian Chang

unread,
Apr 25, 2011, 5:22:41 PM4/25/11
to aardv...@googlegroups.com
Chris - 

The feature you need is now up on GitHub - you need to just build the bleeding edge version from source.  It's available at:

You should be able to use Aardvark 0.3.2 to build. The target you should run is release.

Once you have Aardvark 0.3.3 in your path and set as AARDVARK_HOME, put the following line at the top of your .vark file, below the classpath statement if you have one:
// #antlib Antlibname antlibresource
where Antlibname is the type name for your group of tasks, and antlibresource is the .xml or .properties file listing the tasks provided by the antlib.

Here's an example line you'd use to import Ivy tasks, if Ivy weren't already built in:
// #antlib Ivy org/apache/ivy/ant/antlib.xml

Here's how I import the aspectj antlib in a Guidewire-internal project:
// #antlib Aspectj org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties

Then you'll have a new Gosu type, gw.vark.antlibs.Aspectj, containing static functions representing tasks.

If you have any questions issues, let's communicate outside of this list, since this feature isn't yet officially supported or documented.  I realize the instructions here might be a little bewildering - so I'll offer to guide you over IM.

It will be a lot easier once I have better editor support, or in the shorter term, a way for users to browse the API dynamically from a vark prompt.

Chris Gow

unread,
Apr 26, 2011, 9:43:30 AM4/26/11
to aardv...@googlegroups.com
Hi Brian:

Thanks for the quick response. I checked out the latest from github and ran vark release. Looks like there's a few tests that fail (test report attached). So I ran a clean dist instead which seems to work. It looks like the antlib is not registered by vedit when you first add it to the vark file. When I first added the line //#antlib Tomcat org/apache/catalina/ant/antlib.xml I did not get a global variable called Tomcat until I exited vedit and restarted it (probably your statement of better editor support below). However even though I have a Tomcat variable, I do not see any of the tasks defined in the xml file.

Chris 
TEST-gw.vark.AardvarkSuite.txt

Brian Chang

unread,
Apr 26, 2011, 4:48:03 PM4/26/11
to aardv...@googlegroups.com
Ah yes, I forgot about VEdit.  See why this isn't officially supported?  :)  I'll take a look at things later today.

Brian Chang

unread,
Apr 27, 2011, 3:58:19 AM4/27/11
to aardv...@googlegroups.com
Chris -

I took a look, and it looks like it works as long as the #antlib definition is already in your .vark file at the time vedit starts up.  For now, vedit does a preprocess scan of the file for such defs - at startup - in order to get the typeloader to import your Tomcat tasks.  I'll try to find a way to get this done within vedit's runtime, but it'll take a lot more ironing out.

There's another issue which may have gotten in your way instead.  If you defined your antlib as Tomcat, it will be available as a type, not as a variable. The ant tasks are then available off this type as static functions.  So you're going to need a "uses gw.vark.antlibs.Tomcat" and then you can use task foo as Tomcat.foo().  A few notes on this:
  1) I know things can misleading because I have made Ant and Ivy available as global property objects. I did this so that you wouldn't have to import gw.vark.antlibs.Ant and gw.vark.antlibs.Ivy - I'm rethinking this and I concluded I'd prefer to make them imported by default.
  2) If I import gw.vark.antlibs.* by default, eventually you won't need to import gw.vark.antlibs.Tomcat in your .vark file.

Sorry this is coming off pretty darn confusing.  Obviously you're working with an brand new area which is in very rough shape, but I'm glad for the opportunity to observe your user experience and get your feedback.  Again, I'm happy to work with you offline on this.

Brian


On Tue, Apr 26, 2011 at 6:43 AM, Chris Gow <chri...@gmail.com> wrote:

JP

unread,
Apr 27, 2011, 12:02:56 PM4/27/11
to Aardvark
I know 0.3.2 came out very recently, but any idea when 0.3.3 will be
available? I'm having trouble building it from source at work (it
hangs up at one point while resolving the dependencies and then never
recovers). Being able to use antlib's would be a huge improvement!
> > On Mon, Apr 25, 2011 at 5:22 PM, Brian Chang <bchan...@gmail.com> wrote:
>
> >> Chris -
>
> >> The feature you need is now up on GitHub - you need to just build the
> >> bleeding edge version from source.  It's available at:
> >>   https://bch...@github.com/vark/Aardvark.git
>
> >> You should be able to use Aardvark 0.3.2 to build. The target you should
> >> run is *release*.
>
> >> Once you have Aardvark 0.3.3 in your path and set as AARDVARK_HOME, put
> >> the following line at the top of your .vark file, *below* the classpath
> >> statement if you have one:
> >> // #antlib Antlibname antlibresource
> >> where Antlibname is the type name for your group of tasks, and
> >> antlibresource is the .xml or .properties file listing the tasks provided by
> >> the antlib.
>
> >> Here's an example line you'd use to import Ivy tasks, if Ivy weren't
> >> already built in:
> >> // #antlib Ivy org/apache/ivy/ant/antlib.xml
>
> >> Here's how I import the aspectj antlib in a Guidewire-internal project:
> >> // #antlib Aspectj
> >> org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties
>
> >> Then you'll have a new Gosu type, gw.vark.antlibs.Aspectj, containing
> >> static functions representing tasks.
>
> >> If you have any questions issues, let's communicate outside of this list,
> >> since this feature isn't yet officially supported or documented.  I realize
> >> the instructions here might be a little bewildering - so I'll offer to guide
> >> you over IM.
>
> >> It will be a lot easier once I have better editor support, or in the
> >> shorter term, a way for users to browse the API dynamically from a vark
> >> prompt.
>
> >> On Mon, Apr 25, 2011 at 12:10 PM, Brian Chang <bchan...@gmail.com> wrote:
>
> >>> I have a way for you to do it in 0.3.3, which i haven't released.
>
> >>> Let me make sure I've pushed it all to GitHub, and then you can build
> >>> 0.3.3 from source.
>
> >>> Sent from my iPhone
>
> >>> On Apr 25, 2011, at 7:53 AM, chris <chris....@gmail.com> wrote:
>
> >>> > Hi:
>
> >>> > How would one go about adding additional ant taskdefs to a vark file?
> >>> > I have a vark file that needs to deploy war files on tomcat and I
> >>> > don't know how to make the tomcat commands visible to my vark script.
> >>> > I've placed the catalina-ant.jar file in my $AARDVARK_HOME/lib
> >>> > directory. From going through the aardvark source it appears that I'd
> >>> > need to do something with AntlibTypeLoader.addAntlib().  Is there
> >>> > something I'm missing, or is this something that's planned?
>
> >>> > Thanks
>
> >>> > Chris
>
> >> --
> >> Brian
> >> bchan...@gmail.com
>
> --
> Brian
> bchan...@gmail.com

Chris Gow

unread,
Apr 27, 2011, 12:48:40 PM4/27/11
to aardv...@googlegroups.com
JP:

Do you have aardvark set up as a project in eclipse or trying to build aardvark from within eclipse? I think I had the same problem yesterday as well. I originally created an eclipse project for aardvark (a while back) and did nothing with it for a while then when Brian pushed his changes yesterday I pulled them in (using the git eclipse plugin). I tried to build from outside of eclipse and after 20 minutes of downloading stuff I killed the process (I had actually forgotten about it). I removed the project and pulled Brian's changes again, this time using the command line version of git and did a build again. This time it worked. I know its a shot in the dark, but I thought I would mention it.

hth

Chris

Brian Chang

unread,
Apr 27, 2011, 1:00:48 PM4/27/11
to aardv...@googlegroups.com
Sure, I'm pretty sure I can get 0.3.3 out by the end of this weekend.

Carson Gross

unread,
Apr 27, 2011, 1:21:07 PM4/27/11
to aardv...@googlegroups.com
Sounds like it's an Ivy dependencies issue to me: I've had resolving dependencies take a looooooooong time.

Anyone want to work on packrat (a package manager for gosu)?

Cheers,
Carson

Gus Prevas

unread,
Apr 27, 2011, 1:32:11 PM4/27/11
to aardv...@googlegroups.com
Ivy does take a long time to resolve dependencies the first time, but maybe we should slap a profiler on there and see why before we reinvent any more wheels.

Carson Gross

unread,
Apr 27, 2011, 1:37:20 PM4/27/11
to aardv...@googlegroups.com
That was really a non sequitur on my part: I'm not advocating inventing any wheels with packrat, and it wouldn't fix the perf issues. 

We'd probably use ivy as the backend, just because it understands so many different repositories.  It's the front end I object to: I'd prefer something like ruby gems or apt-get that lets you search and install packages without scrounging around on the internets looking for the right incantation to stick in an XML file.

Yes, I think that copy and paste is too hard.

Cheers,
Carson

bcha...@gmail.com

unread,
Apr 27, 2011, 2:10:35 PM4/27/11
to aardv...@googlegroups.com
You don't need a profiler necessarily. I once tried looking into the long resolution time by running vark with the "-v" switch and found that Ivy attempts and misses with a crapload of invalid URLs based on the resolver chain. Once you have most artifacts in your Ivy cache, however, things tend to fly by pretty quickly.

OTOH, I may or may not have tried nuking my Ivy cache, and failed to observe the slow resolution time again. So that was the end of that at the time. :(

If you find that the resolution is taking inordinately long, such as 20 minutes, try -v and it may shed some light, and I'd love to collect your findings.

JP

unread,
Apr 27, 2011, 2:43:52 PM4/27/11
to Aardvark
>Do you have aardvark set up as a project in eclipse or trying to build aardvark from within eclipse?

I was running this all outside of Eclipse and experienced this issue.
Thanks for the advice though.

> Sounds like it's an Ivy dependencies issue to me: I've had resolving dependencies take a looooooooong time.

That was the behavior I experienced, so I did assume it was dead in
the water - I left it going for about 20 minutes before killing it.

> You don't need a profiler necessarily. I once tried looking into the long  
> resolution time by running vark with the "-v" switch and found that Ivy  
> attempts and misses with a crapload of invalid URLs based on the resolver  
> chain.

I'll run it again with -v to see what's going on.

> It's the front end I object to: I'd prefer something like ruby gems or apt-get that lets you search and install packages without scrounging around > on the internets looking for the right incantation to stick in an XML file.

Yea they have that down pat. It's one thing that I feel makes it alot
easier for a developer to get interested and involved. Setting up a
verbose xml file to handle things can be cumbersome to getting setup
quickly. You want to play around in a repl or a simple editor, and
easily grab additional functionality through a nice package manager
(Ivy is pretty nice, but friendly to setup it is not).

On Apr 27, 2:10 pm, bchan...@gmail.com wrote:
Once you have most artifacts in your Ivy cache, however, things tend  
> to fly by pretty quickly.
>
> OTOH, I may or may not have tried nuking my Ivy cache, and failed to  
> observe the slow resolution time again. So that was the end of that at the  
> time. :(
>
> If you find that the resolution is taking inordinately long, such as 20  
> minutes, try -v and it may shed some light, and I'd love to collect your  
> findings.
>
> On Apr 27, 2011 10:32am, Gus Prevas <kpre...@gmail.com> wrote:
>
>
>
>
>
>
>
> > Ivy does take a long time to resolve dependencies the first time, but  
> > maybe we should slap a profiler on there and see why before we reinvent  
> > any more wheels.
> > On Wed, Apr 27, 2011 at 1:21 PM, Carson Gross carsongr...@gmail.com>  
> > wrote:
> > Sounds like it's an Ivy dependencies issue to me: I've had resolving  
> > dependencies take a looooooooong time.
> > Anyone want to work on packrat (a package manager for gosu)?
> > Cheers,
> > Carson
> > On Apr 27, 2011, at 9:48 AM, Chris Gow wrote:
> > JP:
> > Do you have aardvark set up as a project in eclipse or trying to build  
> > aardvark from within eclipse? I think I had the same problem yesterday as  
> > well. I originally created an eclipse project for aardvark (a while back)  
> > and did nothing with it for a while then when Brian pushed his changes  
> > yesterday I pulled them in (using the git eclipse plugin). I tried to  
> > build from outside of eclipse and after 20 minutes of downloading stuff I  
> > killed the process (I had actually forgotten about it). I removed the  
> > project and pulled Brian's changes again, this time using the command  
> > line version of git and did a build again. This time it worked. I know  
> > its a shot in the dark, but I thought I would mention it.
> > hth
> > Chris

JP

unread,
Apr 27, 2011, 2:46:33 PM4/27/11
to Aardvark
Sweet! That'd be awesome.
> bchan...@gmail.com

JP

unread,
Apr 28, 2011, 1:34:46 PM4/28/11
to Aardvark
I ran it again today and it went fine, no lag. I did get the jUnit
error but I just bypassed it.

Brian Chang

unread,
May 1, 2011, 9:52:17 PM5/1/11
to aardv...@googlegroups.com
I just mentioned in a previous thread that I had fixed the tests, but then I looked into this thread for another look at your test log, and realized your issue was different.  That looks like it could have been from some broken version of Gosu.  I assume you were running the build with Aardvark 0.3.2 - pretty sure you'd find smoother sailing with 0.3.3.

Building Aardvark with Aardvark can be a little tricky sometimes...

Reply all
Reply to author
Forward
0 new messages