Annotation processor generated code

Hi

I have bounced into a few problems related to annotation processors.

1) Shouldn't annotation processor discovery be enabled by default? It would make things easier since developers would not have to care if there are annotation processors in libraries. This would be inline with how javac works also.

2) Maven compile source files to target/generated-sources/annotations by default, shouldn't intellij do the same?

3) I cannot change the source generation path from Preferences > Compiler > Annotation Processors > Default > Production sources directory. Is this a bug?

Ideally developers shouldnt need to do anything when using libraries that have annotation processors - builds should _just_work_ without manual configuration, right? It would be a huge win if intellij follows Maven in terms of configuration and default behaviour.

Cheers,
-Kristoffer

2 comments
Comment actions Permalink

The only way that I can make intellij and Maven to play nicely is to turn off annotation processing in intellij and drive source generation from Maven.

I also need to add the following Maven plugin to make intellij recognize generated source files.

<plugin>
  <groupId>org.codehaus.mojo</groupId>
  <artifactId>build-helper-maven-plugin</artifactId>
  <executions>
    <execution>
      <id>add-source</id>
      <phase>generate-sources</phase>
      <goals>
        <goal>add-source</goal>
      </goals>
      <configuration>
        <sources>
          <source>${basedir}/target/generated-sources/annotations</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>


Is there any way to make annotation procssing work properly from intellij?

0
Comment actions Permalink

I'm having a similar problem. We use Weblogic Pageflows which use annotations to create Struts configurations (yeah, I know). Our Maven build looks like this:

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>
apt-maven-plugin</artifactId>
<version>
1.0-alpha-5</version>
<executions>
<execution>
<phase>
generate-sources</phase>
<goals>
<goal>
process</goal>
</goals>
<configuration>
<options>
<option>
x=3</option>
<option>
web.content.root=${basedir}/src/main/webapp</option>
</options>
<fork>
true</fork>
<executable>
${olt.jdk.home}/bin/apt</executable>
</configuration>
</execution>
</executions>
</plugin>

which puts the created config files from the module in \target\classes\_pageflow

I have tried a million ways to get IDEA to do this but have had no success. The only way I can get IDEA to build my ear and include the necessary files is to first do a Maven build then add the '_pageflow' directory to the <output root> of my war artifact. There has to be a better way. Help!

0

Please sign in to leave a comment.