use of liquibase.resource.ResourceAccessor in project liquibase by liquibase.
the class LiquibaseDatabaseDiff method performLiquibaseTask.
@Override
protected void performLiquibaseTask(Liquibase liquibase) throws LiquibaseException {
ClassLoader cl = null;
ResourceAccessor fileOpener;
try {
cl = getClassLoaderIncludingProjectClasspath();
Thread.currentThread().setContextClassLoader(cl);
ClassLoader artifactClassLoader = getMavenArtifactClassLoader();
fileOpener = getFileOpener(artifactClassLoader);
} catch (MojoExecutionException e) {
throw new LiquibaseException("Could not create the class loader, " + e, e);
}
Database db = liquibase.getDatabase();
Database referenceDatabase = CommandLineUtils.createDatabaseObject(fileOpener, referenceUrl, referenceUsername, referencePassword, referenceDriver, referenceDefaultCatalogName, referenceDefaultSchemaName, outputDefaultCatalog, outputDefaultSchema, null, null, propertyProviderClass, null, null, databaseChangeLogTableName, databaseChangeLogLockTableName);
getLog().info("Performing Diff on database " + db.toString());
if (diffChangeLogFile != null) {
try {
DiffOutputControl diffOutputControl = new DiffOutputControl(diffIncludeCatalog, diffIncludeSchema, diffIncludeTablespace, null).addIncludedSchema(new CatalogAndSchema(referenceDefaultCatalogName, referenceDefaultSchemaName));
if (diffExcludeObjects != null && diffIncludeObjects != null) {
throw new UnexpectedLiquibaseException("Cannot specify both excludeObjects and includeObjects");
}
if (diffExcludeObjects != null) {
diffOutputControl.setObjectChangeFilter(new StandardObjectChangeFilter(StandardObjectChangeFilter.FilterType.EXCLUDE, diffExcludeObjects));
}
if (diffIncludeObjects != null) {
diffOutputControl.setObjectChangeFilter(new StandardObjectChangeFilter(StandardObjectChangeFilter.FilterType.INCLUDE, diffIncludeObjects));
}
CommandLineUtils.doDiffToChangeLog(diffChangeLogFile, referenceDatabase, db, diffOutputControl, StringUtils.trimToNull(diffTypes));
getLog().info("Differences written to Change Log File, " + diffChangeLogFile);
} catch (IOException e) {
throw new LiquibaseException(e);
} catch (ParserConfigurationException e) {
throw new LiquibaseException(e);
}
} else {
CommandLineUtils.doDiff(referenceDatabase, db, StringUtils.trimToNull(diffTypes));
}
}
use of liquibase.resource.ResourceAccessor in project liquibase by liquibase.
the class AbstractLiquibaseMojoTest method loadPropertiesFileIfPresent.
protected void loadPropertiesFileIfPresent(AbstractLiquibaseMojo mojo) throws MojoExecutionException, MojoFailureException {
File rootDir = new File(getBasedir(), "target/test-classes");
ResourceAccessor fo = new FileSystemResourceAccessor(rootDir.getAbsolutePath());
mojo.configureFieldsAndValues(fo);
}
use of liquibase.resource.ResourceAccessor in project liquibase by liquibase.
the class Liquibase method calculateCheckSum.
public CheckSum calculateCheckSum(final String filename, final String id, final String author) throws LiquibaseException {
log.info(String.format("Calculating checksum for changeset %s::%s::%s", filename, id, author));
final ChangeLogParameters changeLogParameters = this.getChangeLogParameters();
final ResourceAccessor resourceAccessor = this.getResourceAccessor();
final DatabaseChangeLog changeLog = ChangeLogParserFactory.getInstance().getParser(this.changeLogFile, resourceAccessor).parse(this.changeLogFile, changeLogParameters, resourceAccessor);
// TODO: validate?
final ChangeSet changeSet = changeLog.getChangeSet(filename, author, id);
if (changeSet == null) {
throw new LiquibaseException(new IllegalArgumentException("No such changeSet: " + filename + "::" + id + "::" + author));
}
return changeSet.generateCheckSum();
}
Aggregations