"Unexpected exception while producing output", e);
throw new UnableToCompleteException();
}
List<Permutation> permsList = new ArrayList<Permutation>();
ArtifactSet generatedArtifacts = new ArtifactSet();
JJSOptions precompileOptions = null;
File compilerWorkDir = options.getCompilerWorkDir(moduleName);
List<Integer> permutationIds = new ArrayList<Integer>();
PrecompilationResult precompileResults;
try {
precompileResults = Util.readFileAsObject(new File(compilerWorkDir,
Precompile.PRECOMPILE_FILENAME), PrecompilationResult.class);
} catch (ClassNotFoundException e) {
logger.log(TreeLogger.ERROR, "Error reading "
+ Precompile.PRECOMPILE_FILENAME);
return false;
} catch (IOException e) {
logger.log(TreeLogger.ERROR, "Error reading "
+ Precompile.PRECOMPILE_FILENAME);
return false;
}
if (precompileResults instanceof PrecompileOptions) {
/**
* Precompiling happened on the shards.
*/
precompileOptions = (JJSOptions) precompileResults;
int numPermutations = module.getProperties().numPermutations();
for (int i = 0; i < numPermutations; ++i) {
permutationIds.add(i);
}
} else {
/**
* Precompiling happened on the start node.
*/
Precompilation precompilation = (Precompilation) precompileResults;
permsList.addAll(Arrays.asList(precompilation.getPermutations()));
generatedArtifacts.addAll(precompilation.getGeneratedArtifacts());
precompileOptions = precompilation.getUnifiedAst().getOptions();
for (Permutation perm : precompilation.getPermutations()) {
permutationIds.add(perm.getId());
}
}
List<FileBackedObject<PermutationResult>> resultFiles = new ArrayList<FileBackedObject<PermutationResult>>(
permutationIds.size());
for (int id : permutationIds) {
File f = CompilePerms.makePermFilename(compilerWorkDir, id);
if (!f.exists()) {
logger.log(TreeLogger.ERROR, "File not found '" + f.getAbsolutePath()
+ "'; please compile all permutations");
return false;
}
resultFiles.add(new FileBackedObject<PermutationResult>(
PermutationResult.class, f));
}
TreeLogger branch = logger.branch(TreeLogger.INFO, "Linking module "
+ module.getName());
StandardLinkerContext linkerContext = new StandardLinkerContext(branch,
module, precompileOptions);
ArtifactSet artifacts = doLink(branch, linkerContext, generatedArtifacts,
resultFiles);
try {
doProduceOutput(branch, artifacts, linkerContext, outFileSet,
extraFileSet);
} catch (IOException e) {