У меня была похожая потребность, и я закончил писать пользовательское задание, которое выглядит так:
<!-- a task that executes the embedded sequential element at the end of the build,
but only if the nested condition is true; in this case, we're dumping out the
properties to a file but only if the target directory exists (otherwise, the clean
target would also generate the file and we'd never really be clean!) -->
<build:whendone>
<condition>
<available file="${project_target-dir}" />
</condition>
<sequential>
<mkdir dir="${project_final-build-properties-file}/.." />
<echoproperties destfile="${project_final-build-properties-file}" />
</sequential>
</build:whendone>
В этом случае мне нужна была запись всех свойств Ant, которые внесли вклад в сборку, но выполнение этого в начале сборки пропускает довольно много (если они инициализируются как часть целей после сброса их) в файл).
К сожалению, я не могу поделиться конкретным кодом, но это не что иное, как Ant Task
, который реализует SubBuildListener
, в частности buildFinished(BuildEvent)
. Слушатель проверяет встроенное условие, а затем, если true
, выполняет встроенное sequential
.
Я бы хотел знать, есть ли лучший способ.