1

I am new to JOOQ and Maven. I want to generate Pojo by giving schema, as per JOOQ's documentation says. I tried with commandline way, and it was working perfectly. I added same configuration in Eclipse java project. Below is my pom.mxl

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>PojoGenerator</groupId>
    <artifactId>PojoGenerator</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>rutherford.pojo</name>
    <build>
        <sourceDirectory>src</sourceDirectory>
        <pluginManagement>

            <plugins>
                <plugin>
                    <!-- <artifactId>maven-compiler-plugin</artifactId>
                    <version>3.5.1</version>
                    <configuration>
                        <source>1.8</source>
                        <target>1.8</target>
                    </configuration>
                </plugin>

                <plugin> -->

                    <!-- Specify the maven code generator plugin -->
                    <!-- Use org.jooq for the Open Source edition org.jooq.pro for commercial 
                        editions, org.jooq.pro-java-6 for commercial editions with Java 6 support, 
                        org.jooq.trial for the free trial edition -->
                    <groupId>org.jooq</groupId>
                    <artifactId>jooq-codegen-maven</artifactId>
                    <version>3.8.4</version>

                    <!-- The plugin should hook into the generate goal -->
                    <executions>
                        <execution>
                            <goals>
                                <goal>generate</goal>
                            </goals>
                        </execution>
                    </executions>

                    <!-- Manage the plugin's dependency. In this example, we'll use a PostgreSQL 
                        database -->
                    <dependencies>
                        <dependency>
                            <groupId>org.postgresql</groupId>
                            <artifactId>postgresql</artifactId>
                            <version>9.4-1201-jdbc41</version>
                        </dependency>
                    </dependencies>

                    <!-- Specify the plugin configuration. The configuration format is the 
                        same as for the standalone code generator -->
                    <configuration>

                        <!-- JDBC connection parameters -->
                        <jdbc>
                            <driver>org.postgresql.Driver</driver>
                            <url>jdbc:postgresql://localhost:5432/test</url>
                            <user>postgres</user>
                            <password>test</password>
                        </jdbc>

                        <!-- Generator parameters -->
                        <generator>
                            <database>
                                <name>org.jooq.util.postgres.PostgresDatabase</name>
                                <includes>.*</includes>
                                <excludes></excludes>
                                <inputSchema>public</inputSchema>
                            </database>
                            <target>
                                <packageName>com.generated.pojo</packageName>
                                <directory>${project.build.directory}/src</directory>

                            </target>
                        </generator>
                    </configuration>
                </plugin>
            </plugins>
        </pluginManagement>
    </build>

</project>

I tried generate resources. It says BUILD SUCCESS, but I can't see my generated Pojos anywhere. Please let me know what am I missing.

kunal dexit
  • 97
  • 2
  • 9
  • Is there any reason why you put the jOOQ code generator plugin inside of ``, rather than directly into ``? – Lukas Eder Aug 01 '16 at 06:51
  • If I remove this tag, I get this error `Plugin execution not covered by lifecycle configuration: org.jooq:jooq-codegen-maven:3.8.4:generate (execution: default, phase: generate-sources)` – kunal dexit Aug 01 '16 at 16:55
  • Aha, I see. There's this well known Eclipse m2e bug, and [people suggest introducing the `` tag to "fix" it.](http://stackoverflow.com/q/6352208/521799), but this changes the semantics of your Maven build. – Lukas Eder Aug 01 '16 at 18:14

1 Answers1

1

You still need to add the plugin to your build, as <pluginManagement> only helps you declare common configurations for reuse.

<build>
    <pluginManagement>...</pluginManagement>
    <plugins>
        <plugin>
            <groupId>org.jooq</groupId>
            <artifactId>jooq-codegen-maven</artifactId>
            <execution>...</execution>
        </plugin>
    </plugins>
</build>

See also this question here: Maven: What is pluginManagement?

In this case, it's probably simpler to just ignore this well-known issue in Eclipse and avoid the <pluginManagement> element.

Community
  • 1
  • 1
Lukas Eder
  • 211,314
  • 129
  • 689
  • 1,509