Question

I've got an Eclipse Maven project for spring-data-jpa and QueryDsl.

I seem to have a problem with the maven-apt-plugin where if I do a mvn clean followed by a mvn install, it tries to "process" files that reference the QueryDsl generated files, but these generated files have not yet been built so I get multiple "cannot find symbol" errors.

If then have to do another mvn install, everything is ok as the generated files now exist.

Does this maven-apt-plugin need to process every file in my project, or can I give it a specified directory ?

Note: Im using JDK6, Eclipse Indigo, M2E 1.0.100

My POM is:

<project>
  ....
  <build>
    <plugins>
      <plugin>
        <groupId>com.mysema.maven</groupId>
        <artifactId>maven-apt-plugin</artifactId>
        <version>1.0.2</version>
        <executions>
          <execution>
            <phase>generate-sources</phase>
            <goals>
              <goal>process</goal>
            </goals>
            <configuration>
              <outputDirectory>target/generated-sources</outputDirectory>
              <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ....
</project>
Was it helpful?

Solution

Alex, try to define build-helper:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>build-helper-maven-plugin</artifactId>
    <version>1.7</version>
    <executions>
        <execution>
            <id>add-source</id>
            <phase>generate-sources</phase>
            <goals>
                <goal>add-source</goal>
                <goal>add-test-source</goal>
            </goals>
            <configuration>
                <sources>
                    <source>target/generated-sources</source>
                    <source>src/main/java</source>
                </sources>
            </configuration>
        </execution>
    </executions>
</plugin>

OTHER TIPS

Do you get errors or just warnings? You can add the true to reduce the error logging.

This kind of logging is a part of APT, since in the first run before types have been generated, the sources inspection sees references to nonavailable types.

I got many "cannot find symbol" logging (and the processing succeeded), too. It seems to be related with the following issue.

https://github.com/mysema/maven-apt-plugin/issues/2

Fixed by adding the following options.

<logOnlyOnError>true</logOnlyOnError>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top