ant-user mailing list archives

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

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" 
classname="net.sf.antcontrib.logic.ShellScriptTask"/>


<shellscript>
	echo This is my inline shell script
 	echo PWD=$PWD
	echo user=$USER
</shellscript>
(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>

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

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


     [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
stephan@einsurance.de - http://www.einsurance.de
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

Mime
View raw message