use of org.talend.repository.services.export.BuildDataServiceHandler in project tesb-studio-se by Talend.
the class ServiceExportWizard method performFinish.
@Override
public boolean performFinish() {
final String destinationValue = mainPage.getDestinationValue();
// TESB-7319: add confirm dialog
if (new File(destinationValue).exists()) {
boolean openQuestion = MessageDialog.openQuestion(getShell(), Messages.ServiceExportWizard_destinationExistTitle, Messages.ServiceExportWizard_destinationExistMessage);
if (!openQuestion) {
return false;
}
}
// END TESB-7319
Map<ExportChoice, Object> exportChoiceMap = mainPage.getExportChoiceMap();
exportChoiceMap.put(ExportChoice.doNotCompileCode, false);
exportChoiceMap.put(ExportChoice.needDependencies, false);
exportChoiceMap.put(ExportChoice.addStatistics, false);
exportChoiceMap.put(ExportChoice.addTracs, false);
exportChoiceMap.put(ExportChoice.needAntScript, false);
exportChoiceMap.put(ExportChoice.needMavenScript, false);
exportChoiceMap.put(ExportChoice.applyToChildren, false);
exportChoiceMap.put(ExportChoice.needContext, true);
exportChoiceMap.put(ExportChoice.binaries, true);
exportChoiceMap.put(ExportChoice.needSourceCode, false);
exportChoiceMap.put(ExportChoice.executeTests, false);
exportChoiceMap.put(ExportChoice.includeTestSource, false);
exportChoiceMap.put(ExportChoice.includeLibs, true);
exportChoiceMap.put(ExportChoice.needLog4jLevel, false);
exportChoiceMap.put(ExportChoice.needAssembly, true);
String bundleVersion = PomIdsHelper.getJobVersion(serviceItem.getProperty());
if (bundleVersion != null) {
bundleVersion = bundleVersion.replace("-", ".");
}
exportChoiceMap.put(ExportChoice.bundleVersion, bundleVersion);
// update to use BuildDataServiceHandler
IProgressMonitor pMonitor = new NullProgressMonitor();
int scale = 10;
BuildDataServiceHandler buildServiceHandler = new BuildDataServiceHandler(serviceItem, serviceItem.getProperty().getVersion(), IContext.DEFAULT, exportChoiceMap);
Map<String, Object> prepareParams = new HashMap<String, Object>();
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS, true);
prepareParams.put(IBuildResourceParametes.OPTION_ITEMS_DEPENDENCIES, true);
try {
buildServiceHandler.prepare(pMonitor, prepareParams);
buildServiceHandler.build(new SubProgressMonitor(pMonitor, scale));
IFile serviceTargetFile = buildServiceHandler.getJobTargetFile();
if (serviceTargetFile != null && serviceTargetFile.exists()) {
FilesUtils.copyFile(serviceTargetFile.getLocation().toFile(), new File(destinationValue));
} else {
if (GlobalServiceRegister.getDefault().isServiceRegistered(IRunProcessService.class)) {
IRunProcessService service = (IRunProcessService) GlobalServiceRegister.getDefault().getService(IRunProcessService.class);
ITalendProcessJavaProject talendJavaProject = service.getTalendJobJavaProject(serviceItem.getProperty());
String mvnLogFilePath = // $NON-NLS-1$
talendJavaProject.getProject().getFile("lastGenerated.log").getLocation().toPortableString();
Exception e = new Exception("Service was not built successfully, please check the logs for more details available on " + mvnLogFilePath);
MessageBoxExceptionHandler.process(e, getShell());
}
return false;
}
} catch (Exception e) {
MessageBoxExceptionHandler.process(e, getShell());
BuildCacheManager.getInstance().performBuildFailure();
return false;
} finally {
ProcessorUtilities.resetExportConfig();
}
mainPage.finish();
return true;
}
Aggregations