ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From stephan beal <>
Subject new task: ShellScriptTask
Date Wed, 24 Apr 2002 11:20:05 GMT

i know this isn't exactly canon, but attached is an ExecTask subclass which 
may be useful for any Unix froods out there. It allows you to write inline 
scripts for arbitrary scripting tools:

<taskdef name="shellscript" 

	echo This is my inline shell script
 	echo PWD=$PWD
	echo user=$USER
(defaults to using shell /bin/bash)

<shellscript executable="/bin/sed">
	<arg value="-n"/>
	<arg line="-e 's/FOO/BAR/gp'"/>
one two
FOO bar bar bar bar FOO FOO bar
three four

<shellscript executable="/usr/bin/make">
	<arg value="-f"/>
default: all
foo = this is a makefile
	@echo foo=$(foo)

<shellscript executable="/usr/bin/perl"><![CDATA[
	print "Hello, World!\n";
	open IN, "</etc/hosts" or die "Error opening build file!\n";
#	print join( "",@foo ),"\n";

     [bash] This is my inline shell script
     [bash] PWD=/home/stephan/cvs/einsurance
     [bash] user=stephan
      [sed] BAR bar bar bar bar BAR BAR bar
     [make] make[1]: Entering directory `/home/stephan/cvs/einsurance'
     [make] foo=this is a makefile
     [make] make[1]: Leaving directory `/home/stephan/cvs/einsurance'
     [perl] Hello, World!

Tested against ant 1.4.1.
It's a subclass of ExecTask, so it supports all of the <exec> options as well.

----- stephan -
Office: +49 (89)  552 92 862 Handy:  +49 (179) 211 97 67
"I didn't give in to the Nazis and I won't give in to the bladder." 
- The Queen Mum

View raw message