alexanoid
alexanoid

Reputation: 25770

QueryDSL maven set up project

I'm followed instructions described in this document http://www.querydsl.com/static/querydsl/2.1.0/reference/html/ch02s02.html

After this, in my Eclipse I have a following error:

Plugin execution not covered by lifecycle configuration: com.mysema.maven:maven-apt-plugin:1.0:process (execution: default, phase: generate-sources)    pom.xml /projectname    line 266    Maven Project Build Lifecycle Mapping Problem

Also, as suggested in QueryDSL documentation I have performed

mvn eclipse:eclipse

in order to include target/generated-sources/java as a source folder and now I have a lot of warnings:

enter image description here

So my questions are:

  1. Is it a correct way to fix Plugin execution error by adding a following to my pom.xml:

    <pluginManagement>
        <plugins>
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        com.mysema.maven
                                    </groupId>
                                    <artifactId>
                                        maven-apt-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.0,)
                                    </versionRange>
                                    <goals>
                                        <goal>process</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
     </pluginManagement>
    
  2. Is there a better way in order to include target/generated-sources/java as a source folder without performing mvn eclipse:eclipse ?

Upvotes: 0

Views: 1710

Answers (2)

renanleandrof
renanleandrof

Reputation: 6997

The correct goal to generate sources is: mvn generate-sources

This will create the QueryDSL querys before the compile.

Also, the documentation you are looking is for QueryDSL 2.x versions.

Check the newest version! http://www.querydsl.com/static/querydsl/4.0.7/reference/html_single/

Upvotes: 1

alexanoid
alexanoid

Reputation: 25770

I have fixed these issues by adding the following plugins:

            <plugin>
                <groupId>com.mysema.maven</groupId>
                <artifactId>apt-maven-plugin</artifactId>
                <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>
            </plugin>

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

Upvotes: 0

Related Questions