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);
}
}
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();
}
Aggregations