Search in sources :

Example 1 with LiquibaseConfiguration

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;
}
Also used : GlobalConfiguration(liquibase.configuration.GlobalConfiguration) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration)

Example 2 with LiquibaseConfiguration

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();
}
Also used : GlobalConfiguration(liquibase.configuration.GlobalConfiguration) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration)

Example 3 with LiquibaseConfiguration

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("");
}
Also used : CompositeResourceAccessor(liquibase.resource.CompositeResourceAccessor) FileSystemResourceAccessor(liquibase.resource.FileSystemResourceAccessor) ResourceAccessor(liquibase.resource.ResourceAccessor) GlobalConfiguration(liquibase.configuration.GlobalConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AuthenticationInfo(org.apache.maven.wagon.authentication.AuthenticationInfo) Database(liquibase.database.Database) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration) URLClassLoader(java.net.URLClassLoader) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 4 with LiquibaseConfiguration

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);
    }
}
Also used : GlobalConfiguration(liquibase.configuration.GlobalConfiguration) LiquibaseConfiguration(liquibase.configuration.LiquibaseConfiguration) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) LiquibaseException(liquibase.exception.LiquibaseException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) SQLException(java.sql.SQLException) UnexpectedLiquibaseException(liquibase.exception.UnexpectedLiquibaseException) DatabaseException(liquibase.exception.DatabaseException) LiquibaseException(liquibase.exception.LiquibaseException) PostConstruct(javax.annotation.PostConstruct)

Aggregations

GlobalConfiguration (liquibase.configuration.GlobalConfiguration)4 LiquibaseConfiguration (liquibase.configuration.LiquibaseConfiguration)4 LiquibaseException (liquibase.exception.LiquibaseException)2 UnexpectedLiquibaseException (liquibase.exception.UnexpectedLiquibaseException)2 URLClassLoader (java.net.URLClassLoader)1 SQLException (java.sql.SQLException)1 PostConstruct (javax.annotation.PostConstruct)1 Database (liquibase.database.Database)1 DatabaseException (liquibase.exception.DatabaseException)1 CompositeResourceAccessor (liquibase.resource.CompositeResourceAccessor)1 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)1 ResourceAccessor (liquibase.resource.ResourceAccessor)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 AuthenticationInfo (org.apache.maven.wagon.authentication.AuthenticationInfo)1