移动蚂蚁DIR项目蚂蚁或subant任务完成后, [英] Move a ant dir project after the ant or subant task completes
问题描述
目前我使用一个shell脚本来做到以下几点:
Currently i'm using a shell script to do the following:
cd myproject1/
ant
cd ..
if grep 'sucessful' myproject/buil.log then move myproject ../backup/today/
等了myproject2,myproject3。
And so on for myproject2, myproject3.
如果一些错误发生,该项目停留在当前目录重新处理,但整个过程将继续。
If some error happens, the project stay in the current dir to be reprocessed but the whole process continues.
我想这个过程中迁移到Ant生成脚本,但我对如何做到这一点毫无头绪。
I want to migrate this process to an ant build script but i have no clue on how to do this.
我已经看过蚂蚁和subant任务。蚂蚁看起来更适合的工作,但我不是可以通过一个目录列表使用蚂蚁togheter找到一种方式来循环移动的任务,如果Ant任务完成或不检查。
I have looked at ant and subant tasks. Ant looks more suitable to the job but i can't find a way to loop through a directory list using ant and move task togheter, checking if the ant task completes or not.
感谢您。
推荐答案
结帐这样的回答:
<一个href=\"http://stackoverflow.com/questions/9132766/running-specific-target-in-different-ant-scripts-in-different-directories/9140052#9140052\">running在不同的目录不同的Ant脚本特定目标
我建议你的子模块构建应该抛出一个错误,而不是试图复制日志解析逻辑。
I recommend that your submodule builds should throw an error rather than try and duplicate the log parsing logic.
如果这是旨在支持部署,或许你应该考虑Groovy脚本?
将更好地支持异常情况:
If this is designed to support deployment, perhaps you should consider a groovy script? Would better support exception conditions:
def ant = new AntBuilder()
scanner = ant.fileScanner {
fileset(dir:".", includes:"test*/build.xml")
}
scanner.each { f ->
try {
ant.ant(antfile:f)
}
catch (e) {
ant.mkdir(dir:"backup")
ant.move(todir:"backup", file:f.parent)
}
}
Groovy中具有优异的ANT集成,也可嵌入Ant构建中:
Groovy has excellent ANT integration and can also be embedded within your ANT build:
<target name="run">
<taskdef name="groovy" classname="org.codehaus.groovy.ant.Groovy" classpathref="build.path"/>
<fileset id="buildFiles" dir="." includes="test*/build.xml"/>
<groovy>
project.references.buildFiles.each {
def f = new File(it.toString())
try {
ant.ant(antfile:f)
}
catch(e) {
ant.mkdir(dir:"backup")
ant.move(todir:"backup", file:f.parent)
}
}
</groovy>
</target>
这篇关于移动蚂蚁DIR项目蚂蚁或subant任务完成后,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!