use of liquibase.configuration.LiquibaseConfiguration in project liquibase by liquibase.
the class BaseLiquibaseTask method shouldRun.
protected boolean shouldRun() {
LiquibaseConfiguration configuration = LiquibaseConfiguration.getInstance();
GlobalConfiguration globalConfiguration = configuration.getConfiguration(GlobalConfiguration.class);
if (!globalConfiguration.getShouldRun()) {
log("Liquibase did not run because " + configuration.describeValueLookupLogic(globalConfiguration.getProperty(GlobalConfiguration.SHOULD_RUN)) + " was set to false", Project.MSG_INFO);
return false;
}
return true;
}
use of liquibase.configuration.LiquibaseConfiguration in project liquibase by liquibase.
the class BaseLiquibaseTask method getDefaultOutputEncoding.
protected String getDefaultOutputEncoding() {
LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance();
GlobalConfiguration globalConfiguration = liquibaseConfiguration.getConfiguration(GlobalConfiguration.class);
return globalConfiguration.getOutputEncoding();
}
use of liquibase.configuration.LiquibaseConfiguration in project liquibase by liquibase.
the class AbstractLiquibaseMojo method execute.
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
getLog().info(MavenUtils.LOG_SEPARATOR);
if (server != null) {
AuthenticationInfo info = wagonManager.getAuthenticationInfo(server);
if (info != null) {
username = info.getUserName();
password = info.getPassword();
}
}
processSystemProperties();
LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance();
if (!liquibaseConfiguration.getConfiguration(GlobalConfiguration.class).getShouldRun()) {
getLog().info("Liquibase did not run because " + liquibaseConfiguration.describeValueLookupLogic(GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN) + " was set to false");
return;
}
if (skip) {
getLog().warn("Liquibase skipped due to maven configuration");
return;
}
ClassLoader artifactClassLoader = getMavenArtifactClassLoader();
ResourceAccessor fileOpener = getFileOpener(artifactClassLoader);
configureFieldsAndValues(fileOpener);
LogFactory.getInstance().setDefaultLoggingLevel(logging);
// Displays the settings for the Mojo depending of verbosity mode.
displayMojoSettings();
// Check that all the parameters that must be specified have been by the user.
checkRequiredParametersAreSpecified();
Database database = null;
try {
String dbPassword = emptyPassword || password == null ? "" : password;
String driverPropsFile = (driverPropertiesFile == null) ? null : driverPropertiesFile.getAbsolutePath();
database = CommandLineUtils.createDatabaseObject(artifactClassLoader, url, username, dbPassword, driver, defaultCatalogName, defaultSchemaName, outputDefaultCatalog, outputDefaultSchema, databaseClass, driverPropsFile, propertyProviderClass, changelogCatalogName, changelogSchemaName, databaseChangeLogTableName, databaseChangeLogLockTableName);
liquibase = createLiquibase(fileOpener, database);
getLog().debug("expressionVars = " + String.valueOf(expressionVars));
if (expressionVars != null) {
for (Map.Entry<Object, Object> var : expressionVars.entrySet()) {
this.liquibase.setChangeLogParameter(var.getKey().toString(), var.getValue());
}
}
getLog().debug("expressionVariables = " + String.valueOf(expressionVariables));
if (expressionVariables != null) {
for (Map.Entry var : (Set<Map.Entry>) expressionVariables.entrySet()) {
if (var.getValue() != null) {
this.liquibase.setChangeLogParameter(var.getKey().toString(), var.getValue());
}
}
}
if (clearCheckSums) {
getLog().info("Clearing the Liquibase Checksums on the database");
liquibase.clearCheckSums();
}
getLog().info("Executing on Database: " + url);
if (isPromptOnNonLocalDatabase()) {
if (!liquibase.isSafeToRunUpdate()) {
if (UIFactory.getInstance().getFacade().promptForNonLocalDatabase(liquibase.getDatabase())) {
throw new LiquibaseException("User decided not to run against non-local database");
}
}
}
performLiquibaseTask(liquibase);
} catch (LiquibaseException e) {
cleanup(database);
throw new MojoExecutionException("Error setting up or running Liquibase: " + e.getMessage(), e);
}
cleanup(database);
getLog().info(MavenUtils.LOG_SEPARATOR);
getLog().info("");
}
use of liquibase.configuration.LiquibaseConfiguration in project liquibase by liquibase.
the class CDILiquibase method onStartup.
@PostConstruct
public void onStartup() {
log.info("Booting Liquibase " + LiquibaseUtil.getBuildVersion());
String hostName;
try {
hostName = NetUtil.getLocalHostName();
} catch (Exception e) {
log.warning("Cannot find hostname: " + e.getMessage());
log.debug("", e);
return;
}
LiquibaseConfiguration liquibaseConfiguration = LiquibaseConfiguration.getInstance();
if (!liquibaseConfiguration.getConfiguration(GlobalConfiguration.class).getShouldRun()) {
log.info("Liquibase did not run on " + hostName + " because " + liquibaseConfiguration.describeValueLookupLogic(GlobalConfiguration.class, GlobalConfiguration.SHOULD_RUN) + " was set to false");
return;
}
initialized = true;
try {
performUpdate();
} catch (LiquibaseException e) {
throw new UnexpectedLiquibaseException(e);
}
}
Aggregations