// now code generate and compile the JAR
if (result) {
// filer implementation writes binary .xsd and generated source to disk
final ClassCollector classCollector = context.get(ClassCollector.class);
FilerImpl filer = new FilerImpl(classesDir, srcDir,
null, verbose, false) {
public Writer createSourceFile(String typename) throws IOException {
String tn = typename;
if (tn.contains("$")) {
tn = tn.substring(0, tn.indexOf('$'));
}
String pkg = tn.substring(0, tn.lastIndexOf('.'));
tn = tn.substring(tn.lastIndexOf('.') + 1);
classCollector.addTypesClassName(pkg, tn, pkg + "." + tn);
return super.createSourceFile(typename);
}
};
// currently just for schemaCodePrinter
XmlOptions options = new XmlOptions();
/*
if (codePrinter != null) {
options.setSchemaCodePrinter(codePrinter);
}
*/
options.setGenerateJavaVersion("1.5");
// save .xsb files
typeSystem.save(filer);
// gen source files
result &= SchemaTypeSystemCompiler.generateTypes(typeSystem, filer, options);
/*
for (String s : classCollector.getGeneratedFileInfo()) {
System.out.println(s);
}
*/
for (Map.Entry<String, String> ent : sourcesToCopyMap.entrySet()) {
try {
OutputStream out = filer.createBinaryFile("schema"
+ SchemaTypeSystemImpl.METADATA_PACKAGE_GEN
+ "/src/" + ent.getValue());
URL url = new URL(ent.getKey());
InputStream in = url.openStream();
IOUtils.copy(in, out);