Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature - Bump liquibase to 4.18 #3847

Draft
wants to merge 2 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import liquibase.database.DatabaseFactory;
import liquibase.database.jvm.JdbcConnection;
import liquibase.exception.LiquibaseException;
import liquibase.resource.FileSystemResourceAccessor;
import liquibase.resource.DirectoryResourceAccessor;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.SystemUtils;
Expand All @@ -33,6 +33,7 @@
import org.slf4j.LoggerFactory;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
Expand Down Expand Up @@ -72,8 +73,8 @@ public class KapuaLiquibaseClient {
* Constructor.
*
* @param jdbcUrl The JDBC connection string.
* @param username The username to connect to to the database.
* @param password The password to connect to to the database.
* @param username The username to connect to the database.
* @param password The password to connect to the database.
* @since 1.0.0
*/
public KapuaLiquibaseClient(String jdbcUrl, String username, String password) {
Expand All @@ -84,8 +85,8 @@ public KapuaLiquibaseClient(String jdbcUrl, String username, String password) {
* Constructor.
*
* @param jdbcUrl The JDBC connection string.
* @param username The username to connect to to the database.
* @param password The password to connect to to the database.
* @param username The username to connect to the database.
* @param password The password to connect to the database.
* @param schema The {@link java.util.Optional} schema name.
* @since 1.0.0
* @deprecated Since 1.2.0. Removed usage of {@link Optional} as parameter.
Expand All @@ -99,8 +100,8 @@ public KapuaLiquibaseClient(String jdbcUrl, String username, String password, Op
* Constructor.
*
* @param jdbcUrl The JDBC connection string.
* @param username The username to connect to to the database.
* @param password The password to connect to to the database.
* @param username The username to connect to the database.
* @param password The password to connect to the database.
* @param schema The schema name.
* @since 1.2.0
*/
Expand Down Expand Up @@ -172,9 +173,9 @@ public void forceReleaseChangelogLock() {
LOG.info("Trying to release changelog lock...");
try (Connection connection = DriverManager.getConnection(jdbcUrl, username, password)) {
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(connection));
Liquibase liquibase = new Liquibase((String) null, new FileSystemResourceAccessor(), database);
Liquibase liquibase = new Liquibase((String) null, new DirectoryResourceAccessor(new File("/")), database);
liquibase.forceReleaseLocks();
} catch (LiquibaseException | SQLException e) {
} catch (LiquibaseException | SQLException | FileNotFoundException e) {
LOG.error("Running release changelog lock... ERROR! Error: {}", e.getMessage(), e);
throw new RuntimeException(e); // TODO: throw an appropriate exception!
}
Expand Down Expand Up @@ -210,7 +211,7 @@ protected static synchronized File loadChangelogs() throws IOException {
return changelogTempDirectory;
}

protected static void executeMasters(Connection connection, String schema, File changelogDir, List<String> contexts) throws LiquibaseException {
protected static void executeMasters(Connection connection, String schema, File changelogDir, List<String> contexts) throws LiquibaseException, FileNotFoundException {
// Find and execute all master scripts
LOG.info("Executing pre master files...");
executeMasters(connection, schema, changelogDir, "-master.pre.xml", contexts);
Expand All @@ -225,7 +226,7 @@ protected static void executeMasters(Connection connection, String schema, File
LOG.info("Executing post master files... DONE!");
}

protected static void executeMasters(Connection connection, String schema, File changelogTempDirectory, String preMaster, List<String> contexts) throws LiquibaseException {
protected static void executeMasters(Connection connection, String schema, File changelogTempDirectory, String preMaster, List<String> contexts) throws LiquibaseException, FileNotFoundException {
List<File> masterChangelogs = Arrays.asList(changelogTempDirectory.listFiles((dir, name) -> name.endsWith(preMaster)));

LOG.info("\tMaster Liquibase files found: {}", masterChangelogs.size());
Expand All @@ -240,7 +241,7 @@ protected static void executeMasters(Connection connection, String schema, File
if (!Strings.isNullOrEmpty(schema)) {
database.setDefaultSchemaName(schema);
}
Liquibase liquibase = new Liquibase(masterChangelog.getAbsolutePath(), new FileSystemResourceAccessor(), database);
Liquibase liquibase = new Liquibase(masterChangelog.getAbsolutePath(), new DirectoryResourceAccessor(new File("/")), database);
liquibase.update(ctx);

LOG.debug("\t\tExecuting liquibase script: {}... DONE!", masterChangelog.getAbsolutePath());
Expand Down
9 changes: 4 additions & 5 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<jolokia-jvm.version>1.3.4</jolokia-jvm.version>
<jose4j.version>0.7.10</jose4j.version>
<junit.version>4.13.2</junit.version>
<liquibase.version>3.6.3</liquibase.version>
<liquibase.version>4.18.0</liquibase.version>
<log4j-api.version>2.17.1</log4j-api.version>
<log4j2-mock.version>0.0.2</log4j2-mock.version>
<logback.version>1.2.11</logback.version> <!-- Logback 1.3.x requires slf4j 2.x. Logback 1.4.x requires Java 11. See https://logback.qos.ch/dependencies.html-->
Expand Down Expand Up @@ -1713,10 +1713,10 @@
<artifactId>liquibase-core</artifactId>
<version>${liquibase.version}</version>
<exclusions>
<!-- This is not required. The implementation of SLF4J will be by the application assembly-->
<!-- Already in dependencies-->
<exclusion>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down Expand Up @@ -2229,7 +2229,6 @@
<artifactId>log4j-over-slf4j</artifactId>
<version>${slf4j.version}</version>
</dependency>

<!-- -->
<!-- Jetty-->
<dependency>
Expand Down