You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Patrick Beard <be...@netscape.com> on 2000/08/01 07:43:27 UTC

Extending ant from within ant

I'm interested in a couple of ideas that are somewhat along the lines 
of what XSLT (XSL Transformations) is supposed to support. I'd like 
to be able to define tasks in XML that correspond to combinations of 
other tasks. For example, to build a tool for JShell, I have the 
following generic pattern:

<?xml version="1.0"?>

<!-- builds foo.jxe -->

<project name="wrap" default = "build" basedir = ".">
	<property name = "tool" value = "foo" />
	<property name = "classes" value = "${tool}.classes" />
	<property
		name = "jlink"
		value = "jlink ${org.jxe.Tools}/${tool}.jxe 
${tool}.properties ${classes}" />

	<target name = "classes">
		<mkdir dir = "${classes}" />
   		<javac
   			srcdir = "."
	  		destdir = "${classes}" />
	</target>

	<target name = "build" depends = "classes">
		<exec command = "echo ${jlink}" />
		<exec command = "${jlink}" />
	</target>

	<target name = "clean">
		<deltree dir = "${classes}" />
	</target>
</project>

What I'd really like to do is to define a task, say "buildtool" that 
would be composed of sub-tasks, mkdir, javac, and jlink. Of course, 
I'd want to define a jlink subtask in terms of exec, as I've done 
above. Is this possible with ant currently?

Another idea I'd like to explore is using Rhino JavaScript (big 
surprise) to provide scripting within a build.xml file. We could then 
define additional tasks dynamically in terms of scripts. Much of the 
currently built-in tasks could be recast in terms of scripts, where 
appropriate.

- Patrick
-- 

// Patrick C. Beard
// Java Runtime Enthusiast -- "Will invoke interfaces for food."
// mailto:beard@netscape.com

Re: Extending ant from within ant

Posted by Patrick Beard <be...@netscape.com>.
At 4:56 PM -0700 8/2/2000, James Duncan Davidson wrote:
>Why would you want to exec the jlink functionality. I know that you've got
>this cool execution engine, but if there were a jlink task that directly
>used the jlink functionality via programmatic interfaces, it's a big win on
>not having to start a VM and deal with the subtle issues involved in execs
>between all the platforms.

I was just using that as an example. I'm just stating that I'd like 
to be able to define tasks in terms of other tasks in general.
-- 

// Patrick C. Beard
// Java Runtime Enthusiast -- "Will invoke interfaces for food."
// mailto:beard@netscape.com

Re: Extending ant from within ant

Posted by James Duncan Davidson <du...@x180.com>.
on 7/31/00 10:43 PM, Patrick Beard at beard@netscape.com wrote:

> What I'd really like to do is to define a task, say "buildtool" that
> would be composed of sub-tasks, mkdir, javac, and jlink. Of course,
> I'd want to define a jlink subtask in terms of exec, as I've done
> above. Is this possible with ant currently?

It is through the programmatic interfaces, but not via the build xml
semantics. For example, you could provide a builtool task that took a bunch
of args and called the mkdir, javac, and whatever else task code directly.
Perfectly OO. :)

Why would you want to exec the jlink functionality. I know that you've got
this cool execution engine, but if there were a jlink task that directly
used the jlink functionality via programmatic interfaces, it's a big win on
not having to start a VM and deal with the subtle issues involved in execs
between all the platforms.

> Another idea I'd like to explore is using Rhino JavaScript (big
> surprise) to provide scripting within a build.xml file.

Should already be enabled thanks to Sam Ruby. He's probably already piped
up.

.duncan


Re: Extending ant from within ant

Posted by Peter Donald <do...@mad.scientist.com>.
At 11:33  31/7/00 -0700, you wrote:
>Great. I've been trying to obtain BSF, but see no way to download all 
>of the source at once! The current web pages at

I believe you can get it via www.alphaworks.ibm.com

>http://oss.software.ibm.com/developerworks/opensource/bsf/
>
>don't describe how to access the repository directly from CVS.
>
>Looking forward to using BSF.

yes that whole section is an ugly unsable eyesore. I once heard some people
make jokes that it was deliberatly done that way so IBM wouldn't get people
wanting to join said projects and thus they could retain IP :P. But the cvs
for it is via

Root: :pserver:anoncvs@oss.software.ibm.com:/usr/cvs/bsf
Module: bsf-src
Passwd: anoncvs


Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*

Re: Extending ant from within ant

Posted by Patrick Beard <be...@netscape.com>.
At 3:50 PM +1000 8/1/00, Peter Donald wrote:
>At 10:43  31/7/00 -0700, you wrote:
>  >Another idea I'd like to explore is using Rhino JavaScript (big
>>surprise) to provide scripting within a build.xml file. We could then
>>define additional tasks dynamically in terms of scripts. Much of the
>>currently built-in tasks could be recast in terms of scripts, where
>>appropriate.
>
>actually that is already possible. The BSF is used in script task to offer
>said functionality.

Great. I've been trying to obtain BSF, but see no way to download all 
of the source at once! The current web pages at

http://oss.software.ibm.com/developerworks/opensource/bsf/

don't describe how to access the repository directly from CVS.

Looking forward to using BSF.

- Patrick
-- 

// Patrick C. Beard
// Java Runtime Enthusiast -- "Will invoke interfaces for food."
// mailto:beard@netscape.com

Re: Extending ant from within ant

Posted by Peter Donald <do...@mad.scientist.com>.
At 10:43  31/7/00 -0700, you wrote:
>I'm interested in a couple of ideas that are somewhat along the lines 
>of what XSLT (XSL Transformations) is supposed to support. I'd like 
>to be able to define tasks in XML that correspond to combinations of 
>other tasks. For example, to build a tool for JShell, I have the 
>following generic pattern:

there has been a demand for similar things in ant recently.

>What I'd really like to do is to define a task, say "buildtool" that 
>would be composed of sub-tasks, mkdir, javac, and jlink. Of course, 
>I'd want to define a jlink subtask in terms of exec, as I've done 
>above. Is this possible with ant currently?

yes as you have done it above but as a more complex approach is noyt possible.

>Another idea I'd like to explore is using Rhino JavaScript (big 
>surprise) to provide scripting within a build.xml file. We could then 
>define additional tasks dynamically in terms of scripts. Much of the 
>currently built-in tasks could be recast in terms of scripts, where 
>appropriate.

actually that is already possible. The BSF is used in script task to offer
said functionality.  From one of Sam Rubies posts :

   <project name="squares" default="main" basedir=".">

     <target name="setup">

       <script language="javascript"> <![CDATA[

         for (i=1; i<=10; i++) {
           echo = squares.createTask("echo");
           main.addTask(echo);
           echo.setMessage(i*i);
         }

       ]]> </script>

     </target>

     <target name="main" depends="setup" />

   </project>

Cheers,

Pete

*------------------------------------------------------*
| "Nearly all men can stand adversity, but if you want |
| to test a man's character, give him power."          |
|       -Abraham Lincoln                               |
*------------------------------------------------------*