Dave
Dave

Reputation: 19180

What version of Java works with the Liquibase Maven plugin?

Is there a version of the Liquibase Maven plugin that works with Java 9? I have the below Maven compiler plugin set up :-

<build>
  <plugins>
    <plugin>
      <groupId>org.apache.maven.plugins</groupId>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.1</version>
      <configuration>
        <source>1.9</source>
        <target>1.9</target>
        <compilerArgument>-proc:none</compilerArgument>
        <fork>true</fork>
        <executable>${javac_path}</executable>
       </configuration>
       <executions>
         <execution>
           <id>default-testCompile</id>
           <phase>test-compile</phase>
           <goals>
             <goal>testCompile</goal>
           </goals>
         </execution>
       </executions>
    </plugin>
  </plugins>
</build>

and have this Maven liquibase plugin

<!-- Run the liquibase scripts -->
<plugin>
  <groupId>org.liquibase</groupId>
  <artifactId>liquibase-maven-plugin</artifactId>
  <version>${version.liquibase}</version>
  <dependencies>
    <dependency>
      <groupId>mysql</groupId>
      <artifactId>mysql-connector-java</artifactId>
      <version>${version.mysql}</version>
    </dependency>
  </dependencies>
  <executions>
    <execution>
      <id>build-test-database</id>
      <phase>process-test-classes</phase>
      <configuration>
        <driver>com.mysql.jdbc.Driver</driver>
        <url>${test.mysql.dataSource.url}</url>
        <username>${test.mysql.db.user}</username>
        <password>${test.mysql.db.password}</password>
        <changeLogFile>${project.build.directory}/db.changelog-master.xml</changeLogFile>
        <promptOnNonLocalDatabase>false</promptOnNonLocalDatabase>
        <skip>${skipLiquibaseRun}</skip>
        <clearCheckSums>true</clearCheckSums>
      </configuration>
      <goals>
        <goal>update</goal>
      </goals>
    </execution>
  </executions>
</plugin>

but running the plugin dies with the error

[INFO] --- liquibase-maven-plugin:3.3.0:update (build-local-database) @ database ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 3 source files to /home/jboss/.jenkins/workspace/springboard/session/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: /home/jboss/.jenkins/workspace/springboard/database/src/main/resources/liquibase.properties
[INFO] ------------------------------------------------------------------------
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] Source option 1.5 is no longer supported. Use 1.6 or later.
[ERROR] Target option 1.5 is no longer supported. Use 1.6 or later.

This doesn't happen when I change my compiler version to "1.8".

Upvotes: 2

Views: 2258

Answers (2)

Naman
Naman

Reputation: 31938

Try changing your maven-compiler-plugin configuration to

<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version> <!-- JDK9 compatible version-->
<configuration>
    <source>9</source> <!--not 1.9-->
    <target>9</target>
    <compilerArgument>-proc:none</compilerArgument>
    <fork>true</fork>
    <executable>${javac_path}</executable>
</configuration>

The reason being the Java version being parsed is not 1.9 but 9 since the JDK9 release.

Upvotes: 2

Sai Hegde
Sai Hegde

Reputation: 623

Based of this issue - https://github.com/liquibase/liquibase/pull/710 I think your best bet at this time would be to clone the liquibase git repo, build it locally and use >= 3.6.0-SNAPSHOT for liquibase.

Note: 3.6.0-SNAPSHOT is the version that the master is on at the time of this answer :)

Upvotes: 2

Related Questions