7

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>
Alec
  • 8,529
  • 8
  • 37
  • 63
Alex
  • 483
  • 1
  • 10
  • 21

3 Answers3

4

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>
SourceVisor
  • 1,868
  • 1
  • 27
  • 43
ILX
  • 336
  • 4
  • 10
1

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>
Kazuhiro Sera
  • 1,822
  • 12
  • 15
1

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.

Timo Westkämper
  • 21,824
  • 5
  • 78
  • 111
  • In the Eclipse Console window, at the maven-apt-plugin:1.0.2:process stage I get some red text output (not logging) stating that symbols not found. This is for any class that references the QDSL generated classes. – Alex Nov 10 '11 at 11:06
  • The tests that as run as part of the mvn install then fail as Spring fails for unresolved compiler errors. If I redo the mvn install straight afterwards it all works perfectly. – Alex Nov 10 '11 at 11:11
  • Following up from Ralph's comment above, if I run mvn clean, and then mvn install from the command line, I see the same output from the maven-apt-plugin regarding symbols not found, however I have no problems with the tests failing. So this problem is only experienced within Eclipse – Alex Nov 10 '11 at 11:25
  • Maybe for the build you could configure Eclipse's own APT. That might work better than M2E + APT. Did you have similar problems with the JPA Criteria API? – Timo Westkämper Nov 10 '11 at 16:44
  • I used the M2E querydsl configurer as documented here https://github.com/ilx/m2e-querydsl/issues/1 and https://bugs.eclipse.org/bugs/show_bug.cgi?id=349935 Can you verify whether you have experienced problems with the setup I'm using ? – Alex Nov 10 '11 at 20:47
  • Sorry, I don't use m2e. Why not ask Ivica Loncar directly. He wrote that integration and seems to know more about the subject than me. – Timo Westkämper Nov 10 '11 at 21:08
  • Alex sent me a sample project. It seems it's not related to the m2e plugin but to the way m2e works with unit tests. – ILX Nov 13 '11 at 15:35