use of com.mulesoft.tools.migration.exception.MigrationTaskException 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);
}
}
use of com.mulesoft.tools.migration.exception.MigrationTaskException in project mule-migration-assistant by mulesoft.
the class AbstractMigrationTask method execute.
@Override
public void execute(MigrationReport report) throws Exception {
// TODO depending on the project type this may not be true
checkState(applicationModel != null, "An application model must be provided.");
List<MigrationStep> steps = enableReporting(getSteps());
try {
if (steps != null) {
MigrationStepSelector stepSelector = new MigrationStepSelector(steps);
if (shouldExecuteAllSteps(stepSelector)) {
steps.stream().filter(s -> s instanceof ExpressionMigratorAware).forEach(s -> ((ExpressionMigratorAware) s).setExpressionMigrator(getExpressionMigrator()));
stepSelector.getNameSpaceContributionSteps().forEach(s -> s.execute(applicationModel, report));
stepSelector.getApplicationModelContributionSteps().forEach(s -> {
s.setApplicationModel(applicationModel);
fetchAndProcessNodes(report, s, new ArrayList<>());
});
stepSelector.getProjectStructureContributionSteps().forEach(s -> {
s.setApplicationModel(applicationModel);
s.execute(applicationModel.getProjectBasePath(), report);
});
stepSelector.getPomContributionSteps().forEach(s -> {
s.setApplicationModel(applicationModel);
s.execute(applicationModel.getPomModel().orElse(new PomModel()), report);
});
}
}
} catch (MigrationAbortException e) {
throw e;
} catch (Exception e) {
throw new MigrationTaskException("Task execution exception. " + e.getMessage(), e);
}
}
Aggregations