Debugging "Incorrect configuration of jOOQ code generation tool" - maven

I am trying to follow along with the jOOQ tutorial. I am at Step 3 (code generation) but want to do the code generation step using Maven.
Here is the contents of my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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>net.hiew</groupId>
<artifactId>jooq-tutorial</artifactId>
<version>1.0-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.11.2</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-meta</artifactId>
<version>3.11.2</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen</artifactId>
<version>3.11.2</version>
</dependency>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>1.1.7</version>
</dependency>
</dependencies>
<build>
<plugins>
<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
Note: Only the Open Source Edition is hosted on Maven Central.
Import the others manually from your distribution -->
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.11.2</version>
<executions>
<execution>
<id>jooq-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- Configure the database connection here -->
<jdbc>
<driver>org.mariadb.jdbc.Driver</driver>
<url>jdbc:mariadb://localhost:3306/library</url>
<user>root</user>
<password>mysql</password>
</jdbc>
<generator>
<!-- The default code generator. You can override this one, to generate your own code style.
Supported generators:
- org.jooq.codegen.JavaGenerator
- org.jooq.codegen.ScalaGenerator
Defaults to org.jooq.codegen.JavaGenerator -->
<name>org.jooq.codegen.JavaGenerator</name>
<database>
<!-- The database type. The format here is:
org.util.[database].[database]Database -->
<name>org.jooq.meta.mariadb.MariaDBDatabase</name>
<!-- The database schema (or in the absence of schema support, in your RDBMS this
can be the owner, user, database name) to be generated -->
<inputSchema>library</inputSchema>
<!-- All elements that are generated from your schema
(A Java regular expression. Use the pipe to separate several expressions)
Watch out for case-sensitivity. Depending on your database, this might be important! -->
<includes>.*</includes>
<!-- All elements that are excluded from your schema
(A Java regular expression. Use the pipe to separate several expressions).
Excludes match before includes, i.e. excludes have a higher priority -->
<excludes></excludes>
</database>
<target>
<!-- The destination package of your generated classes (within the destination directory) -->
<packageName>net.hiew.jooqtutorial.generated</packageName>
<!-- The destination directory of your generated classes. Using Maven directory layout here -->
<directory>/home/james/src/local/jooqtutorial/src/main/java/</directory>
</target>
</generator>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
My project directory:
The error I get when running mvn -e jooq-codegen:generate:
[INFO] --- jooq-codegen-maven:3.11.2:generate (default-cli) # jooq-tutorial ---
[ERROR] Incorrect configuration of jOOQ code generation tool
[ERROR]
The jOOQ-codegen-maven module's generator configuration is not set up correctly.
This can have a variety of reasons, among which:
- Your pom.xml's <configuration> contains invalid XML according to jooq-codegen-3.11.0.xsd
- There is a version or artifact mismatch between your pom.xml and your commandline
The error message is not that helpful, so I am not sure of the best way to debug the problem further. The pom.xml validates and the database exists and is accessible as described in the <configuration> element.

The configuration tag has to be directly under the plugin tag, not inside execution:
<plugin>
...
<executions>
...
</executions>
<configuration>
...
</configuration>
...
</plugin>
Full plugin tag:
<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 Note: Only the Open Source Edition is hosted on Maven Central. Import the others manually from your distribution -->
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.11.2</version>
<executions>
<execution>
<id>jooq-codegen</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.mariadb.jdbc</groupId>
<artifactId>mariadb-java-client</artifactId>
<version>${mariadb.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- Configure the database connection here -->
<jdbc>
<driver>org.mariadb.jdbc.Driver</driver>
<url>jdbc:mariadb://localhost:3306/library</url>
<user>root</user>
<password>mysql</password>
</jdbc>
<generator>
<!-- The default code generator. You can override this one, to generate your own code style. Supported generators: - org.jooq.codegen.JavaGenerator - org.jooq.codegen.ScalaGenerator Defaults to org.jooq.codegen.JavaGenerator -->
<name>org.jooq.codegen.JavaGenerator</name>
<database>
<!-- The database type. The format here is: org.util.[database].[database]Database -->
<name>org.jooq.meta.mariadb.MariaDBDatabase</name>
<!-- The database schema (or in the absence of schema support, in your RDBMS this can be the owner, user, database name) to be generated -->
<inputSchema>library</inputSchema>
<!-- All elements that are generated from your schema (A Java regular expression. Use the pipe to separate several expressions) Watch out for case-sensitivity. Depending on your database, this might be important! -->
<includes>.*</includes>
<!-- All elements that are excluded from your schema (A Java regular expression. Use the pipe to separate several expressions). Excludes match before includes, i.e. excludes have a higher priority -->
<excludes>
</excludes>
</database>
<target>
<!-- The destination package of your generated classes (within the destination directory) -->
<packageName>net.hiew.jooqtutorial.generated</packageName>
<!-- The destination directory of your generated classes. Using Maven directory layout here -->
<directory>/home/james/src/local/jooqtutorial/src/main/java/</directory>
</target>
</generator>
</configuration>
</plugin>
Note tha you may need to specify your mariadb version in the dependency, I added the defalut variable name.

Alternatively to wallek876's answer, you could rename your executionId to default-cli as documented here. So, this should work:
<executions>
<execution>
<id>default-cli</id>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<!-- Configure the database connection here -->
<jdbc>
...
Another option, which I always prefer, is to use profiles:
<profiles>
<profile>
<id>jooq-codegen</id>
<build>
<plugins>
<plugin>
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.11.2</version>
...
And then, run that with
mvn install -P jooq-codegen

Related

java.lang.NoClassDefFoundError: com.trueaccord.scalapb.GeneratedEnum with Gatling Maven Plugin

Using the latest OpenJDK 11.0.7 with the Gatling Maven Plugin is resulting in this compilation crash. I tried deleting the local Maven repository folders for Gatling, scala-lang, and scala-sbt and re-running a clean install. Below I've pasted my pom.xml. Can someone help to resolve this?
java.lang.ClassNotFoundException: com.trueaccord.scalapb.GeneratedEnum
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:766)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1078)
... 31 common frames omitted
Wrapped by: java.lang.NoClassDefFoundError: com.trueaccord.scalapb.GeneratedEnum
at java.base/java.lang.ClassLoader.defineClassImpl(Native Method)
at java.base/java.lang.ClassLoader.defineClassInternal(ClassLoader.java:476)
at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:437)
at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
at java.base/jdk.internal.loader.BuiltinClassLoader.defineClass(BuiltinClassLoader.java:1110)
at java.base/jdk.internal.loader.BuiltinClassLoader.findClassOnClassPathOrNull(BuiltinClassLoader.java:898)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClassOrNull(BuiltinClassLoader.java:806)
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:764)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:1078)
at sbt.internal.inc.FileAnalysisStore$BinaryFileStore.<init>(FileAnalysisStore.scala:50)
at sbt.internal.inc.FileAnalysisStore$.binary(FileAnalysisStore.scala:36)
at io.gatling.compiler.ZincCompiler$.doCompile(ZincCompiler.scala:174)
at io.gatling.compiler.ZincCompiler$.delayedEndpoint$io$gatling$compiler$ZincCompiler$1(ZincCompiler.scala:216)
at io.gatling.compiler.ZincCompiler$delayedInit$body.apply(ZincCompiler.scala:39)
at scala.Function0.apply$mcV$sp(Function0.scala:39)
at scala.Function0.apply$mcV$sp$(Function0.scala:39)
at scala.runtime.AbstractFunction0.apply$mcV$sp(AbstractFunction0.scala:17)
at scala.App.$anonfun$main$1$adapted(App.scala:80)
at scala.App$$Lambda$5/0000000000000000.apply(Unknown Source)
at scala.collection.immutable.List.foreach(List.scala:392)
at scala.App.main(App.scala:80)
at scala.App.main$(App.scala:78)
at io.gatling.compiler.ZincCompiler$.main(ZincCompiler.scala:39)
at io.gatling.compiler.ZincCompiler.main(ZincCompiler.scala)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at io.gatling.mojo.MainWithArgsInFile.runMain(MainWithArgsInFile.java:50)
at io.gatling.mojo.MainWithArgsInFile.main(MainWithArgsInFile.java:33)
My redacted pom.xml:
<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>***</groupId>
<artifactId>****</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<gatling.version>3.3.1</gatling.version>
<gatling-plugin.version>3.0.5</gatling-plugin.version>
<maven-jar-plugin.version>3.2.0</maven-jar-plugin.version>
<!-- <scala-maven-plugin.version>4.3.1</scala-maven-plugin.version> -->
</properties>
<dependencies>
<dependency>
<groupId>io.gatling.highcharts</groupId>
<artifactId>gatling-charts-highcharts</artifactId>
<version>${gatling.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<testSourceDirectory>simulations</testSourceDirectory>
<plugins>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven-jar-plugin.version}</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<executable>bash</executable>
<arguments>
<argument>run.sh</argument>
<argument>${env.NS}</argument> <!-- will be empty if running with services -->
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>io.gatling</groupId>
<artifactId>gatling-maven-plugin</artifactId>
<version>${gatling-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<configuration>
<!-- the name of the single Simulation class to run -->
<simulationClass>${env.SIMULATION}</simulationClass>
<runMultipleSimulations>false</runMultipleSimulations> <!-- if the plugin should run multiple simulations sequentially -->
<includes> <!-- include filters, see dedicated section below -->
<include></include>
</includes>
<excludes> <!-- exclude filters, see dedicated section below -->
<exclude></exclude>
</excludes>
<reportsOnly></reportsOnly> <!-- to only trigger generating HTML reports from the log file contained in folder parameter -->
<runDescription>****</runDescription> <!-- short text that will be displayed in the HTML reports -->
<failOnError>true</failOnError> <!-- report failure in case of assertion failure, typically to fail CI pipeline -->
<continueOnAssertionFailure>false</continueOnAssertionFailure> <!-- keep on executing multiple simulations even if one fails -->
<useOldJenkinsJUnitSupport>true</useOldJenkinsJUnitSupport> <!-- report results to Jenkins JUnit support (workaround until we manage to get Gatling support into Jenkins) -->
<!-- pass extra parameters to the Gatling JVM -->
<jvmArgs>
<jvmArg>-DIAM=${env.IAM}</jvmArg>
<jvmArg>-DStarterkitsDir=${env.STARTERKITS_DIR}</jvmArg>
<jvmArg>-DServicesDir=${env.SERVICES_DIR}</jvmArg>
<jvmArg>-DGROUP=${env.RESOURCE_GROUP}</jvmArg>
<jvmArg>-DGORG=${env.ORG_GUID}</jvmArg>
<jvmArg>-DSPACE=${env.SPACE_GUID}</jvmArg>
<jvmArg>-DURL=${env.URL}</jvmArg>
<jvmArg>-DUsers=${env.USERS}</jvmArg>
<jvmArg>-DDuration=${env.DURATION}</jvmArg>
</jvmArgs>
<overrideJvmArgs>false</overrideJvmArgs> <!-- if above option should override the defaults instead of replacing them -->
<propagateSystemProperties>true</propagateSystemProperties> <!-- if System properties from the maven JVM should be propagated to the Gatling forked one -->
<!-- pass extra parameters to the Compiler JVM -->
<compilerJvmArgs>
</compilerJvmArgs>
<!-- if above option should override the defaults instead of replacing them -->
<overrideCompilerJvmArgs>false</overrideCompilerJvmArgs>
<!-- extra options to be passed to scalac -->
<!-- <extraScalacOptions>
<extraScalacOption></extraScalacOption>
</extraScalacOptions> -->
<disableCompiler>false</disableCompiler> <!-- if compiler should be disabled, typically because another plugin has already compiled sources -->
<simulationsFolder>${project.basedir}/simulations</simulationsFolder> <!-- where the simulations to be compiled are located -->
<resourcesFolder>${project.basedir}</resourcesFolder> <!-- where the test resources are located -->
<resultsFolder>${project.basedir}/target/gatling</resultsFolder> <!-- where the simulation log and the HTML reports will be generated -->
</configuration>
</plugin>
</plugins>
</build>
</project>
There's nothing wrong with gatling-maven-plugin.
As I said in the issue you opened on our bug tracker, you most likely have some corrupted jars in your local maven repository.
Maven sometimes messes up when downloading jars and still installs the corrupted files in the local repository. The ClassLoader can't open the jars (jars are just zip files) and silently ignores them, causing NoClassDefFoundErrors at runtime.
It looks like the gatling-maven-plugin compilation is not working or something else is going on with it. I switched to using scala-maven-plugin and that compiles my simulation classes successfully.
<plugin>
<groupId>net.alchim31.maven</groupId>
<artifactId>scala-maven-plugin</artifactId>
<version>${scala-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>testCompile</goal>
</goals>
<configuration>
<jvmArgs>
<jvmArg>-Xss100M</jvmArg>
</jvmArgs>
<args>
<arg>-target:jvm-1.8</arg>
<arg>-deprecation</arg>
<arg>-feature</arg>
<arg>-unchecked</arg>
<arg>-language:implicitConversions</arg>
<arg>-language:postfixOps</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>

Maven: How to execute a dependency in a forked JVM?

Using maven-exec-plugin and a java goal I execute a jar program that validates some files in my project. When the validation fails, it calls System.exit to return a non zero return code.
The problem is that it executes in the same JVM as Maven, so when it calls exit, the processing stops since it does not fork.
I configured it to execute with maven-exec-plugin and a java goal (like in here ). The execute jar is in my Nexus repository, so I want to download it as a dependency in my pom.xml.
A very nice feature of configuring the maven-exec-plugin dependency is that it downloads the jar and all its dependencies, so it isn't necessary to use maven assembly plugin to include all jars in the executable.
How do I configure my pom.xml to execute a jar dependency and correctly stop when it fails?
I solved my problem. Basically, instead of using the java goal, I must use the exec goal, and run the java executable. The code below sets the classpath and the class with the main method.
This solution using the pom.xml and a Nexus repository has a lot of advantages over just handling a jar file for my users:
No need to install anything in the machine that will run it, be it a developer machine or a continuous integration one.
The validation tool developer can release new versions and it will be automatically updated.
The developer can turn it off with a simple parameter.
Also solves the original problem: the validation tool will execute in a separate process, so the maven process won't abort when it calls System.exit.
Here is a commented pom.xml:
<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>com.company</groupId>
<artifactId>yourId</artifactId>
<version>1.0</version>
<properties>
<!--
Skip the validation executing maven setting the parameter below
mvn integration-test -Dvalidation.skip
-->
<validation.skip>false</validation.skip>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.6.0</version>
<executions>
<execution>
<id>MyValidator</id>
<phase>integration-test</phase> <!-- you can associate to any maven phase -->
<goals>
<goal>exec</goal> <!-- forces execution in another process -->
</goals>
</execution>
</executions>
<configuration>
<executable>java</executable> <!-- java must be in your PATH -->
<includeProjectDependencies>false</includeProjectDependencies>
<includePluginDependencies>false</includePluginDependencies>
<skip>${validation.skip}</skip>
<arguments>
<argument>-classpath</argument>
<classpath/> <!-- will include your class path -->
<mainClass>com.company.yourpackage.AppMain</mainClass> <!-- the class that has your main file -->
<argument>argument.xml</argument> <!-- any argument for your executable -->
</arguments>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<!-- Specify your executable jar here -->
<groupId>com.company.validator</groupId>
<artifactId>validatorId</artifactId>
<version>RELEASE</version> <!-- you can specify a fixed version here -->
<type>jar</type>
</dependency>
</dependencies>
</project>
You can run more than one executable passing its id: mvn exec:exec#MyValidator
I have stumbled upon the same issue - System.exit halts the maven with exec:java.
I have experimented to use the exec:exec goal, and made it work with the following configuration:
(using exec-maven-plugin 3.1.0)
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-observability-docs</id>
<phase>prepare-package</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>java</executable>
<arguments>
<argument>-jar</argument>
<argument>${settings.localRepository}/io/micrometer/micrometer-docs-generator/${micrometer-docs-generator.version}/micrometer-docs-generator-${micrometer-docs-generator.version}.jar</argument>
<argument>${micrometer-docs-generator.inputPath}</argument>
<argument>${micrometer-docs-generator.inclusionPattern}</argument>
<argument>${micrometer-docs-generator.outputPath}</argument>
</arguments>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-docs-generator</artifactId>
<version>${micrometer-docs-generator.version}</version>
<type>jar</type>
</dependency>
</dependencies>
</plugin>

liquibase maven plugin multiple changeLogFile

I'm using liquibase maven plugin to update the database changes via jenkins automated builds.
I have this in my pom.xml
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.2</version>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.5</version>
</dependency>
</dependencies>
<configuration>
<changeLogFile>${basedir}/src/main/resources/schema.sql</changeLogFile>
<changeLogFile>${basedir}/src/main/resources/data.sql</changeLogFile>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://${db.url}</url>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
</plugin>
I need to run schema.sql before data.sql. When I run this locally it works. When I run it via jenkins the schema changeLogFile executes second, so in order to make it work I reversed the commads.
Question: What's the order of execution? Am I doing something wrong?
The official goal documentation specify that only one entry is foreseen:
changeLogFile:
Specifies the change log file to use for Liquibase.
Type: java.lang.String
Required: No
Expression: ${liquibase.changeLogFile}
You can add further entries, but they will be ignored and maven will not complain: it doesn't validate plugin configuration' content, it cannot, because that part is up to the plugin and not known upfront by maven. That is, is generic.
To ensure a deterministic order and have two changeLogFile executed, you should specify several plugin executions as following:
<plugin>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-maven-plugin</artifactId>
<version>3.4.2</version>
<dependencies>
<dependency>
<groupId>org.postgresql</groupId>
<artifactId>postgresql</artifactId>
<version>9.5</version>
</dependency>
</dependencies>
<configuration>
<changeLogFile>${basedir}/src/main/resources/schema.sql</changeLogFile>
<changeLogFile>${basedir}/src/main/resources/data.sql</changeLogFile>
<driver>org.postgresql.Driver</driver>
<url>jdbc:postgresql://${db.url}</url>
<promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
</configuration>
<executions>
<execution>
<id>update-schema</id>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
<configuration>
<changeLogFile>${basedir}/src/main/resources/schema.sql</changeLogFile>
</configuration>
</execution>
<execution>
<id>update-data</id>
<phase>process-resources</phase>
<goals>
<goal>update</goal>
</goals>
<configuration>
<changeLogFile>${basedir}/src/main/resources/data.sql</changeLogFile>
</configuration>
</execution>
</executions>
</plugin>
Note: we are specifying a common configuration for all executions outside of the executions section, then per each execution we are only defining the additional configuration, which is every time the different file.
The deterministic order is guaranteed by Maven: for the same plugin, for the same phase, the order of declaration in the POM will be respected.
However, this executions will be part of your build now as part of the process-resources phase, which is probably not what you want. So in this case, better to move it to a profile as following:
<profiles>
<profile>
<id>liquibase-executions</id>
<build>
<defaultGoal>process-resources</defaultGoal>
<plugins>
<!-- MOVE HERE liquibase plugin configuration and executions -->
</plugins>
</build>
</profile>
</profiles>
And then execute the following (according also to your comment):
mvn -Pliquibase-executions -Ddb.url=IP:PORT/DB -Dliquibase.username=USERNAME

Aggregate findbugs report in Maven 3.0.5

I am using multi-module Maven Project ( more than 10 modules ). I am trying to create a findbugs report of all module in single html page. Is there any way?
For creating individual report for each module, i am using the below
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<!--
Enables analysis which takes more memory but finds more bugs.
If you run out of memory, changes the value of the effort element
to 'Low'.
-->
<effort>Max</effort>
<!-- Build doesn't fail if problems are found -->
<failOnError>false</failOnError>
<!-- Reports all bugs (other values are medium and max) -->
<threshold>Low</threshold>
<!-- Produces XML report -->
<xmlOutput>false</xmlOutput>
<skip>${skipFindbugs}</skip>
<!-- Configures the directory in which the XML report is created -->
<findbugsXmlOutputDirectory>${project.build.directory}/findbugs</findbugsXmlOutputDirectory>
</configuration>
<executions>
<!--
Ensures that FindBugs inspects source code when project is compiled.
-->
<execution>
<phase>compile</phase>
<goals>
<goal>findbugs</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>xml-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<transformationSets>
<transformationSet>
<!-- Configures the source directory of XML files. -->
<dir>${project.build.directory}/findbugs</dir>
<!-- Configures the directory in which the FindBugs report is written.-->
<outputDir>${project.build.directory}/findbugs</outputDir>
<!-- Selects the used stylesheet. -->
<!-- <stylesheet>fancy-hist.xsl</stylesheet> -->
<stylesheet>${project.parent.basedir}/default.xsl</stylesheet>
<!--<stylesheet>plain.xsl</stylesheet>-->
<!--<stylesheet>fancy.xsl</stylesheet>-->
<!--<stylesheet>summary.xsl</stylesheet>-->
<fileMappers>
<!-- Configures the file extension of the output files. -->
<fileMapper implementation="org.codehaus.plexus.components.io.filemappers.FileExtensionMapper">
<targetExtension>.html</targetExtension>
</fileMapper>
</fileMappers>
</transformationSet>
</transformationSets>
</configuration>
<executions>
<!-- Ensures that the XSLT transformation is run when the project is compiled. -->
<execution>
<phase>compile</phase>
<goals>
<goal>transform</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>findbugs</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
</plugin>
According to official documentation of the plugin (question n. 1), it is not possible.
However, here is the approach I used to achieve it:
Add an additional module to your existing multimodule project. This additional module will only be used for reporting
Configure the Buildhelper Maven Plugin to dynamically add the source code of the other modules to the reporting module. Note: you can do the same for resources, if required.
Configure the Findbugs plugin only on the reporting module
Add the other modules as dependencies of the reporting module, in order to have the Maven reactor build to build it only at the end.
If required: you don't want the reporting module to be part of your default build, create a profile in the aggregator/parent module which redefines the modules element and add the reporting module to it. As such, only when the profile will be activated (i.e. via command line, on demand) the reporting module will be added and the aggregated report will be created.
As an example, in the aggregator/parent module you can define as following:
<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>com.sample</groupId>
<artifactId>findbugs-parent</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<modules>
<module>findbugs-module1</module>
<module>findbugs-module2</module>
</modules>
<profiles>
<profile>
<id>findbugs-reporting</id>
<modules>
<module>findbugs-module1</module>
<module>findbugs-module2</module>
<module>findbugs-reporting</module>
</modules>
</profile>
</profiles>
</project>
Note: the findbugs-reporting module is only added in the findbugs-reporting profile. By default, the build will ignore it.
In the findbugs-reporting module, configure the POM using the configuration you posted (findbugs and XML maven plugin) and also add as following:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>..\findbugs-module1\src\main\java</source>
<source>..\findbugs-module2\src\main\java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
Note the added sources from other modules (change it according to your project).
Furthermore, we also need to add dependencies to the reporting module. It has to depend on other modules in order to be built at the end (and as such make sure to take the latest changes/sources from other modules). As an example:
<dependencies>
<dependency>
<groupId>com.sample</groupId>
<artifactId>findbugs-module1</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.sample</groupId>
<artifactId>findbugs-module2</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Finally, you can invoke the reporting build as following from the aggregator/parent dir:
mvn clean install -Pfindbugs-reporting
As such, you will build the whole project and additionally activate the reporting module, which will dynamically include sources from other modules (as configured) and generate an aggregated report.
Depending on your needs, you can avoid the profile step (if you want it as part of your default build) or activate the profile by default (so that you can skip the reporting build deactivate it via -P!findbugs-reporting) or use the skipFindbugs property you already configured (and without the profile, in such a case).

Using embedded database with Flyway and jOOQ in Maven for continuous integration

So I'm really trying to do things 'right' with SQL that will break at compile time using flyway and jOOQ. To do this I need a database solution that can work on the continuous integration server with no access to any server-based database. Ultimately, I want to deploy this to Amazon so I need a solution that is mostly compatible with postgreSQL. HSQLDB's file protocol seems to fit that bill.
<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">
<properties>
<schema></schema>
<db.groupId>org.hsqldb</db.groupId>
<db.artifactId>hsqldb</db.artifactId>
<db.version>2.3.2</db.version>
<flyway.url>jdbc:hsqldb:file:myDB/db</flyway.url>
<flyway.driver>org.hsqldb.jdbcDriver</flyway.driver>
<jooq.generator.database.name>org.jooq.util.hsqldb.HSQLDBDatabase</jooq.generator.database.name>
<flyway.user></flyway.user>
<flyway.password></flyway.password>
</properties>
<dependencies>
<dependency>
<groupId>${db.groupId}</groupId>
<artifactId>${db.artifactId}</artifactId>
<version>${db.version}</version>
</dependency>
<dependency>
<groupId>org.jooq</groupId>
<artifactId>jooq</artifactId>
<version>3.4.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.flywaydb</groupId>
<artifactId>flyway-maven-plugin</artifactId>
<version>3.1</version>
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>migrate</goal>
</goals>
</execution>
</executions>
<configuration>
<locations>
<location>filesystem:src/main/resources/db/migration</location>
</locations>
</configuration>
</plugin>
<plugin>
<!-- Specify the maven code generator plugin -->
<groupId>org.jooq</groupId>
<artifactId>jooq-codegen-maven</artifactId>
<version>3.4.2</version>
<!-- The plugin should hook into the generate goal -->
<executions>
<execution>
<phase>generate-sources</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<!-- Work around Maven's classloader -->
<dependencies>
<dependency>
<groupId>${db.groupId}</groupId>
<artifactId>${db.artifactId}</artifactId>
<version>${db.version}</version>
</dependency>
</dependencies>
<configuration>
<!-- JDBC connection parameters -->
<jdbc>
<driver>${flyway.driver}</driver>
<url>${flyway.url}</url>
<user>${flyway.user}</user>
<password>${flyway.password}</password>
</jdbc>
<!-- Generator parameters -->
<generator>
<name>org.jooq.util.DefaultGenerator</name>
<database>
<name>${jooq.generator.database.name}</name>
<includes>.*</includes>
<excludes></excludes>
<inputSchema>${schema}</inputSchema>
</database>
<target>
<packageName>package.goes.here</packageName>
<directory>target/generated-sources/jooq</directory>
</target>
</generator>
</configuration>
</plugin>
</plugins>
</build>
The problem is that Flyway can create the database fine, but when it becomes jOOQ's turn to use the database to generate code, it fails with:
Caused by: org.hsqldb.HsqlException: Database lock acquisition failure: lockFile: org.hsqldb.persist.LockFile#1096ec89[file =...db/db.lck, exists=true, locked=false, valid=false, ] method: checkHeartbeat read: 2015-02-09 03:56:15 heartbeat - read: -863 ms.
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.error.Error.error(Unknown Source)
at org.hsqldb.persist.LockFile.newLockFileLock(Unknown Source)
at org.hsqldb.persist.Logger.acquireLock(Unknown Source)
at org.hsqldb.persist.Logger.open(Unknown Source)
at org.hsqldb.Database.reopen(Unknown Source)
at org.hsqldb.Database.open(Unknown Source)
at org.hsqldb.DatabaseManager.getDatabase(Unknown Source)
at org.hsqldb.DatabaseManager.newSession(Unknown Source)
The core of problem is that Maven's plugins do not share the same classloader as the rest of the POM, and you must specify the JDBC driver dependency a second time. Thus I get a new instance of the driver and it conflicts with the already open driver Flyway has open, instead of using the same one.
So a solution may exist along a number of different paths:
Flyway could close the database properly. Apparently Flyway has a workaround in its plugin to read the project's classpath.
jOOQ could be configured somehow to read the project's classpath.
There might be another database that would work better.
Yours!
Thanks Thilo for the direction. Replacing the Flyway plugin with exec works, but I had to create a simpler command line client to make it work.

Resources