Perform an Ant action always and regardless of purpose

Is there a way to specify actions such as <copy> in the Ant build file that runs every time the build file is read using Ant (regardless of the target being invoked)?

Background: I want the * .properties file to be automatically created from the template when it is not present. I know, I could point out the goal that does this, and then include it in the root of the dependency tree, but maybe there is a more elegant solution. Because the problem is actually a bit more complicated: the Ant file, in which the * .properties file is read, is imported by other assembly files, and I do not want to cross-reference the targets between them.

I hope I have explained my problem in sufficient detail. In case of questions do not ask questions.

This is my first post here. I hope you can help. - Hello from Germany, Ben.

+3
source share
1 answer

Just put the code at the top of the file outside the 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, echo will be executed once before any target, regardless of which target is invoked.

+5
source

Source: https://habr.com/ru/post/1442631/


All Articles