Calling depends targets from parent build.xml inside includes xml

后端 未结 1 900
傲寒
傲寒 2021-01-16 11:31

Is it possible for xml files that are part of \'includes\' inside build.xml to have depends on targets from that build.xml (backwards dependency)? Or do I need to create a c

相关标签:
1条回答
  • 2021-01-16 11:50

    This works for me: In the main project file the target default depends on a target from commontasks.xml which depends on a target from the main project file:

    <project name="main" default="default">
    
      <import file="commontasks.xml" as="common" />
    
      <target name="default" depends="common.hello" description="the main project">
      </target>
    
      <target name="initMain">
        <echo>initializing main</echo>
        <property name="aValue" value="MAIN" />
      </target>
    

    <project name="commontasks" >
    
      <target name="hello" depends="initMain">
        <echo>hello from common tasks</echo>
        <echo>aValue: ${aValue}</echo>
      </target>
    

    When I run the ant build, I get:

    initMain:
     [echo] initializing main
    common.hello:
     [echo] hello from common tasks
     [echo] aValue: MAIN
    default:
    BUILD SUCCESSFUL
    

    The dependency is target default depends on hello depends on initMain and hello can use properties defined in initMain.

    0 讨论(0)
提交回复
热议问题