How to specify base dir then we run ant like ant -f somedir/dir/build.xml

前端 未结 4 1769
猫巷女王i
猫巷女王i 2021-02-13 14:29

How to specify base dir then we run ant like ant -f somedir/dir/build.xml. Ant sets basedir relative to build.xml, if I specify



        
相关标签:
4条回答
  • 2021-02-13 15:01

    another solution (if it makes more sense in some cases) could be to override basedir via the var task from the antcontrib extension as described here: https://stackoverflow.com/a/25786329/1915920

    0 讨论(0)
  • 2021-02-13 15:04

    I found, that using following solution is the easiest.

    pushd somedir/dir && ant && popd
    

    Although is seems to be to easy - it works.

    0 讨论(0)
  • 2021-02-13 15:10

    Use -D to override the basedir property:

    ant -Dbasedir=`pwd` -f path/to/build.xml
    

    The use of pwd is a Linux-only thing, but you can always put the absolute path of the current directory there if you're on another platform.

    I don't think there's a way to do this inside build.xml, short of re-executing ant with the ant task.

    0 讨论(0)
  • 2021-02-13 15:17

    You can try to use subant task:

    Assuming you have two different folders

    1. Your current folder X:/your/launching/folder where you are executing ant command from

    2. Folder where your destination bulid.xml is: Y:/any/folder/with/build.xml

    You can do the following:

    Create build.xml in X:/your/launching/folder with the next content:

    <target name="mytarget">
        <subant target="debug">
            <fileset dir="Y:/any/folder/with" includes="build.xml"/>
        </subant>
    </target>
    

    Then you can execute ant mytarget from X:/your/launching/folder folder to start building your Y:/any/folder/with/build.xml

    Update:

    You can override basedir property for subant build like this:

        <subant target="debug">
            <property name="basedir" value="./any/dir/with/project"/>
            <fileset dir="Y:/any/folder/with" includes="build.xml"/>
        </subant>
    
    0 讨论(0)
提交回复
热议问题