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

m2e usage

Paul Verest edited this page Jun 23, 2016 · 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 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