DataQL Maven 插件

DataQL Maven 插件的作用是,根据 DataQL 查询文件生成对应的查询工具类。从而Java应用程序中使用 DataQL 查询能力更加方便快捷。

引入插件

  1. <plugin>
  2. <groupId>net.hasor</groupId>
  3. <artifactId>dataql-maven-plugin</artifactId>
  4. <version>4.1.1</version>
  5. <executions>
  6. <execution>
  7. <goals>
  8. <goal>dataql</goal>
  9. </goals>
  10. </execution>
  11. </executions>
  12. </plugin>

插件会扫描 sourceDirectory 配置的路径中所有 .ql 结尾的查询文件,并在 outputSourceDirectory 配置的路径下自动生成对应的 Java 代码,原始的 Query 查询文件会拷贝到 outputResourceDirectory 配置的目录下。

各个配置的默认值

满足条件默认值
outputSourceDirectory${project.build.directory}/generated-resources/dataql
outputResourceDirectory${project.build.directory}/generated-sources/dataql
sourceDirectory${basedir}/src/main/java

插件工作在 GENERATE_SOURCES 阶段,依赖的范围是:COMPILE

下面这个接口是生成的类的接口模板

  1. public class ListOptionQuery extends HintsSet implements Query {
  2. // 构造方法
  3. private ListOptionQuery(HintsSet hintsSet) { ... }
  4. public ListOptionQuery() throws IOException, ParseException { ... }
  5. public ListOptionQuery(DataQL dataQL) throws IOException, ParseException { ... }
  6. public ListOptionQuery(Finder finder, Map<String, VarSupplier> shareVarMap) throws IOException, ParseException { ... }
  7. // 方法
  8. public QueryResult execute(CustomizeScope customizeScope) throws InstructRuntimeException { ... }
  9. public ListOptionQuery clone() { ... }
  10. }

详细配置查看:Maven 配置页面