ant warning: "'includeantruntime' was not set"
Solution 1
Ant Runtime
Simply set includeantruntime="false"
:
<javac includeantruntime="false" ...>...</javac>
If you have to use the javac
-task multiple times you might want to consider using PreSetDef
to define your own javac
-task that always sets includeantruntime="false"
.
Additional Details
From http://www.coderanch.com/t/503097/tools/warning-includeantruntime-was-not-set:
That's caused by a misfeature introduced in Ant 1.8. Just add an attribute of that name to the javac task, set it to false, and forget it ever happened.
From http://ant.apache.org/manual/Tasks/javac.html:
Whether to include the Ant run-time libraries in the classpath; defaults to yes, unless build.sysclasspath is set. It is usually best to set this to false so the script's behavior is not sensitive to the environment in which it is run.
Solution 2
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
Solution 3
Chet Hosey wrote a nice explanation here:
Historically, Ant always included its own runtime in the classpath made available to the javac task. So any libraries included with Ant, and any libraries available to ant, are automatically in your build's classpath whether you like it or not.
It was decided that this probably wasn't what most people wanted. So now there's an option for it.
If you choose "true" (for includeantruntime), then at least you know that your build classpath will include the Ant runtime. If you choose "false" then you are accepting the fact that the build behavior will change between older versions and 1.8+.
As annoyed as you are to see this warning, you'd be even less happy if your builds broke entirely. Keeping this default behavior allows unmodified build files to work consistently between versions of Ant.
Solution 4
The answer from Daniel works just perfect. Here is a sample snippet that I added to my build.xml:
<target name="compile">
<mkdir dir="${classes.dir}"/>
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="false">
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^ -->
<classpath>
<path id="application" location="${jar.dir}/${ant.project.name}.jar"/>
<path id="junit" location="${lib.dir}/junit-4.9b2.jar"/>
</classpath>
</javac>
</target>
Solution 5
Use <property name="build.sysclasspath" value="last"/>
in your build.xml file
For more details search includeAntRuntime
in Ant javac
Other possible values could be found here
user496949
Updated on July 08, 2022Comments
-
user496949 almost 2 years
I receive the following warning:
[javac] build.xml:9: warning: 'includeantruntime' was not set, defaulting to build.sysclasspath=last; set to false for repeatable builds
What does this mean?
-
user496949 about 13 yearsApache Ant(TM) version 1.8.2 compiled on December 20 2010
-
Daniel Kutik about 13 yearsso if you need the ant runtime in the classpath set it to yes/true otherwise to no/false. i guess you don't need it.
-
Jonik almost 13 years+1, Great answer. I just wish I could set that once somewhere in the buildfile instead of littering every javac call with it...
-
karmakaze about 12 yearsI always thought this was the most silly feature/message ever. Who wants 'repeatable builds' in their configuration management tool? ;)
-
saxman almost 12 yearsWorks great for retrofitting an existing Ant build file with multiple javac tasks. The presetdef element goes just inside project element.
-
Stuart Golodetz over 11 years@jwfearn: Can a similar
presetdef
trick be made to work for non-built-in Ant tasks? I've tried this withscalac
, but because lower-downbuild.xml
files have to manually define thescalac
task, they override whatever I set at the top-level. -
mikijov over 11 yearsA note, that using presetdef will cause an ant warning that javac task has been redefined. Addind includeantruntime to each javac task avoids this. I am not aware of downsides of the warning. But this might be useful for people who 'need' clean builds.
-
mike jones over 11 yearsYes the presetdef gives "Trying to override old definition of task javac"
-
Paul Vargas almost 8 yearsThis helps me a lot. I'm using
set ANT_OPTS=-Xms40M -Xmx512M -Dbuild.sysclasspath=ignore
. -
Lorenzo Lerate over 7 yearsWhat does it any case it is set to True?
-
Daniel Kutik over 7 years"Whether to include the Ant run-time libraries in the classpath; defaults to yes, unless build.sysclasspath is set. It is usually best to set this to false so the script's behavior is not sensitive to the environment in which it is run."
-
t.y about 6 yearsThis answer seems to be the only one that tells us what the warning actually means.
-
deepakl.2000 almost 2 yearsIm facing an ant issue