final long compilationVersion) {
// compile java
DiagnosticCollector<JavaFileObject> diagnosticCollector
= new DiagnosticCollector<JavaFileObject>();
JavaFileManager javaFileManager
= new JavaFileManagerImpl(javaCompiler.getStandardFileManager(diagnosticCollector,
Locale.US,
Charsets.US_ASCII),
outFs);
String className = classBase + compilationVersion;
try {
JavaFileObject compilationUnit = javaFileManager.getJavaFileForInput(
StandardLocation.SOURCE_PATH, className, JavaFileObject.Kind.SOURCE);
Iterable<JavaFileObject> compilationUnits = ImmutableList.of(compilationUnit);
javaCompiler.getTask(null, javaFileManager, diagnosticCollector,
null, null, compilationUnits).call();
List<Diagnostic<? extends JavaFileObject>> diagnostics =
filterErrors(diagnosticCollector.getDiagnostics());
if (!diagnostics.isEmpty()) {
throw new GxpCompilationException.Java(diagnostics);
}
List<byte[]> classFiles = Lists.newArrayList();
for (FileRef fileRef : outFs.getManifest()) {
if (fileRef.getKind().equals(JavaFileObject.Kind.CLASS)) {
String outputClassName = javaFileManager.inferBinaryName(StandardLocation.CLASS_OUTPUT,
new JavaFileRef(fileRef));
if (outputClassName.equals(className) || outputClassName.startsWith(className + "$")) {
classFiles.add(ByteStreams.toByteArray(fileRef.openInputStream()));
}
}