Вы, вероятно, могли бы написать что-то довольно легко, а затем вызвать его из Ant:
import java.io.File;
import java.io.IOException;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.SchemaOutputResolver;
import javax.xml.transform.Result;
import javax.xml.transform.stream.StreamResult;
public class SchemaGenerator {
public static void main(String[] args) throws Exception {
String contextPath = args[0];
String outputDir = args[1];
JAXBContext jc = JAXBContext.newInstance(contextPath);
jc.generateSchema(new MySchemaOutputResolver(schemaFileName));
}
private static class MySchemaOutputResolver extends SchemaOutputResolver {
private String outputDir;
public MySchemaOutputResolver(String outputDir) {
this.outputDir = outputDir;
}
public Result createOutput(String namespaceURI, String suggestedFileName) throws IOException {
File file = new File(outputDir + "/" + suggestedFileName);
StreamResult result = new StreamResult(file);
result.setSystemId(file.toURI().toURL().toString());
return result;
}
}
}
В вашем контекстном пути вам понадобится файл jaxb.index со списком классов, который будет включен в ваш JAXBContext,Или вы можете передать имена классов в класс SchemaGenerator и загрузить их через ClassLoader.