-1

我编写了一个带有以下命令的 shell 脚本:

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";

我想将其转换为groovy scriptie,以创建一个执行相同操作的自定义 grails-command,使用GANT.

我搜索了很多。但是,我无法在 Apache Ant API 中找到合适的方法来运行像上面这样的 linux 命令。

请建议我使用等效的 GANT 脚本解决我的 shell 脚本代码

至少建议我where to start with完成我的任务。

非常感谢您提前...

4

1 回答 1

0

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 :)

于 2013-06-07T05:39:29.613 回答