-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support system properties as a way of providing configuration options…
… to the CLI (#4104) * #3777 Support system properties as a way of providing configuration options to the CLI. * #3777 Define a more convenient naming convention for JVM properties. * Improve JVM system property to environment mapping by using an enum class instead of a Map. * Provide a friendly error message in case of liquibase home misconfiguration. * Externalize command line settings allowing for being reused by both LiquibaseCommandLine and LiquibaseLauncher. --------- Co-authored-by: filipe <flautert@liquibase.org>
- Loading branch information
1 parent
d093b2a
commit 9790070
Showing
3 changed files
with
176 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
liquibase-cli/src/main/java/liquibase/integration/commandline/LiquibaseLauncherSettings.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package liquibase.integration.commandline; | ||
|
||
/** | ||
* Convenience class for reading well known Liquibase command line settings (System and/or environment properties). | ||
* | ||
* @see LiquibaseLauncher | ||
*/ | ||
class LiquibaseLauncherSettings { | ||
|
||
private static final String LIQUIBASE_HOME_JVM_PROPERTY_NAME = "liquibase.home"; | ||
private static final String LIQUIBASE_LAUNCHER_DEBUG_JVM_PROPERTY_NAME = "liquibase.launcher.debug"; | ||
private static final String LIQUIBASE_LAUNCHER_PARENT_CLASSLOADER_JVM_PROPERTY_NAME = "liquibase.launcher.parent_classloader"; | ||
|
||
/** | ||
* Agglutinates the different settings, i.e., environment variables or associated JVM system properties, that can be | ||
* used for customizing the behavior of the class. | ||
*/ | ||
enum LiquibaseLauncherSetting { | ||
LIQUIBASE_HOME(LIQUIBASE_HOME_JVM_PROPERTY_NAME), | ||
LIQUIBASE_LAUNCHER_DEBUG(LIQUIBASE_LAUNCHER_DEBUG_JVM_PROPERTY_NAME), | ||
LIQUIBASE_LAUNCHER_PARENT_CLASSLOADER(LIQUIBASE_LAUNCHER_PARENT_CLASSLOADER_JVM_PROPERTY_NAME); | ||
|
||
private final String jvmPropertyName; | ||
|
||
LiquibaseLauncherSetting(String jvmPropertyName) { | ||
this.jvmPropertyName = jvmPropertyName; | ||
} | ||
|
||
String getJvmPropertyName() { | ||
return this.jvmPropertyName; | ||
} | ||
} | ||
|
||
static String getSetting(LiquibaseLauncherSetting setting) { | ||
String value = System.getProperty(setting.getJvmPropertyName()); | ||
if (value != null) { | ||
return value; | ||
} | ||
|
||
return System.getenv(setting.name()); | ||
} | ||
} |