Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to compile the annotation processor with Ant?
    primarykey
    data
    text
    <p>The question seems to be obvious, but the implementation is pretty hard for me.</p> <p>My goal is to write <em>Ant build script</em> to <strong>compile some classes that require another classes generated</strong> by Annotation Processor. I have a custom annotations and it's processor implementation (inherited from <code>AbstractProcessor</code> class).</p> <p>As I understand I need to:</p> <ol> <li>Compile the Annotation Processor </li> <li>Run the compiler over some annotated classes to generate the new ones.</li> <li>Compile the classes that require generated classes</li> </ol> <p>The code (step 1 &amp; 2):</p> <hr> <pre><code>&lt;target name="compileAnnotationProcessor"&gt; &lt;javac destdir="${OUTPUT_DIR}" debug="true" failonerror="true" includeantruntime="false" classpath="${java.class.path}"&gt; &lt;src&gt; &lt;pathelement path="${PROJECT_DIR}/tools/src"/&gt; &lt;/src&gt; &lt;include name="/path/to/annotation/processor/package/**"/&gt; &lt;/javac&gt; &lt;/target&gt; &lt;target name="generateFilesWithAPT" depends="compileAnnotationProcessor"&gt; &lt;javac destdir="${OUTPUT_DIR}" includeantruntime="false" listfiles="false" fork="true" debug="true" verbose="true"&gt; &lt;src&gt; &lt;pathelement path="${PROJECT_DIR}/common/src/"/&gt; &lt;/src&gt; &lt;include name="/path/to/files/to/compile/**"/&gt; &lt;classpath&gt; &lt;pathelement path="${OUTPUT_DIR}"/&gt; &lt;pathelement path="${java.class.path}"/&gt; &lt;/classpath&gt; &lt;compilerarg line="-proc:only"/&gt; &lt;compilerarg line="-processorpath ${OUTPUT_DIR}/path/to/annotation/processor/package/annProcessorImplement"/&gt; &lt;/javac&gt; &lt;/target&gt; </code></pre> <hr> <p>Actually, the first task is performing good and compiles the .class file for the Annotation processor implementation. It is stopping at 2nd task.</p> <p>Ant says: <code>Annotation processing without compilation requested but no processors were found.</code></p> <p>What am I doing wrong? Maybe I should put the annotation processor class in a <code>.jar</code>? Or provide a file name with .class extension as <code>-processorpath</code> argument? I tried several options but nothing helps..</p> <hr> <p>Notes:</p> <p>I'm using ant <code>javac</code> task instead of <code>apt</code>one because <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/apt/GettingStarted.html" rel="nofollow noreferrer">documentation</a> claims that apt tool as well as <code>com.sun.mirror</code> API is deprecated. I've also looked through this <a href="https://stackoverflow.com/questions/3644069/java-6-annotation-processing-configuration-with-ant">question</a>, but there is no information how to compile the processor in right way.</p> <p>I'm using:</p> <ul> <li>Java 1.6 </li> <li>Ant 1.8.2</li> </ul>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload