Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ant:javac和proc:only from Ant?_Ant_Javac_Annotation Processing - Fatal编程技术网

Ant:javac和proc:only from Ant?

Ant:javac和proc:only from Ant?,ant,javac,annotation-processing,Ant,Javac,Annotation Processing,有没有办法强制javac任务只调用注释处理,而不进行编译-proc:根据,只有javac选项应该强制执行这种行为 但是ant buildfile的以下片段: <target name="apt"> <javac srcdir="src" destdir="bin" includeantruntime="false"> <compilerarg value="-proc:only"/> </javac> </ta

有没有办法强制
javac
任务只调用注释处理,而不进行编译
-proc:根据,只有
javac选项应该强制执行这种行为

但是ant buildfile的以下片段:

<target name="apt">
    <javac srcdir="src" destdir="bin" includeantruntime="false">
        <compilerarg value="-proc:only"/>
    </javac>
</target>

无论如何编译项目。我尝试了其他
标记版本(例如,
而不是
),但没有任何帮助。

避免指定任务的“destdir”属性,或者使用空目录作为类文件的目标。然后,Ant“javac”任务将在基本目录(如果未设置“destdir”)或空目录中查找类文件。因为它在那里找不到类文件,所以它不会从编译中排除可能是最新的源代码,并从“srcdir”属性中指定的目录中对源代码执行“javac”

因此,您的代码如下所示:

<target name="apt">
    <javac srcdir="src" includeantruntime="false">
        <compilerarg value="-proc:only" />
    </javac>
</target>
<target name="apt">
    <mkdir dir="empty" />
    <javac srcdir="src" destdir="empty" includeantruntime="false">
        <compilerarg value="-proc:only" />
    </javac>
</target>

或者,如果使用空目录方法,如下所示:

<target name="apt">
    <javac srcdir="src" includeantruntime="false">
        <compilerarg value="-proc:only" />
    </javac>
</target>
<target name="apt">
    <mkdir dir="empty" />
    <javac srcdir="src" destdir="empty" includeantruntime="false">
        <compilerarg value="-proc:only" />
    </javac>
</target>


第二种方法稍微复杂一点,但更干净一点。通常,您的项目将有一个输出目录,您可以在其中放置编译的类和打包的JAR,因此在那里添加一个额外的空目录不会有任何影响。从Ant版本1.9.4开始,我没有找到任何其他方法从Ant独立于编译来进行注释处理,即使“javac”任务中的一个简单的“force”属性可以解决这个问题。

您可以尝试将带有javac.exe的任务用作可执行任务是的,但我需要javac的主要一点是编译的可能性(或者,事实上,处理注释)整个目录结构。我能用exec做同样的事情吗?所以用javac作为可执行任务