Search in sources :

Example 1 with ProjectType

use of com.mulesoft.tools.migration.project.ProjectType in project mule-migration-assistant by mulesoft.

the class MigrationJob method execute.

@Override
public void execute(MigrationReport report) throws Exception {
    ApplicationModel applicationModel = generateSourceApplicationModel(project);
    report.initialize(applicationModel.getProjectType(), project.getFileName().toString());
    Path sourceProjectBasePath = applicationModel.getProjectBasePath();
    persistApplicationModel(applicationModel);
    ProjectType targetProjectType = applicationModel.getProjectType().getTargetType();
    applicationModel = generateTargetApplicationModel(outputProject, targetProjectType, sourceProjectBasePath, projectParentGAV, projectGAV);
    try {
        for (AbstractMigrationTask task : migrationTasks) {
            if (task.getApplicableProjectTypes().contains(targetProjectType)) {
                task.setApplicationModel(applicationModel);
                task.setExpressionMigrator(new MelToDwExpressionMigrator(report, applicationModel));
                try {
                    task.execute(report);
                    persistApplicationModel(applicationModel);
                    applicationModel = generateTargetApplicationModel(outputProject, targetProjectType, sourceProjectBasePath, projectParentGAV, projectGAV);
                } catch (MigrationTaskException ex) {
                    if (cancelOnError) {
                        throw ex;
                    } else {
                        logger.error("Failed to apply task, rolling back and continuing with the next one.", ex);
                    }
                } catch (RuntimeException e) {
                    throw new MigrationJobException("Failed to continue executing migration: " + e.getClass().getName() + ": " + e.getMessage(), e);
                }
            }
        }
    } finally {
        generateReport(report, applicationModel);
    }
}
Also used : Path(java.nio.file.Path) MelToDwExpressionMigrator(com.mulesoft.tools.migration.library.tools.MelToDwExpressionMigrator) MigrationJobException(com.mulesoft.tools.migration.engine.exception.MigrationJobException) AbstractMigrationTask(com.mulesoft.tools.migration.task.AbstractMigrationTask) ProjectType(com.mulesoft.tools.migration.project.ProjectType) ApplicationModel(com.mulesoft.tools.migration.project.model.ApplicationModel) MigrationTaskException(com.mulesoft.tools.migration.exception.MigrationTaskException)

Example 2 with ProjectType

use of com.mulesoft.tools.migration.project.ProjectType in project mule-migration-assistant by mulesoft.

the class MigrationJob method generateSourceApplicationModel.

private ApplicationModel generateSourceApplicationModel(Path project) throws Exception {
    ProjectTypeFactory projectFactory = new ProjectTypeFactory();
    ProjectType type = projectFactory.getProjectType(project);
    MuleProject muleProject = getMuleProject(project, type);
    ApplicationModelBuilder builder = new ApplicationModelBuilder().withConfigurationFiles(getFiles(muleProject.srcMainConfiguration(), "xml")).withProjectType(type).withMuleVersion(muleVersion).withPom(muleProject.pom()).withProjectPomGAV(projectGAV).withProjectBasePath(muleProject.getBaseFolder()).withSupportedNamespaces(getTasksDeclaredNamespaces(migrationTasks));
    if (muleProject.srcTestConfiguration().toFile().exists()) {
        builder.withTestConfigurationFiles(getFiles(muleProject.srcTestConfiguration(), "xml"));
    }
    return builder.build();
}
Also used : MuleProject(com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject) MuleProjectFactory.getMuleProject(com.mulesoft.tools.migration.engine.project.MuleProjectFactory.getMuleProject) ApplicationModelBuilder(com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder) ProjectType(com.mulesoft.tools.migration.project.ProjectType) ProjectTypeFactory(com.mulesoft.tools.migration.engine.project.ProjectTypeFactory)

Aggregations

ProjectType (com.mulesoft.tools.migration.project.ProjectType)2 MigrationJobException (com.mulesoft.tools.migration.engine.exception.MigrationJobException)1 MuleProjectFactory.getMuleProject (com.mulesoft.tools.migration.engine.project.MuleProjectFactory.getMuleProject)1 ProjectTypeFactory (com.mulesoft.tools.migration.engine.project.ProjectTypeFactory)1 MuleProject (com.mulesoft.tools.migration.engine.project.structure.mule.MuleProject)1 MigrationTaskException (com.mulesoft.tools.migration.exception.MigrationTaskException)1 MelToDwExpressionMigrator (com.mulesoft.tools.migration.library.tools.MelToDwExpressionMigrator)1 ApplicationModel (com.mulesoft.tools.migration.project.model.ApplicationModel)1 ApplicationModelBuilder (com.mulesoft.tools.migration.project.model.ApplicationModel.ApplicationModelBuilder)1 AbstractMigrationTask (com.mulesoft.tools.migration.task.AbstractMigrationTask)1 Path (java.nio.file.Path)1