Skip to content

Commit d31b02c

Browse files
EvaristeGalois11mhalbritter
authored andcommitted
Add liquibase ui-service property
See gh-39227
1 parent dae3952 commit d31b02c

File tree

5 files changed

+66
-4
lines changed

5 files changed

+66
-4
lines changed

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfiguration.java

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222
import liquibase.UpdateSummaryOutputEnum;
2323
import liquibase.change.DatabaseChange;
2424
import liquibase.integration.spring.SpringLiquibase;
25+
import liquibase.ui.UIServiceEnum;
2526

2627
import org.springframework.aot.hint.RuntimeHints;
2728
import org.springframework.aot.hint.RuntimeHintsRegistrar;
@@ -122,6 +123,9 @@ public SpringLiquibase liquibase(ObjectProvider<DataSource> dataSource,
122123
liquibase
123124
.setShowSummaryOutput(UpdateSummaryOutputEnum.valueOf(properties.getShowSummaryOutput().name()));
124125
}
126+
if (properties.getUiService() != null) {
127+
liquibase.setUiService(UIServiceEnum.valueOf(properties.getUiService().name()));
128+
}
125129
return liquibase;
126130
}
127131

spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseProperties.java

+36-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@
2222
import liquibase.UpdateSummaryEnum;
2323
import liquibase.UpdateSummaryOutputEnum;
2424
import liquibase.integration.spring.SpringLiquibase;
25+
import liquibase.ui.UIServiceEnum;
2526

2627
import org.springframework.boot.context.properties.ConfigurationProperties;
2728
import org.springframework.util.Assert;
@@ -147,6 +148,11 @@ public class LiquibaseProperties {
147148
*/
148149
private ShowSummaryOutput showSummaryOutput;
149150

151+
/**
152+
* Which UIService to use.
153+
*/
154+
private UIService uiService;
155+
150156
public String getChangeLog() {
151157
return this.changeLog;
152158
}
@@ -316,6 +322,14 @@ public void setShowSummaryOutput(ShowSummaryOutput showSummaryOutput) {
316322
this.showSummaryOutput = showSummaryOutput;
317323
}
318324

325+
public UIService getUiService() {
326+
return this.uiService;
327+
}
328+
329+
public void setUiService(UIService uiService) {
330+
this.uiService = uiService;
331+
}
332+
319333
/**
320334
* Enumeration of types of summary to show. Values are the same as those on
321335
* {@link UpdateSummaryEnum}. To maximize backwards compatibility, the Liquibase enum
@@ -368,4 +382,25 @@ public enum ShowSummaryOutput {
368382

369383
}
370384

385+
/**
386+
* Enumeration of types of UIService. Values are the same as those on
387+
* {@link UIServiceEnum}. To maximize backwards compatibility, the Liquibase enum is
388+
* not used directly.
389+
*
390+
* @since 3.3.0
391+
*/
392+
public enum UIService {
393+
394+
/**
395+
* Console-based UIService.
396+
*/
397+
CONSOLE,
398+
399+
/**
400+
* Logging-based UIService.
401+
*/
402+
LOGGER
403+
404+
}
405+
371406
}

spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata.json

+4
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,10 @@
19591959
"name": "spring.liquibase.show-summary-output",
19601960
"defaultValue": "log"
19611961
},
1962+
{
1963+
"name": "spring.liquibase.ui-service",
1964+
"defaultValue": "logger"
1965+
},
19621966
{
19631967
"name": "spring.mail.test-connection",
19641968
"description": "Whether to test that the mail server is available on startup.",

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibaseAutoConfigurationTests.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -33,6 +33,7 @@
3333
import liquibase.UpdateSummaryOutputEnum;
3434
import liquibase.command.core.helpers.ShowSummaryArgument;
3535
import liquibase.integration.spring.SpringLiquibase;
36+
import liquibase.ui.UIServiceEnum;
3637
import org.junit.jupiter.api.Test;
3738
import org.junit.jupiter.api.extension.ExtendWith;
3839
import org.junit.jupiter.api.io.TempDir;
@@ -226,6 +227,7 @@ void defaultValues() {
226227
assertThat(liquibase).extracting("showSummary").isNull();
227228
assertThat(ShowSummaryArgument.SHOW_SUMMARY.getDefaultValue()).isEqualTo(UpdateSummaryEnum.SUMMARY);
228229
assertThat(liquibase).extracting("showSummaryOutput").isEqualTo(UpdateSummaryOutputEnum.LOG);
230+
assertThat(liquibase).extracting("uiService").isEqualTo(UIServiceEnum.LOGGER);
229231
}));
230232
}
231233

@@ -411,6 +413,16 @@ void overrideShowSummaryOutput() {
411413
}));
412414
}
413415

416+
@Test
417+
void overrideUiService() {
418+
this.contextRunner.withUserConfiguration(EmbeddedDataSourceConfiguration.class)
419+
.withPropertyValues("spring.liquibase.ui-service=console")
420+
.run(assertLiquibase((liquibase) -> {
421+
UIServiceEnum uiService = (UIServiceEnum) ReflectionTestUtils.getField(liquibase, "uiService");
422+
assertThat(uiService).isEqualTo(UIServiceEnum.CONSOLE);
423+
}));
424+
}
425+
414426
@Test
415427
@SuppressWarnings("unchecked")
416428
void testOverrideParameters() {

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/liquibase/LiquibasePropertiesTests.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 the original author or authors.
2+
* Copyright 2012-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -21,10 +21,12 @@
2121

2222
import liquibase.UpdateSummaryEnum;
2323
import liquibase.UpdateSummaryOutputEnum;
24+
import liquibase.ui.UIServiceEnum;
2425
import org.junit.jupiter.api.Test;
2526

2627
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.ShowSummary;
2728
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.ShowSummaryOutput;
29+
import org.springframework.boot.autoconfigure.liquibase.LiquibaseProperties.UIService;
2830

2931
import static org.assertj.core.api.Assertions.assertThat;
3032

@@ -45,6 +47,11 @@ void valuesOfShowSummaryOutputMatchValuesOfUpdateSummaryOutputEnum() {
4547
assertThat(namesOf(ShowSummaryOutput.values())).isEqualTo(namesOf(UpdateSummaryOutputEnum.values()));
4648
}
4749

50+
@Test
51+
void valuesOfUiServiceMatchValuesOfUiServiceEnum() {
52+
assertThat(namesOf(UIService.values())).isEqualTo(namesOf(UIServiceEnum.values()));
53+
}
54+
4855
private List<String> namesOf(Enum<?>[] input) {
4956
return Stream.of(input).map(Enum::name).toList();
5057
}

0 commit comments

Comments
 (0)