1

目前我的 jooq-codegen-maven 插件在每次编译时都会运行,从而减慢了构建速度。在我更改数据库架构后,我只想手动运行它。如何更改插件配置以实现此目的?

      <plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <version>${jooq.version}</version>

            <executions>
                <execution>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>generate</goal>
                    </goals>
                </execution>
            </executions>

            <configuration>
                <jdbc>
                    <url>${jooq.db.url}</url>
                    <user>${jooq.db.username}</user>
                    <password>${jooq.db.username}</password>
                </jdbc>
                <generator>
                    <database>
                        <includes>.*</includes>
                        <inputSchema>${jooq.db.schema}</inputSchema>
                    </database>
                    <target>
                        <packageName>my.package.name.generated.jooq</packageName>
                        <directory>${project.build.directory}/generated-sources/jooq</directory>
                    </target>
                </generator>
            </configuration>
        </plugin>
4

2 回答 2

2

只需删除执行:

<executions>
    <execution>
       <phase>generate-sources</phase>
       <goals>
          <goal>generate</goal>
       </goals>
    </execution>
 </executions>

因为这个配置在 Maven 的 generate-sources 阶段运行了 jooq codegen 插件。

于 2020-05-23T08:56:52.470 回答
2

您可以使用配置文件:

<profiles>
  <profile>
    <id>generate-jooq-code</id>
    <plugins>
      <plugin>
        <groupId>org.jooq</groupId>
        <artifactId>jooq-codegen-maven</artifactId>
        ...
      </plugin>
    </plugins>
  </profile>
</profiles>

接着:

mvn generate-sources -P generate-jooq-code
于 2020-05-25T07:07:34.960 回答