Spyplane
Spyplane

Reputation: 435

How do you access ant properties from within a shellscript task?

In ant you can do something like:

<property name="version" value="${some.fake.version}"

<shellscript shell="bash" dir="${build.dir}"> 
   echo "some shell cmds"
   df -h
   ls *
   svn export http://svn.org/somedir              
</shellscript>

Okay, that shell script doesn't do anything, I know, but how would I the property "version" from within that shellscript?

I know you can do all of the above in Java scripting which is better than most uses, but in the real script I'm doing a ton of svn commands which I'll have to shell out for anyway.

Upvotes: 1

Views: 1551

Answers (2)

David Webb
David Webb

Reputation: 193716

There are some "official" SVN Ant Tasks available if you didn't want to write your own.

Otherwise, since ShellScript extends Exec you could use arguments.

<shellscript shell="bash" dir="${build.dir}"> 
  <arg value="${someproperty}"/>
   echo $1
</shellscript>

Upvotes: 1

flicken
flicken

Reputation: 15543

According to the shellscript documentation:

Embedded ant properties will be converted.

So you can use the ${variable} notation:

<shellscript shell="bash" dir="${build.dir}"> 
   echo "Version: ${version}"
</shellscript>

Upvotes: 1

Related Questions