3

I try to compile my code that contains annotations that generate source code. I use the maven-compiler-plugin and build-helper-maven-plugin. My POM is looking like that:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.2</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
                <generatedSourcesDirectory>${project.build.directory}/generated-sources/apt</generatedSourcesDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.5</version>
            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${project.build.directory}/generated-sources/apt</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

When I run mvn compile, ${project.build.directory}/generated-sources/apt is added as a source directory, and the generated sources are generated in the correct directory. But I get compiler errors because of missing references to the generated classes. It's like the generated source directory is not included in the compilation process.

I also try apt-maven-plugin which does not generate anything. And maven-annotation-plugin but it behaves as describe above.

Sydney
  • 11,964
  • 19
  • 90
  • 142

3 Answers3

1

The release 2.0.7-SNAPSHOT of maven-annotation-plugin should solve the problem

bsorrentino
  • 1,413
  • 11
  • 19
1

fwiw I just downgraded from 3.0 to 2.5.1 and fixed an issue I was seeing with APT processing not being executed after a few runs, using maven so just downgraded one version:

http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22org.apache.maven.plugins%22%20AND%20a%3A%22maven-compiler-plugin%22

HaveAGuess
  • 1,231
  • 1
  • 13
  • 23
0

Can you try with the latest version of maven compiler plugin (2.3.2)?

Also build-helper-maven-plugin is not required since it looks like you are using the maven-compiler-plugin itself to generate the sources from the annotation.

Raghuram
  • 51,854
  • 11
  • 110
  • 122
  • I had the same issue, it works fine with `2.3.2`, there is a "false error" about `missing symbol` definitions but it's just on the first pass to generate the *Metamodel* – dcestari Feb 24 '11 at 00:01