Skip to content
This repository has been archived by the owner on Jul 30, 2021. It is now read-only.

m2e usage

Karl Pihlblad edited this page Oct 22, 2019 · 8 revisions

The apt-maven-plugin needs to be configured slightly different if it is to be used with m2e.

The following example illustrates how to use plugin with Querydsl JPA.

<plugin>
  <groupId>com.mysema.maven</groupId>
  <artifactId>apt-maven-plugin</artifactId>
  <version>1.0.5</version>
  <executions>
    <execution>
      <goals>
        <goal>process</goal>
      </goals>
      <configuration>
        <outputDirectory>target/generated-sources/java</outputDirectory>
        <processor>com.mysema.query.apt.jpa.JPAAnnotationProcessor</processor>
      </configuration>
    </execution>
  </executions>
  <dependencies>
    <dependency>
      <groupId>com.mysema.querydsl</groupId>
      <artifactId>querydsl-apt</artifactId>
      <version>${querydsl.version}</version>
    </dependency>
    <dependency>
      <groupId>com.mysema.querydsl</groupId>
      <artifactId>querydsl-jpa</artifactId>
      <classifier>apt</classifier>
      <version>${querydsl.version}</version>
    </dependency>
  </dependencies>
</plugin>

The querydsl-apt dependency contains the general apt logic of Querydsl and querydsl-jpa with the apt classifier contains the necessary JPA dependencies and the APT service descriptor for the JPAAnnotationProcessor.

Generated source folder

You may need make sure that generated source folder is added to Eclipse project .classpath for project to be without errors and warnings. Take a look at http://stackoverflow.com/questions/7160006/m2e-and-having-maven-generated-source-folders-as-eclipse-source-folders, where suggested solution is

<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>${project.build.directory}/generated-sources/java/</source>
        </sources>
      </configuration>
    </execution>
  </executions>
</plugin>

and make Eclipse IDE to discover and install m2e connector.

Clone this wiki locally