ant warning: “'includeantruntime' was not set”

前端 未结 7 1108
眼角桃花
眼角桃花 2020-12-04 05:00

I receive the following warning:

[javac] build.xml:9: warning: \'includeantruntime\' was not set, 
defaulting to build.sysclasspath=last; set to false for re         


        
相关标签:
7条回答
  • 2020-12-04 05:46

    As @Daniel Kutik mentioned, presetdef is a good option. Especially if one is working on a project with many build.xml files which one cannot, or prefers not to, edit (e.g., those from third-parties.)

    To use presetdef, add these lines in your top-level build.xml file:

      <presetdef name="javac">
        <javac includeantruntime="false" />
      </presetdef>
    

    Now all subsequent javac tasks will essentially inherit includeantruntime="false". If your projects do actually need ant runtime libraries, you can either add them explicitly to your build files OR set includeantruntime="true". The latter will also get rid of warnings.

    Subsequent javac tasks can still explicitly change this if desired, for example:

    <javac destdir="out" includeantruntime="true">
      <src path="foo.java" />
      <src path="bar.java" />
    </javac>
    

    I'd recommend against using ANT_OPTS. It works, but it defeats the purpose of the warning. The warning tells one that one's build might behave differently on another system. Using ANT_OPTS makes this even more likely because now every system needs to use ANT_OPTS in the same way. Also, ANT_OPTS will apply globally, suppressing warnings willy-nilly in all your projects

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