Apt task with Java 1.6?
I have some automatically generated Ant build scripts that I need to use to build an application. I am using Ant 1.8.1 and Java 1.6. The scripts use the Apt Ant task, which according to the task reference is pretty much obsolete in Java 1.6 because it can process annotations in the compiler. However, the Apt targets generate extra classes that my application needs and I haven't been able to find a way to replicate this using javac.
The problem is, when the scripts are executed, the Apt task fails complaining that it needs a JDK of 1.5+ even though I have a 1.6 JDK installed. I have tried replacing the <apt>
tags with <javac>
tags, copying across as many of the attributes as I can, but doing that the build falls over when looking for classes that should have been generated by the <apt>
task.
I am at my wits end and am just wondering if there is any way of getting the Apt task to play nice with Java 1.6, or indeed any other means of doing the same work as Apt with different tasks that I might have missed?
Found the solution - and it was simpler than I would have thought.
To fix the scripts, I just had to switch to an older version of Ant. Weblogic ships with Ant 1.6.5, and after pointing my ANT_HOME to this version rather than the Apache 1.8.1 the scripts ran without any complaints.
精彩评论