How to run ant apt task on java 1.8 version

微笑、不失礼 提交于 2020-01-25 08:05:49

问题


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?


回答1:


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>


来源:https://stackoverflow.com/questions/58483258/how-to-run-ant-apt-task-on-java-1-8-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!