0
votes

I have an open-source project that I added to my project source. The oss-project currently builds stand-alone using ant and its build.xml.

I want to build this project as a part of my project. My directory structure looks like this:

my-project\
  build.xml
  oss-project\
     build.xml
     {all the code}

I tried to import the oss-project\build.xml into my-project\build.xml.

<import file="${source_base}/oss-project/build.xml"/>

My build.xml defines basedir, source.base etc. variables and the imported xml also contains these variables. But, when i try to build by running "ant" at my source root, while building the oss-project, it's using the variables defined in parent build.xml.

I could probably create unique names be prefixing all variables in my oss-project\build.xml with that project name. But, its starting to look ugly. And then hard to keep it in sync in future as well.

Is there a way by which the variables defined inside the child build.xml are not overridden by the once in parent build.xml?

1
What is your end goal? To have one jar with everything in it, or to build both projects in succession with one invocation of Ant?user439793

1 Answers

3
votes

(in this case) You should not import build.xml. Instead it should delegate the child build to the appropriate build file. You can use ant task for it

Your top level build should have entry like below..

   <ant dir="${source_base}/oss-project/"/>