use of liquibase.resource.FileSystemResourceAccessor in project liquibase by liquibase.
the class ConvertCommandStep method run.
@Override
public void run(CommandResultsBuilder resultsBuilder) throws Exception {
CommandScope commandScope = resultsBuilder.getCommandScope();
String src = commandScope.getArgumentValue(SRC_ARG);
String out = commandScope.getArgumentValue(OUT_ARG);
String classpath = commandScope.getArgumentValue(CLASSPATH_ARG);
List<ResourceAccessor> openers = new ArrayList<>();
openers.add(new FileSystemResourceAccessor());
openers.add(new ClassLoaderResourceAccessor());
if (classpath != null) {
openers.add(new FileSystemResourceAccessor(new File(classpath)));
}
ResourceAccessor resourceAccessor = new CompositeResourceAccessor(openers);
ChangeLogParser sourceParser = ChangeLogParserFactory.getInstance().getParser(src, resourceAccessor);
ChangeLogSerializer outSerializer = ChangeLogSerializerFactory.getInstance().getSerializer(out);
DatabaseChangeLog changeLog = sourceParser.parse(src, new ChangeLogParameters(), resourceAccessor);
File outFile = new File(out);
if (!outFile.exists()) {
outFile.getParentFile().mkdirs();
}
try (FileOutputStream outputStream = new FileOutputStream(outFile)) {
outSerializer.write(changeLog.getChangeSets(), outputStream);
}
Scope.getCurrentScope().getUI().sendMessage("Converted successfully");
}
use of liquibase.resource.FileSystemResourceAccessor in project traccar by tananaev.
the class DataManager method initDatabaseSchema.
private void initDatabaseSchema() throws LiquibaseException {
if (config.hasKey(Keys.DATABASE_CHANGELOG)) {
ResourceAccessor resourceAccessor = new FileSystemResourceAccessor(new File("."));
Database database = DatabaseFactory.getInstance().openDatabase(config.getString(Keys.DATABASE_URL), config.getString(Keys.DATABASE_USER), config.getString(Keys.DATABASE_PASSWORD), config.getString(Keys.DATABASE_DRIVER), null, null, null, resourceAccessor);
Liquibase liquibase = new Liquibase(config.getString(Keys.DATABASE_CHANGELOG), resourceAccessor, database);
liquibase.clearCheckSums();
liquibase.update(new Contexts());
}
}
use of liquibase.resource.FileSystemResourceAccessor 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);
}
use of liquibase.resource.FileSystemResourceAccessor in project liquibase by liquibase.
the class AbstractLiquibaseChangeLogMojo method getFileOpener.
@Override
protected ResourceAccessor getFileOpener(ClassLoader cl) {
ResourceAccessor mFO = new MavenResourceAccessor(cl);
ResourceAccessor fsFO = new FileSystemResourceAccessor(project.getBasedir().getAbsolutePath());
return new CompositeResourceAccessor(mFO, fsFO);
}
use of liquibase.resource.FileSystemResourceAccessor in project liquibase by liquibase.
the class AbstractLiquibaseMojo method getFileOpener.
protected ResourceAccessor getFileOpener(ClassLoader cl) {
ResourceAccessor mFO = new MavenResourceAccessor(cl);
ResourceAccessor fsFO = new FileSystemResourceAccessor(project.getBasedir().getAbsolutePath());
return new CompositeResourceAccessor(mFO, fsFO);
}
Aggregations