build - ant large project. How to enforce common output directory structure - include,import and inhertAll=false? -


i have toplevel ant project , many subprojects under it.

./build.xml ./datamodel_src/src/build.xml ./datamodel_src/src/module1/build.xml ./datamodel_src/src/module2/build.xml ./infrastructure_src/src/build.xml ./interfaces_src/src/build.xml 

each of subproject, want enforce common output directory structure. project have work area , each sub project have own work area under it. each subproject should create artifacts (lib, docs, classes etc) under work area subproject.

so output thing like

c:/sandbox/mainprojectworkarea/subprojectworkarea/lib c:/sandbox/mainprojectworkarea/subprojectworkarea/docs c:/sandbox/mainprojectworkarea/subprojectworkarea/classes 

currently follows.

the toplevel build.xml below

<project name="toplevelproject" default="compile" basedir=".">     <target name="compile">         <ant dir="infrastructure_src/src" />         <ant dir="interfaces_src/src " /> <!--does not work-->         <ant dir="datamodel_src/src inhertall=false" /> <!--works-->     </target> </project> 

common.xml below

<property environment="env" /> <property name="project.sandbox" value="${env.build_home}/sandbox" /> <property name="sandbox"  value="${project.sandbox}" /> <property name="pwa"  value="${sandbox}/pwa" /> <property name="wa"  value="${pwa}/${ant.project.name}" /> <property name="build"  value="${wa}/build" /> <property name="lib"  value="${wa}/lib" /> <property name="docs"  value="${wa}/docs" /> <property name="exports"  value="${wa}/exports" /> 

this "included" projects. example "datamodel_src/src/build.xml" below

<!doctype project [        <!entity common system "../../common.xml"> ]>  <project name="dmodel" default="compile" basedir=".">     &common;     <target name="compile">         <echo  message="will create lib  in  ${lib}"/>         <echo  message="will create docs  in  ${docs}"/>         <ant dir="module1" inheritall="false"/> <!--works fine-->         <ant dir="module2" /> <!--does not work -->     </target>    </project> 

this works when set inhertiall=false ant calls.

is there better , correct way to?

expanding answer kevin question. using import common.xml becomes real project below

<project name="toplevelproject" default="compile" basedir=".">     <property name="toplevel" value="settotrue"/>     <target name="compile">         <ant dir="infrastructure_src/src" />         <ant dir="interfaces_src/src" />         <ant dir="datamodel_src/src" />     </target> </project> 

the "datamodel_src/src/build.xml" think below.

<project name="dmodel" default="compile" basedir=".">     <import file="../../common.xml" />     <target name="compile">         <echo  message="will create classes in  ${build}"/>         <echo  message="will create lib  in  ${lib}"/>         <ant dir="module1" inheritall="false"/> <!--works fine-->         <ant dir="module2" /> <!--does not work -->     </target> </project> 

the import gives option have common targets etc, hence go it.

i'm doing similar using imports rather includes. common targets , properties defined in common build file , each subproject imports common file. when import file, properties defined in file become relative importing file.

so try doing following:

  1. move compile target subproject build files common.xml.

  2. import common.xml each subproject build.xml.


Comments

Popular posts from this blog

WPF: binding viewmodel property of type DateTime to Calendar inside ItemsControl -

java - Getting corefrences with Standard corenlp package -

jQuery clickable div with working mailto link inside -