Skip to content

Commit

Permalink
Update to Liquibase 4.8.0 (keycloak#10839)
Browse files Browse the repository at this point in the history
Closes keycloak#10678

Co-authored-by: Stefan Guilhen <sguilhen@redhat.com>
Co-authored-by: Martin Kanis <mkanis@redhat.com>

Co-authored-by: Bruno Oliveira da Silva <bruno@abstractj.com>
Co-authored-by: Stefan Guilhen <sguilhen@redhat.com>
Co-authored-by: Martin Kanis <mkanis@redhat.com>
  • Loading branch information
4 people committed Mar 21, 2022
1 parent d19a830 commit ae92e6e
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.6.2</version>
<version>4.8.0</version>
<licenses>
<license>
<name>Apache Software License 2.0</name>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.6.2/LICENSE.txt</url>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.8.0/LICENSE.txt</url>
</license>
</licenses>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.6.2.redhat-00001</version>
<version>4.8.0.redhat-00001</version>
<licenses>
<license>
<name>Apache Software License 2.0</name>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.6.2/LICENSE.txt</url>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.8.0/LICENSE.txt</url>
</license>
</licenses>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>3.6.2</version>
<version>4.8.0</version>
<licenses>
<license>
<name>Apache Software License 2.0</name>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.6.2/LICENSE.txt</url>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.8.0/LICENSE.txt</url>
</license>
</licenses>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,11 @@
<dependency>
<groupId>org.liquibase</groupId>
<artifactId>liquibase-core</artifactId>
<version>4.6.2.redhat-00001</version>
<version>4.8.0.redhat-00001</version>
<licenses>
<license>
<name>Apache Software License 2.0</name>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.6.2/LICENSE.txt</url>
<url>https://raw.githubusercontent.com/liquibase/liquibase/v4.8.0/LICENSE.txt</url>
</license>
</licenses>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import liquibase.exception.LiquibaseException;
import liquibase.resource.ClassLoaderResourceAccessor;
import liquibase.resource.ResourceAccessor;
import liquibase.ui.LoggerUIService;
import org.jboss.logging.Logger;
import org.keycloak.Config;
import org.keycloak.connections.jpa.updater.liquibase.LiquibaseJpaUpdaterProvider;
Expand Down Expand Up @@ -81,6 +82,7 @@ protected void baseLiquibaseInitialization() {
final Map<String, Object> scopeValues = new HashMap<>();
scopeValues.put(Scope.Attr.resourceAccessor.name(), new ClassLoaderResourceAccessor(this.getClass().getClassLoader()));
scopeValues.put(Scope.Attr.classLoader.name(), this.getClass().getClassLoader());
scopeValues.put(Scope.Attr.ui.name(), new LoggerUIService());
try {
Scope.enter(scopeValues);
} catch (Exception e) {
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
<freemarker.version>2.3.31</freemarker.version>

<jetty9.version>${jetty92.version}</jetty9.version>
<liquibase.version>4.6.2</liquibase.version>
<liquibase.version>4.8.0</liquibase.version>
<osgi.version>4.2.0</osgi.version>
<pax.web.version>7.1.0</pax.web.version>
<servlet.api.30.version>1.0.2.Final</servlet.api.30.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,13 @@

import java.lang.reflect.Method;
import java.sql.Connection;
import java.util.HashMap;
import java.util.Map;

import javax.xml.parsers.SAXParserFactory;

import liquibase.Scope;
import liquibase.ui.LoggerUIService;
import org.jboss.logging.Logger;
import org.keycloak.Config;
import org.keycloak.connections.jpa.updater.liquibase.conn.LiquibaseConnectionProvider;
Expand Down Expand Up @@ -63,6 +67,16 @@ public LiquibaseConnectionProvider create(KeycloakSession session) {
protected void baseLiquibaseInitialization(KeycloakSession session) {
resourceAccessor = new ClassLoaderResourceAccessor(getClass().getClassLoader());

// initialize Liquibase using a custom scope
final Map<String, Object> scopeValues = new HashMap<>();
scopeValues.put(Scope.Attr.ui.name(), new LoggerUIService());
try {
Scope scope = Scope.getCurrentScope();
scope.enter(scopeValues);
} catch (Exception e) {
throw new RuntimeException("Failed to initialize Liquibase: " + e.getMessage(), e);
}

// disables XML validation
for (ChangeLogParser parser : ChangeLogParserFactory.getInstance().getParsers()) {
if (parser instanceof XMLChangeLogSAXParser) {
Expand Down

0 comments on commit ae92e6e

Please sign in to comment.