可用版本: Dev (3.21) | 最新 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

使用 Ant 运行代码生成器

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

使用 Ant 运行生成

使用 ant 的 <java/> 任务运行代码生成时,您可能需要设置 fork="true"

<!-- Run the code generation task -->
<target name="generate-test-classes">
  <java fork="true"
        classname="org.jooq.codegen.GenerationTool">
    <arg value="/path/to/configuration.xml"/>
    <classpath>
      <pathelement location="/path/to/jooq-3.20.5.jar"/>
      <pathelement location="/path/to/jooq-meta-3.20.5.jar"/>
      <pathelement location="/path/to/jooq-codegen-3.20.5.jar"/>
      <!-- Add JDBC drivers and other required artifacts -->
    </classpath>
  </java>
</target>

使用 Ant Maven 插件

有时,ant 可以用来解决 Maven 构建的限制(误解?)。就像上面的独立 ant 用法示例一样,jOOQ 代码生成器可以从 maven-antrun-plugin 调用

<!-- Run the code generation task -->
<plugin>
  <artifactId>maven-antrun-plugin</artifactId>
  <version>1.8</version>
  <executions>
    <execution>
      <phase>generate-sources</phase>
      <goals>
        <goal>run</goal>
      </goals>
    </execution>
  </executions>

  <configuration>
    <tasks>
      <java fork="true"
            classname="org.jooq.codegen.GenerationTool"
            classpathref="maven.compile.classpath">
          <arg value="/path/to/configuration.xml"/>
      </java>
    </tasks>
  </configuration>

  <dependencies>
    <dependency>
      <!-- JDBC driver -->
    </dependency>
    <dependency>
                  <!-- Use org.jooq                for the Open Source Edition
                           org.jooq.pro            for commercial editions with Java 21 support,
                           org.jooq.pro-java-17    for commercial editions with Java 17 support,
                           org.jooq.pro-java-11    for commercial editions with Java 11 support,
                           org.jooq.pro-java-8     for commercial editions with Java 8 support,
                           org.jooq.trial          for the free trial edition with Java 21 support,
                           org.jooq.trial-java-17  for the free trial edition with Java 17 support,
                           org.jooq.trial-java-11  for the free trial edition with Java 11 support,
                           org.jooq.trial-java-8   for the free trial edition with Java 8 support
      
                   Note: Only the Open Source Edition is hosted on Maven Central.
                         Install the others locally using the provided scripts, or access them from here: https://repo.jooq.org
                         See the JDK version support matrix here: https://jooq.org.cn/download/support-matrix-jdk -->

      <groupId>org.jooq</groupId>
      <artifactId>jooq-codegen</artifactId>
      <version>3.20.5</version>
    </dependency>
    <!-- Add JDBC drivers and other required artifacts -->
  </dependencies>
</plugin>

反馈

您对此页面有任何反馈吗? 我们很乐意听取您的意见!

The jOOQ Logo