Question

I have written a shell script with commands like:

version=$1;

sed -i 's/def version = ".*"/def version = "'$version'"/' $file;

grails package-plugin;

echo -n 'Enter description of new version: ';

read desc;

git commit -m "$desc";

I want to convert it into a groovy script i.e, to create a custom grails-command that does the same thing, using GANT.

I searched a lot. But, I'm unable to find the proper methods in Apache Ant API to run a linux command like above.

Please suggest me a solution to my shell-script code with equivalent GANT script

Atleast suggest me where to start with to achieve my task.

Thank you very much in advance...

Was it helpful?

Solution

Well at last, I have figured it out how to perform the above said task.

Thanx to Grails documentation and Apache Ant tasks manual . .

After taking a whole day time, I observed that for any task to be performed:

  1. one can refer to Apache Ant manual first,

  2. Find it in the index,

  3. and then knowing its usage along with necessary arguments and examples given in XML,

  4. Then observe how XML syntax is converted to corresponding Groovy script i.e., GANT script

    For e.g., observe the mkdir task and its corresponding usage in grails doc example i.e., use ant variable, then . task-name [ arguments-map ]

  5. For those shell commands which don't have a direct task in Apache Ant manual, use exec() to run the command

  6. That's it ... task complete :)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top