use of liquibase.resource.FileSystemResourceAccessor in project liquibase by liquibase.
the class AbstractLiquibaseChangeLogMojo method getResourceAccessor.
@Override
protected ResourceAccessor getResourceAccessor(ClassLoader cl) {
List<ResourceAccessor> resourceAccessors = new ArrayList<ResourceAccessor>();
resourceAccessors.add(new MavenResourceAccessor(cl));
resourceAccessors.add(new FileSystemResourceAccessor(project.getBasedir()));
resourceAccessors.add(new ClassLoaderResourceAccessor(getClass().getClassLoader()));
if (changeLogDirectory != null) {
calculateChangeLogDirectoryAbsolutePath();
resourceAccessors.add(new FileSystemResourceAccessor(new File(changeLogDirectory)));
}
return new CompositeResourceAccessor(resourceAccessors);
}
use of liquibase.resource.FileSystemResourceAccessor in project liquibase by liquibase.
the class LiquibaseRegisterChangeLogMojo method getResourceAccessor.
/**
* Override this method in order to create a ResourceAccessor which only
* looks for files in root and src/main/resources paths
*
* @param cl
* @return ResourceAccessor
*/
@Override
protected ResourceAccessor getResourceAccessor(ClassLoader cl) {
List<ResourceAccessor> resourceAccessors = new ArrayList<ResourceAccessor>();
File baseDir = project.getBasedir();
File sourceDir = new File(baseDir, "src/main/resources");
resourceAccessors.add(new FileSystemResourceAccessor(baseDir, sourceDir));
return new CompositeResourceAccessor(resourceAccessors);
}
use of liquibase.resource.FileSystemResourceAccessor in project collect by openforis.
the class LiquibaseRelationalSchemaCreator method createRelationalSchema.
@Override
public void createRelationalSchema(RelationalSchema schema, Connection targetConn) throws CollectRdbException {
PrintStream ps = null;
try {
LiquidbaseDatabaseSnapshotBuilder snapshotGen = new LiquidbaseDatabaseSnapshotBuilder();
Database rdb = getDatabaseImplementation(targetConn);
boolean dbSupportsFKs = rdb instanceof SQLiteDatabase ? false : true;
DatabaseSnapshot generatedSnapshot = snapshotGen.createSnapshot(schema, dbSupportsFKs);
String targetSchema = schema.getName();
rdb.setDefaultSchemaName(targetSchema);
DatabaseSnapshot emptyDbSnapshot = new DatabaseSnapshot(rdb, targetSchema);
// Generate change set
Diff diff = new Diff(generatedSnapshot, emptyDbSnapshot);
DiffResult diffResult = diff.compare();
File tmpFile = File.createTempFile("collect-schemagen", ".xml");
ps = new PrintStream(new FileOutputStream(tmpFile));
diffResult.setChangeSetAuthor("collect3");
diffResult.setChangeSetContext("schemagen");
System.out.println("Writing change log to " + tmpFile.getAbsolutePath());
diffResult.printChangeLog(ps, rdb);
ps.flush();
// Execute change set
Liquibase liq = new Liquibase(tmpFile.getName(), new FileSystemResourceAccessor(tmpFile.getParent()), rdb);
liq.update("schemagen");
} catch (LiquibaseException e) {
throw new CollectRdbException("Failed to update schema", e);
} catch (IOException e) {
throw new CollectRdbException("Failed to create temp db changelog file", e);
} catch (ParserConfigurationException e) {
throw new CollectRdbException("Failed to write temp db changelog file", e);
} finally {
if (ps != null) {
ps.close();
}
}
}
use of liquibase.resource.FileSystemResourceAccessor in project Singularity by HubSpot.
the class SingularityCuratorTestBase method setup.
@BeforeAll
public synchronized void setup() throws Exception {
JerseyGuiceUtils.reset();
singularityTestModule = new SingularityTestModule(useDBTests, customConfigSetup);
singularityTestModule.getInjector().injectMembers(this);
singularityTestModule.start();
leaderCacheCoordinator.activateLeaderCache();
configuration.setThreadpoolShutdownDelayInSeconds(0);
if (useDBTests) {
Handle handle = dbiProvider.get().open();
handle.getConnection().setAutoCommit(true);
Database database = DatabaseFactory.getInstance().findCorrectDatabaseImplementation(new JdbcConnection(handle.getConnection()));
Liquibase liquibase = new Liquibase("singularity_test.sql", new FileSystemResourceAccessor(), database);
liquibase.update((String) null);
try {
database.close();
handle.close();
} catch (Throwable t) {
}
}
}
Aggregations