matejs
matejs

Reputation: 3536

How to configure jooq-codegen-maven, so i can run only manually and not on each compile

Currently my jooq-codegen-maven plugin runs on every compile, slowing down build. I only want to run it manually, after i change DB schema. How can i change plugin configuration to achieve this?

      <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>

Upvotes: 3

Views: 4158

Answers (2)

Lukas Eder
Lukas Eder

Reputation: 220877

You can use profiles:

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

And then:

mvn generate-sources -P generate-jooq-code

Upvotes: 3

Simon Martinelli
Simon Martinelli

Reputation: 36133

Simply remove the execution:

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

Because this configuration runs the jooq codegen plugin in the generate-sources phase of Maven.

Upvotes: 5

Related Questions