Search in sources :

Example 21 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project liquibase by liquibase.

the class BaseLiquibaseTask method createResourceAccessor.

/**
     * Creates a suitable ResourceAccessor for use in an Ant task..
     *
     * @param classLoader The ClassLoader to use in the ResourceAccessor. It is preferable that it is an AntClassLoader.
     * @return A ResourceAccessor.
     */
private ResourceAccessor createResourceAccessor(ClassLoader classLoader) {
    FileSystemResourceAccessor fileSystemResourceAccessor = new FileSystemResourceAccessor();
    ClassLoaderResourceAccessor classLoaderResourceAccessor = new ClassLoaderResourceAccessor(classLoader);
    return new CompositeResourceAccessor(fileSystemResourceAccessor, classLoaderResourceAccessor);
}
Also used : CompositeResourceAccessor(liquibase.resource.CompositeResourceAccessor) FileSystemResourceAccessor(liquibase.resource.FileSystemResourceAccessor) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor)

Example 22 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project liquibase by liquibase.

the class TestContext method getTestResourceAccessor.

public ResourceAccessor getTestResourceAccessor() throws URISyntaxException, MalformedURLException {
    if (resourceAccessor == null) {
        File integrationJarsDir = new File(TestContext.getInstance().findIntegrationTestProjectRoot(), "src/test/resources/ext/jars");
        /*File samples1 = new File(integrationJarsDir, "liquibase-samplesqlgenerator.jar");
            File samples2 = new File(integrationJarsDir, "liquibase-changesample.jar");

            if (!samples2.exists()) {
                throw new RuntimeException("Could not find "+samples2.getAbsolutePath());
            }*/
        resourceAccessor = new ClassLoaderResourceAccessor(new URLClassLoader(new URL[] { //samples2.toURL(),
        new File(TestContext.getInstance().findCoreJvmProjectRoot(), "/target/classes").toURL(), new File(TestContext.getInstance().findCoreProjectRoot(), "/target/classes").toURL() }));
    }
    return resourceAccessor;
}
Also used : ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) File(java.io.File)

Example 23 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project api-core by ca-cwds.

the class ClientCountyDeterminationServiceTest method runLiquibaseScript.

private static void runLiquibaseScript(String script) throws LiquibaseException {
    try {
        final Liquibase liquibase = new Liquibase(script, new ClassLoaderResourceAccessor(), getDatabase());
        liquibase.update((String) null);
    } catch (Exception e) {
        throw new LiquibaseException(e);
    }
}
Also used : Liquibase(liquibase.Liquibase) LiquibaseException(liquibase.exception.LiquibaseException) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) DatabaseException(liquibase.exception.DatabaseException) SQLException(java.sql.SQLException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 24 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project api-core by ca-cwds.

the class DatabaseHelper method runScript.

public void runScript(String script) throws LiquibaseException {
    try {
        Liquibase liquibase = new Liquibase(script, new ClassLoaderResourceAccessor(), getDatabase());
        liquibase.update((String) null);
    } catch (Exception e) {
        throw new LiquibaseException(e);
    }
}
Also used : Liquibase(liquibase.Liquibase) LiquibaseException(liquibase.exception.LiquibaseException) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor) DatabaseException(liquibase.exception.DatabaseException) SQLException(java.sql.SQLException) LiquibaseException(liquibase.exception.LiquibaseException)

Example 25 with ClassLoaderResourceAccessor

use of liquibase.resource.ClassLoaderResourceAccessor in project microservice_framework by CJSCommonPlatform.

the class EventBufferIT method initDatabase.

private void initDatabase() throws Exception {
    Liquibase liquibase = new Liquibase(LIQUIBASE_STREAM_STATUS_CHANGELOG_XML, new ClassLoaderResourceAccessor(), new JdbcConnection(dataSource.getConnection()));
    liquibase.dropAll();
    liquibase.update("");
}
Also used : Liquibase(liquibase.Liquibase) JdbcConnection(liquibase.database.jvm.JdbcConnection) ClassLoaderResourceAccessor(liquibase.resource.ClassLoaderResourceAccessor)

Aggregations

ClassLoaderResourceAccessor (liquibase.resource.ClassLoaderResourceAccessor)38 Liquibase (liquibase.Liquibase)25 JdbcConnection (liquibase.database.jvm.JdbcConnection)20 SQLException (java.sql.SQLException)11 CompositeResourceAccessor (liquibase.resource.CompositeResourceAccessor)9 Database (liquibase.database.Database)8 LiquibaseException (liquibase.exception.LiquibaseException)8 Connection (java.sql.Connection)7 DatabaseException (liquibase.exception.DatabaseException)7 FileSystemResourceAccessor (liquibase.resource.FileSystemResourceAccessor)7 ResourceAccessor (liquibase.resource.ResourceAccessor)7 File (java.io.File)6 ArrayList (java.util.ArrayList)3 Contexts (liquibase.Contexts)3 FileOutputStream (java.io.FileOutputStream)2 DataSource (javax.sql.DataSource)2 ChangeLogParameters (liquibase.changelog.ChangeLogParameters)2 ChangeSet (liquibase.changelog.ChangeSet)2 DatabaseChangeLog (liquibase.changelog.DatabaseChangeLog)2 DatabaseConnection (liquibase.database.DatabaseConnection)2