1

I'm writing a shell script to automate an elaborate build process. It includes execution of multiple ant scripts located in different directories.

The shell script is in my home directory, while the ant scripts are located in: /opt/myApp/module1/ ant -f patch.xml, and /opt/myApp2/module2 ant build.xml.

How can I invoke ant command in my shell script, from a different folder location?

1

You can create a module in master ant file which contains corresponding ant files. For eg:

You can make a master file as

/opt/Makefile

all:
(make module1)
(make module2)

module1:
(cd myApp/module1/; ant -f patch.xml)

module2:
(cd myApp2/module2; ant -buildfile build.xml)

Then you can run the master Makefile as:

$ make Makefile all

0

Just as VAR=/opt/myapp and then using $VAR to substitute the value. Like $VAR/module1/ant -f patch.xml

  • Which shell uses the syntax $(VAR) ? – Angelo Feb 19 '18 at 4:07
  • My bad. Sorry. Remove the parentheses. – GLaDOS Feb 19 '18 at 4:22
  • Thanks for your reply, but that's not what I'm asking for. I need to invoke the ant execution from my shell script – CuriousCoder Feb 19 '18 at 7:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.