从目标总是和独立执行蚂蚁行动 [英] Execute Ant action always and independently from target
问题描述
有没有指定一个像&LT行动的方式;复制>在让每一个构建文件被蚂蚁(无论这就是所谓的目标)?
Is there a way to specify actions like <copy> in an Ant buildfile that get executed every time the build file gets read by ant (regardless of the target which is called)?
的背景是:我想要的* .properties文件从模板自动生成时,它不是present。我知道,我可以指定一个目标而做到这一点,然后将其包含在依赖关系树的根,但也许还有一个更优雅的解决方案。因为实际上这个问题是一个比较复杂的:其中的* .properties文件中读出由其他构建文件导入,我不希望他们之间交叉引用的目标蚂蚁文件
The background is: I want a *.properties-file to be automatically created from a template when it's not present. I know, I could specify a target which does this and then include it at the root of the dependency-tree but maybe there is a more elegant solution. Because actually the problem is a bit more complex: the ant file where the *.properties-file is read-out is imported by other build files and I don't want to cross-reference targets between them.
我希望我充分的解释我的问题。在问题的情况下毫不犹豫问。
I hope I explained my problem sufficiently. In cases of questions do not hestitate to ask.
这是我第一次在这里发帖。希望你能帮助 - 来自德国的问候,本
This is my first posting here. Hope you can help - Greetings from Germany, Ben.
推荐答案
只要把code。在文件的顶部,目标定义之外。
Just put the code at the top of the file, outside of a target definition.
<project name="myproject" default="mytarget" basedir=".">
<echo message="Hello there." />
<target name="mytarget">
<!-- Do stuff. -->
</target>
<target name="myothertarget">
<!-- Do other stuff. -->
</target>
</project>
在这种情况下,回声
将获得的任何目标前执行一次,无论是调用了哪些目标。
In this case the echo
will get executed once before any target, regardless of which target is invoked.
这篇关于从目标总是和独立执行蚂蚁行动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!