Search in sources :

Example 16 with ToolsModule

use of org.apache.cayenne.dbsync.reverse.configuration.ToolsModule in project cayenne by apache.

the class DbImporterMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    Logger logger = new MavenLogger(this);
    // check missing data source parameters
    dataSource.validate();
    DbImportConfiguration config = createConfig(logger);
    Injector injector = DIBootstrap.createInjector(new DbSyncModule(), new ToolsModule(logger), new DbImportModule());
    DbImportConfigurationValidator validator = new DbImportConfigurationValidator(dbImportConfig, config, injector);
    try {
        validator.validate();
    } catch (Exception ex) {
        throw new MojoExecutionException(ex.getMessage(), ex);
    }
    try {
        injector.getInstance(DbImportAction.class).execute(config);
    } catch (Exception ex) {
        Throwable th = Util.unwindException(ex);
        String message = "Error importing database schema";
        if (th.getLocalizedMessage() != null) {
            message += ": " + th.getLocalizedMessage();
        }
        getLog().error(message);
        throw new MojoExecutionException(message, th);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DbImportConfigurationValidator(org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfigurationValidator) Logger(org.slf4j.Logger) DbImportAction(org.apache.cayenne.dbsync.reverse.dbimport.DbImportAction) ToolsModule(org.apache.cayenne.dbsync.reverse.configuration.ToolsModule) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DbImportConfiguration(org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfiguration) Injector(org.apache.cayenne.di.Injector) DbSyncModule(org.apache.cayenne.dbsync.DbSyncModule) DbImportModule(org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule)

Aggregations

ToolsModule (org.apache.cayenne.dbsync.reverse.configuration.ToolsModule)16 Injector (org.apache.cayenne.di.Injector)15 DbSyncModule (org.apache.cayenne.dbsync.DbSyncModule)12 Logger (org.slf4j.Logger)10 DataMap (org.apache.cayenne.map.DataMap)9 Test (org.junit.Test)6 File (java.io.File)5 URL (java.net.URL)4 DbAdapter (org.apache.cayenne.dba.DbAdapter)4 URLResource (org.apache.cayenne.resource.URLResource)4 DbGenerator (org.apache.cayenne.access.DbGenerator)3 DbImportAction (org.apache.cayenne.dbsync.reverse.dbimport.DbImportAction)3 DbImportConfigurationValidator (org.apache.cayenne.dbsync.reverse.dbimport.DbImportConfigurationValidator)3 DbImportModule (org.apache.cayenne.dbsync.reverse.dbimport.DbImportModule)3 ClassGenerationAction (org.apache.cayenne.gen.ClassGenerationAction)3 ClientClassGenerationAction (org.apache.cayenne.gen.ClientClassGenerationAction)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 BuildException (org.apache.tools.ant.BuildException)3 TaskAction (org.gradle.api.tasks.TaskAction)3