antverbosity

How do you determine within Ant whether verbose is enabled?


Within an ant build.xml, I want to influence a child process's verbose flag based on whether ant itself was run with verbose enabled. Is there a variable set to determine this? Or otherwise, can I parse the raw Ant command line somehow to check whether -v is passed?


Solution

  • The property sun.java.command contains command line options

    <project >
        <condition property="verbose" value="true">
            <contains string="${sun.java.command} " substring=" -v " />
        </condition>
        <property name="verbose" value="false" />
    
    </project>
    

    Suggested edit by @carl verbiest ( I did not verify ):

    <project >
        <condition property="verbose" value="true">
            <contains string="${sun.java.command} " substring=" -v " />
        </condition>
        <property name="verbose" value="false" /> 
    </project>