Customize package for QueryDSL output
Question
I am creating QueryDSL objects for MongoDB using Maven, here's the build xml,
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<plugins>
<plugin>
<groupId>com.mysema.maven</groupId>
<artifactId>maven-apt-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>process</goal>
</goals>
</execution>
</executions>
<configuration>
<outputDirectory>src/main/java</outputDirectory>
<!-- This processor uses the Spring MongoDB annotations for processing -->
<processor>org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor</processor>
</configuration>
</plugin>
</plugins>
</build>
But its generating the query class QDomain
for Domain
in the same package as Domain
.
Can the plugin be customized to put Query classes in a separate package?
Solution
You can use the querydsl.packageSuffix APT option to add a suffix to your generated package. Just add the following block inside configuration
<options>
<querydsl.packageSuffix>.query</querydsl.packageSuffix>
</options>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow