use of es.bsc.servicess.ide.ProjectMetadata in project compss by bsc-wdc.
the class InstrumentMojo method execute.
public void execute() throws MojoExecutionException {
try {
getLog().info("COMPSs code instrumentation...");
if (outputDirectory != null && outputDirectory.exists() && project != null) {
String classesFolder = outputDirectory.getAbsolutePath().concat(File.separator + "classes");
getLog().debug("Classes folder " + classesFolder);
List<String> ccp = project.getCompileClasspathElements();
List<String> cp = project.getRuntimeClasspathElements();
cp.addAll(ccp);
if (metadataFile != null && metadataFile.exists()) {
getLog().info("Getting values from metadata file...");
ProjectMetadata prMeta = new ProjectMetadata(metadataFile);
String[] extClasses = prMeta.getExternalOrchestrationClasses();
compssLocation = prMeta.getRuntimeLocation();
for (String cl : extClasses) {
getLog().warn("External classses not supported yet, skipping cl");
// extractPackages
// String classesFolder = addOrchestration(cp, cl, prMeta.getOrchestrationElementFormExternalClass(cl));
// instrument(cp, classesFolder, cl);
}
String[] intClasses = prMeta.getNonExternalOrchestrationClasses();
CommonUtils.instrumentOrchestrations(compssLocation, intClasses, classesFolder, cp, prMeta.getOrchestrationClassesTypes(intClasses), mainClass);
} else {
getLog().info("Metadata does not exists.");
}
if (orchestrations != null && orchestrations.length > 0) {
getLog().info("Treating defined orchestrations ...");
Map<String, List<String>> orchClassAndElements = ElementLabelUtils.getClassesAndElements(orchestrations);
for (Entry<String, List<String>> entry : orchClassAndElements.entrySet()) {
CommonUtils.preInstrumentOrchestration(compssLocation, entry.getKey(), entry.getValue(), classesFolder, cp);
String cl = entry.getKey();
boolean isWs = webServiceClasses != null && webServiceClasses.contains(cl) ? true : false;
boolean isMainClass = mainClass != null && cl.equals(mainClass) ? true : false;
CommonUtils.instrumentOrchestration(compssLocation, cl, classesFolder, cp, isWs, isMainClass);
}
} else {
getLog().info("There are not defined orchestrations.");
}
} else {
getLog().error("Output dir " + outputDirectory.getAbsolutePath() + " or maven project does not exist");
throw new MojoExecutionException("Output dir or maven project does not exist");
}
} catch (DependencyResolutionRequiredException e) {
getLog().error("Exception getting project classpath");
getLog().error(e);
throw new MojoExecutionException("Exception getting project classpath", e);
} catch (SAXException e) {
getLog().error("Exception parsing metadata file");
getLog().error(e);
throw new MojoExecutionException("Exception parsing metadata file", e);
} catch (IOException e) {
getLog().error("Exception parsing metadata file");
getLog().error(e);
throw new MojoExecutionException("Exception parsing metadata file", e);
} catch (ParserConfigurationException e) {
getLog().error("Exception parsing metadata file");
getLog().error(e);
throw new MojoExecutionException("Exception parsing metadata file", e);
} catch (Exception e) {
getLog().error("Exception getting orchestration Classes");
getLog().error(e);
throw new MojoExecutionException("Exception getting orchestration Classes", e);
}
}
Aggregations