Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add liquibase flow and flow.validate goals to maven plugin (DAT-10576) #3015

Merged
merged 3 commits into from
Jul 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,10 @@ public Integer run() throws Exception {
java.util.logging.Logger liquibaseLogger = java.util.logging.Logger.getLogger("liquibase");
liquibaseLogger.setParent(rootLogger);

final JavaLogService logService = (JavaLogService) Scope.getCurrentScope().get(Scope.Attr.logService, LogService.class);
logService.setParent(liquibaseLogger);
LogService logService = Scope.getCurrentScope().get(Scope.Attr.logService, LogService.class);
if (logService instanceof JavaLogService) {
((JavaLogService) logService).setParent(liquibaseLogger);
}

if (main.logLevel == null) {
String defaultLogLevel = System.getProperty("liquibase.log.level");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package org.liquibase.maven.plugins;

import liquibase.Liquibase;
import liquibase.command.CommandScope;
import liquibase.exception.CommandExecutionException;
import liquibase.exception.LiquibaseException;
import org.liquibase.maven.property.PropertyElement;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;

public abstract class AbstractLiquibaseFlowMojo extends AbstractLiquibaseMojo {
/**
* Specifies the <i>flowFile</i> to use. If not specified, the default
* checks will be used and no file will be created.
*
* @parameter property="liquibase.flowFile"
*/
@PropertyElement
protected String flowFile;

/**
* @parameter property="liquibase.outputFile"
*/
@PropertyElement
protected File outputFile;

@Override
public boolean databaseConnectionRequired() {
return false;
}

@Override
protected void performLiquibaseTask(Liquibase liquibase) throws LiquibaseException {
CommandScope liquibaseCommand = new CommandScope(getCommandName());
liquibaseCommand.addArgumentValue("flowFile", flowFile);
liquibaseCommand.addArgumentValue("flowIntegration", "maven");
if (outputFile != null) {
try {
liquibaseCommand.setOutput(new FileOutputStream(outputFile));
} catch (FileNotFoundException e) {
throw new CommandExecutionException(e);
}
}
liquibaseCommand.execute();
}

public abstract String[] getCommandName();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package org.liquibase.maven.plugins;

/**
* Run a series of commands contained in one or more stages, as configured in a liquibase flow-file.
*
* @goal flow
*/
public class LiquibaseFlowMojo extends AbstractLiquibaseFlowMojo {

@Override
public String[] getCommandName() {
return new String[]{"flow"};
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.liquibase.maven.plugins;

/**
* Validate a series of commands contained in one or more stages, as configured in a liquibase flow-file.
*
* @goal flow.validate
*/
public class LiquibaseFlowValidateMojo extends AbstractLiquibaseFlowMojo{
@Override
public String[] getCommandName() {
return new String[]{"flow", "validate"};
}
}