Creating QueryDsl Q classes from a package

How to create QueryDsl Q-classes by specifying only the package name? Given that the source classes are in my target / generated-sources folder, as they are the product of other build plugins (WSDL, XSD, etc.).

I tried using the following plugins, but cannot find the correct configuration:

<groupId>com.mysema.querydsl</groupId> <artifactId>querydsl-maven-plugin</artifactId> <version>2.9.0</version> <executions> <phase>generate-sources</phase> <goals> <goal>process</goal> </goals> <configuration> <outputDirectory>target/generated-sources</outputDirectory> <processor>${com.mysema.query.apt.ProcessorClass}</processor> </configuration> </executions> 

and

 <groupId>com.mysema.maven</groupId> <artifactId>maven-apt-plugin</artifactId> <version>1.0.4</version> 

What I would like to do is something like this:

 <configuration> <packageName>com.my.package</packageName> <sourceFolder>target/generated-sources</sourceFolder> <targetFolder>target/generated-sources/querydsl</targetFolder> </configuration> 

... which will generate classes:

  • com.my.package.QFoo.java
  • com.my.package.QBar.java

Since there is no general JPA or JDO annotation, and I do not have access to the source files, I could not use any of com.mysema.query.apt.*Processor for maven-apt-plugin <processor> .

EDIT 1: Added full maven-apt-plugin configuration.

EDIT 2: - I managed to get maven-apt-plugin to work sporadically through the maven command line, but not Eclipse / STS, extending AbstractQuerydslProcessor to look for @XmlType XmlType-annotated classes. Dual code generation is admittedly not an ideal solution.

+4
source share
1 answer

The answer is to create Q classes using the Timo strategy outlined here: https://github.com/mysema/querydsl/issues/196

In my module package-info.java :

 @QueryEntities({ com.remote.module.Foo.class, com.remote.module.Bar.class }) package com.my.local.module.querydsl; import com.mysema.query.annotations.QueryEntities; 

Plugin execution in Maven POM:

 <plugin> <groupId>com.mysema.maven</groupId> <artifactId>apt-maven-plugin</artifactId> <executions> <execution> <id>apt-maven-plugin-remote-module-QuerydslAnnotationProcessor</id> <goals> <goal>process</goal> </goals> <configuration> <outputDirectory>target/generated-sources</outputDirectory> <showWarnings>true</showWarnings> <!-- genereate Q-classes specified in package-info.java --> <processor>com.mysema.query.apt.QuerydslAnnotationProcessor</processor> </configuration> </execution> </executions> <dependencies> <dependency> <groupId>com.mysema.querydsl</groupId> <artifactId>querydsl-apt</artifactId> </dependency> </dependencies> </plugin> 
+5
source

All Articles