}
checkCancel(subMon);
// get metadata
Metadata metadata;
File[] extractionSource = new File[1];
IFile metadataResource = project.getFile(METADATA_JSON_NAME);
boolean metadataDerived = metadataResource.isDerived();
if(metadataDerived) {
try {
// Delete this file. It will be recreated from other
// sources.
metadataResource.delete(true, subMon.newChild(1));
}
catch(CoreException e) {
log.error("Unable to delete metadata.json", e);
}
}
else {
// The one that will be created should be considered to
// be derived
metadataDerived = !metadataResource.exists();
subMon.worked(1);
}
Diagnostic diagnostic = new Diagnostic();
try {
// Load metadata, types, checksums etc.
metadata = forge.createFromModuleDirectory(projectDir, true, null, extractionSource, diagnostic);
}
catch(Exception e) {
createErrorMarker(project, "Can not parse Modulefile or other metadata source: " + e.getMessage(), null);
if(log.isDebugEnabled())
log.debug("Could not parse module description: '" + project.getName() + "'", e);
return; // give up - errors have been logged.
}
if(metadata == null) {
createErrorMarker(project, "Unable to find Modulefile or other metadata source", null);
return;
}
// Find the resource used for metadata extraction
File extractionSourceFile = extractionSource[0];
IPath extractionSourcePath = Path.fromOSString(extractionSourceFile.getAbsolutePath());
IFile moduleFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(extractionSourcePath);
createResourceMarkers(moduleFile, diagnostic);
// sync version and name project data
Version version = null;
ModuleName moduleName = null;
if(metadata != null) {
version = metadata.getVersion();
moduleName = metadata.getName();
}
if(version == null)
version = Version.fromString("0.0.0");