Ant and Java assertions (Enable Java assertions in Ant)

Enable Java assertions in Ant (FAQ): How do I enable Java assertions in Ant?

Here's something that should have been a little more obvious to me: how to enable assertions when compiling Java code that uses the version 1.4 "assertions" feature:

  <javac destdir="${build.dir}/classes" source="1.4">

Of course I'm skipping the details in between, but the bold characters in the first line of my build.xml file are the most important in terms of enabling assertions in Ant while performing a javac/compile task.

I'm still trying to get comfortable with where to use assertions and where not to, but this was a major stumbling block when using Ant inside of Intellij. Now that I'm through that, I can get back to the important question: "When should I use assertions, and when shouldn't I?"


Add new comment

Anonymous format

  • Allowed HTML tags: <em> <strong> <cite> <code> <ul type> <ol start type> <li> <pre>
  • Lines and paragraphs break automatically.