Reputation: 79
I'm trying to generate querydsl classes from groovy entities using alternative method described here http://www.querydsl.com/static/querydsl/2.7.3/reference/html/ch03s02.html
The problem I faced with is that these classes are generated only when I do mvn compile/package twice
i.e. something with the order, classes should be generated before compilation of groovy classes
otherwise I get compilation error
Groovy:unable to resolve class com.application.domain.QUser
My pom.xml
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<compilerId>groovy-eclipse-compiler</compilerId>
</configuration>
<dependencies>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-batch</artifactId>
<version>2.3.7-01</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-eclipse-compiler</artifactId>
<version>2.9.1-01</version>
<extensions>true</extensions>
</plugin>
<plugin>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>3.6.8</version>
<executions>
<execution>
<id>generate-querydsl-classes</id>
<goals>
<goal>jpa-export</goal>
</goals>
<phase>process-sources</phase>
<configuration>
<targetFolder>target/generated-sources/java</targetFolder>
<packages>
<package>com.application</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
what I'm missing?
Upvotes: 0
Views: 3850
Reputation: 384
You need to:
Compile generated QClasses again.
<plugin>
<groupId>com.mysema.querydsl</groupId>
<artifactId>querydsl-maven-plugin</artifactId>
<version>${querydsl.version}</version>
<executions>
<execution>
<id>generate-query-dsl-classes</id>
<phase>process-classes</phase>
<goals>
<goal>jpa-export</goal>
</goals>
<configuration>
<targetFolder>target/generated-sources/java</targetFolder>
<packages>
<package>com.my.package</package>
</packages>
</configuration>
</execution>
<execution>
<id>compile-query-dsl-classes</id>
<phase>process-classes</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceFolder>target/generated-sources/java</sourceFolder>
</configuration>
</execution>
</executions>
</plugin>
Upvotes: 2