用于JOOQ检查器的Gradle annotationProcessor

问题描述 投票:2回答:1

Gradle是否具有与为JOOQ类型检查器注释处理器(https://www.jooq.org/doc/latest/manual/tools/checker-framework/)描述的Maven配置等效的内容? Maven版本是:

<dependency>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-checker</artifactId>
  <version>3.10.5</version>
</dependency>

<plugin>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.3</version>
  <configuration>
    <source>1.8</source>
    <target>1.8</target>
    <fork>true</fork>
    <annotationProcessors>
      <annotationProcessor>org.jooq.checker.SQLDialectChecker</annotationProcessor>
    </annotationProcessors>
    <compilerArgs>
      <arg>-Xbootclasspath/p:1.8</arg>
    </compilerArgs>
  </configuration>
</plugin>

但是,虽然我可以将编译依赖项放入Gradle中,但我不确定将annotationProcessor位放在何处。任何帮助将不胜感激!

java sql gradle jooq java-annotations
1个回答
3
投票

Gradle支持注释处理器,因为Gradle 3.4通过为处理器添加配置(例如名为“apt”)并设置annotationProcessorPath。有关详细信息,请参阅CompileOptions#setAnnotationProcessorPath()

例:

configurations {
    apt
}

dependencies {
    apt 'org.jooq: jooq-checker:3.10.5'
}

tasks.withType(JavaCompile) {
    options.annotationProcessorPath = configurations.apt
    options.compilerArgs << "-processor" << "org.jooq.checker.SQLDialectChecker"
}

从Gradle 4.6开始,使用预定义的annotationProcessorconfiguration甚至可以更简单:

dependencies {
    annotationProcessor 'org.jooq: jooq-checker:3.10.5'
}
compileJava.options.compilerArgs << "-processor" << "org.jooq.checker.SQLDialectChecker"

另请查看Gradle 4.6-rc.2 release notes了解详情。当然,总有潜力可以改进:Make annotation processors a first-class citizen

当然,Gradle还有一些jOOQ插件可供您查看:https://plugins.gradle.org/search?term=jooq

© www.soinside.com 2019 - 2024. All rights reserved.