How to configure pom.xml for generate jooq classes into two different packages?

Viewed 111

My project consists of two packages, each of which uses the same database schema. In the future, both packages will become independent microservices.

Question: how to configure code generation in pom.xml so that folders with jooq classes are created in two different packages (myProject/packageTwo/ Dao and myProject/packageOne/Dao).

For example, this decision results in jooq classes being created only in the second folder.

<plugin>
 <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>
  <version>3.15.3</version>
…
   <target>
        <packageName>myProject/packageOne/Dao</packageName>
        <directory>target/generated-sources/jooq</directory>
  </target>
  <target>
        <packageName> myProject/packageTwo/Dao</packageName>
        <directory>target/generated-sources/jooq</directory>
  </target>
1 Answers

This is more of a Maven question than a jOOQ one: You should configure two separate executions in order to have two separate target configurations:

<plugin>
  <groupId>org.jooq</groupId>
  <artifactId>jooq-codegen-maven</artifactId>

  <!-- shared configuration, can also be moved to pluginManagement -->
  <configuration>...</configuration>

  <executions>
    <execution>
      <id>exec-1</id>
      <phase>...</phase>
      <goals><goal>generate</goal></goals>
      <configuration>
        <generator>
          <target>...</target>
        </generator>
      </configuration>
    </execution>

    <execution>
      <id>exec-2</id>
      <phase>...</phase>
      <goals><goal>generate</goal></goals>
      <configuration>
        <generator>
          <target>...</target>
        </generator>
      </configuration>
    </execution>
  </executions>
</plugin>
Related