
com.googlecode.mvnmigrate.ScriptCommandMojo Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of maven-migration-plugin Show documentation
Show all versions of maven-migration-plugin Show documentation
Migration-plugin is a Apache Maven 2 plugin that aims to integrate into the maven life cycle, the myBatis 3 Migration tool.
myBatis 3 Migration Schema is a tool that helps you to manage database schema changes.
/*
* Copyright 2010 The maven-migrate-plugin Team
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.googlecode.mvnmigrate;
import java.io.File;
import java.io.PrintStream;
import org.apache.ibatis.migration.commands.ScriptCommand;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
/**
* Goal which executes the ibatis migration script command.
*
* @version $Id: ScriptCommandMojo.java 132 2010-07-10 17:23:54Z marco.speranza79 $
* @goal script
*/
public class ScriptCommandMojo extends AbstractCommandMojo {
/**
* Initial version
*
* @parameter expression="${v2}"
*/
protected String v1;
/**
* Final version.
*
* @parameter expression="${v2}"
* @required
*/
protected String v2;
/**
* The output file to be create.
*
* @parameter expression="${output}"
*/
protected File output;
/**
* Creates a instance of script command mojo.
*/
public ScriptCommandMojo() {
super(ScriptCommand.class);
}
/**
* {@inheritDoc}
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (isSkip()) return;
try {
this.init();
if (this.output == null) {
// Set the default System.out PrintStream
this.getCommand().setPrintStream(System.out);
if (this.getLog().isInfoEnabled()) {
this.getLog().info(" Creating SQL script (From: "
+ this.v1
+ " to: "
+ this.v2
+")");
}
System.out.println(" --- CUT HERE ---");
} else {
if (!this.output.exists()) {
new File(this.output.getParent()).mkdirs();
}
this.getCommand().setPrintStream(new PrintStream(this.output));
}
this.getCommand().execute(this.v1
+ " "
+ this.v2);
if (this.getLog().isInfoEnabled()) {
if (this.output != null) {
this.getLog().info(" Created file: " + this.output);
} else {
System.out.println(" --- CUT HERE ---");
this.getLog().info(" Creating SQL script (From: "
+ this.v1
+ " to: "
+ this.v2
+ ")");
}
}
} catch (Exception e) {
throw new MojoExecutionException(e.getMessage(), e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy