////
/// First generate the main classes (and their associated classes and resources)
//
for (final MainClassSpec spec : mainClassSpecs) {
final JavaTypeName mainClassName = spec.getClassName();
final QualifiedName entryPointName = spec.getEntryPointName();
// Check the main class's configuration, and throw InvalidConfigurationException if there are problems
checkMainClassConfiguration(entryPointName, workspaceManager);
final ModuleName rootModule = entryPointName.getModuleName();
////
/// Write out the main class and the generated classes required by the class.
//
final String mainClassRelativePath = mainClassName.getName().replace('.', '/') + ".class";
final ZipEntry mainClassEntry = new ZipEntry(mainClassRelativePath);
final byte[] mainClassBytecode;
try {
final JavaClassRep mainClassRep = makeMainClass(mainClassName, entryPointName, workspaceManager);
mainClassBytecode = AsmJavaBytecodeGenerator.encodeClass(mainClassRep);
// Write out the source for the class
final String javaFileRelativePath = mainClassName.getName().replace('.', '/') + ".java";
final ZipEntry javaFileEntry = new ZipEntry(javaFileRelativePath);
sourceGen.generateSource(javaFileEntry, mainClassRep);
writeClassAndOtherRequiredClassesAndGatherResources(workspaceManager, jos, classesAlreadyAdded, sourcesAlreadyAdded, allRequredModules, rootModule, mainClassEntry, mainClassBytecode, sourceGen);
} catch (final JavaGenerationException e) {
// We should not have problems generating the main class - if there are any then it is an internal problem
throw new InternalProblemException(e);
}
}
////
/// Then generate the library classes (and their associated classes and resources)
//
for (final LibraryClassSpec spec : libClassSpecs) {
final JavaTypeName libClassName = spec.getClassName();
final ModuleName libModuleName = spec.getModuleName();
// Check the library class's configuration, and throw InvalidConfigurationException if there are problems
checkLibraryClassConfiguration(libModuleName, workspaceManager);
////
/// Write out the library class and the generated classes required by the class.
//
final String libClassRelativePath = libClassName.getName().replace('.', '/') + ".class";
final ZipEntry libClassEntry = new ZipEntry(libClassRelativePath);
final byte[] libClassBytecode;
try {
final JavaClassRep libClassRep = makeLibraryClass(spec.getScope(), libClassName, libModuleName, workspaceManager, monitor);
libClassBytecode = AsmJavaBytecodeGenerator.encodeClass(libClassRep);
// Write out the source for the class
final String javaFileRelativePath = libClassName.getName().replace('.', '/') + ".java";
final ZipEntry javaFileEntry = new ZipEntry(javaFileRelativePath);
sourceGen.generateSource(javaFileEntry, libClassRep);
writeClassAndOtherRequiredClassesAndGatherResources(workspaceManager, jos, classesAlreadyAdded, sourcesAlreadyAdded, allRequredModules, libModuleName, libClassEntry, libClassBytecode, sourceGen);