Package com.celum.dbtool.mojo

Source Code of com.celum.dbtool.mojo.PatchMojo

package com.celum.dbtool.mojo;

import com.celum.dbtool.Db;
import com.celum.dbtool.configuration.DbConfiguration;
import com.celum.dbtool.resource.DbStepResource;
import com.celum.dbtool.resource.DirResource;
import com.celum.dbtool.resource.PackageResource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;

import java.io.File;

/**
* @author Zdenko Vrabel (zdenko.vrabel@celum.com)
*
* @goal patch
*/
public class PatchMojo extends AbstractDbMojo
{

    /**
     * @parameter default-value="${basedir}/src/main/sql/patch"
     */
    protected File stepsDir;


    /**
     * @parameter
     */
    protected String stepsPackage;


    /**
     * @parameter default-value="PATCH"
     */
    protected String patchTable;


    @Override
    public void execute() throws MojoExecutionException, MojoFailureException
    {
        try {
            registerVersionFactoryFromSettings();

            DbConfiguration config =
                    DbConfiguration.createSelfInitConfigurationForTable(patchTable)
                                   .setDataSource(getDataSource())
                                   .setVariables(getParameters())
                                   .setEventListener(this);

            if (stepsPackage == null || stepsPackage.isEmpty()) {
                config.setStepsSourceForDirectory(stepsDir);
            } else {
                config.setStepsSource(new PackageResource(stepsPackage, getClassLoaderWithCompiledClasses()));
            }

            config.build().patch();

        } catch (Exception e) {
            getLog().error(e);
        }
    }

}
TOP

Related Classes of com.celum.dbtool.mojo.PatchMojo

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.