Krish
Krish

Reputation: 4232

How to run ant apt task on java 1.8 version

On Ant Apt trying to build ant apt task on java 1.8 will crash. But in application that i have to change i must use this task because it is built with ant

Anyone have any idea how to avoid this crash and run Ant apt task on java 1.8?

Upvotes: 0

Views: 765

Answers (1)

quotidian-ennui
quotidian-ennui

Reputation: 126

If you are using java8; then you don't need to run the apt task directly; it can happen behind the scenes.

From ANT's own documentation :

This task runs on Java 1.5 to Java 1.7.

Apt is deprecated in Java 1.6, which can run annotation processors as part of javac, and removed from the distribution in Java 1.8. The task will fire an exception when attempting to run under Java 1.8.

However, all that means is that you need to make sure that your custom annotation processor is in the classpath at the point of executing javac.

   <javac source="${javac.version}" target="${javac.version}" destdir="${classes.build.dir}" srcdir="${src.dir}" debug="on" debuglevel="source,lines">
      <classpath>
        <!-- make sure this has "my-annotation-processor.jar" -->
        <path refid="main.classpath"/>
      </classpath>
    </javac>

Upvotes: 0

Related Questions