The best way I know to accomplish this type of modularity in Ant is to create an ant file to contain the common targets (call it common-targets.xml
or whatever you like), and use the import
task in the build-[n].xml
property files. If you have troubles with properties not sharing the way you like, you should also look at utilizing macrodef
.
How to achieve modular Ant builds?
-
29-06-2022 - |
Вопрос
I would like to have a "modular" (reusable) Ant build that I can reuse across multiple projects. The build might be able to take a project (directory) name as input and run the same common targets on various projects' source code. This is to prevent having the same exact (or nearly exact) build.properties
and build.xml
files for each and every project.
So, given the following setup:
build-base.properties
is a "base" props file, containing properties that will exist for all buildscriptsbuild-1.xml
uses properties defined inbuild-base.properties
as well asbuild-1.properties
build-2.xml
uses properties defined inbuild-base.properties
as well asbuild-2.properties
build-3.xml
uses properties defined inbuild-base.properties
as well asbuild-3.properties
, and uses targets defined in bothbuild-1.xml
andbuild-2.xml
What would build-3.xml
need to look like (basic structure) to import/use build-base.properties
properties, and have access to build-1.xml
/build-2.xml
targets? Thanks in advance!
Решение
Не связан с StackOverflow