use of org.apache.xmlbeans.SchemaCodePrinter in project airavata by apache.
the class SchemaCompilerUtil method compile.
public static void compile(String[] args) {
if (args.length == 0) {
return;
}
Set flags = new HashSet();
flags.add("h");
flags.add("help");
flags.add("usage");
flags.add("license");
flags.add("quiet");
flags.add("verbose");
flags.add("version");
flags.add("dl");
flags.add("noupa");
flags.add("nopvr");
flags.add("noann");
flags.add("novdoc");
flags.add("noext");
flags.add("srconly");
flags.add("debug");
Set opts = new HashSet();
opts.add("out");
opts.add("name");
opts.add("src");
opts.add("d");
opts.add("cp");
opts.add("compiler");
opts.add("javasource");
// deprecated
opts.add("jar");
opts.add("ms");
opts.add("mx");
opts.add("repackage");
opts.add("schemaCodePrinter");
opts.add("extension");
opts.add("extensionParms");
opts.add("allowmdef");
opts.add("catalog");
CommandLine cl = new CommandLine(args, flags, opts);
String[] badopts = cl.getBadOpts();
if (badopts.length > 0) {
for (int i = 0; i < badopts.length; i++) System.out.println("Unrecognized option: " + badopts[i]);
return;
}
boolean verbose = (cl.getOpt("verbose") != null);
boolean quiet = (cl.getOpt("quiet") != null);
if (verbose)
quiet = false;
String outputfilename = cl.getOpt("out");
String repackage = cl.getOpt("repackage");
cl.getOpt("schemaCodePrinter");
SchemaCodePrinter codePrinter = null;
String name = cl.getOpt("name");
boolean download = (cl.getOpt("dl") != null);
boolean noUpa = (cl.getOpt("noupa") != null);
boolean noPvr = (cl.getOpt("nopvr") != null);
boolean noAnn = (cl.getOpt("noann") != null);
boolean noVDoc = (cl.getOpt("novdoc") != null);
boolean noExt = (cl.getOpt("noext") != null);
boolean nojavac = (cl.getOpt("srconly") != null);
boolean debug = (cl.getOpt("debug") != null);
String allowmdef = cl.getOpt("allowmdef");
Set mdefNamespaces = (allowmdef == null ? Collections.EMPTY_SET : new HashSet(Arrays.asList(XmlListImpl.split_list(allowmdef))));
List extensions = new ArrayList();
String classesdir = cl.getOpt("d");
File classes = null;
if (classesdir != null)
classes = new File(classesdir);
String srcdir = cl.getOpt("src");
File src = null;
if (srcdir != null)
src = new File(srcdir);
if (nojavac && srcdir == null && classes != null)
src = classes;
// create temp directory
File tempdir = null;
if (src == null || classes == null) {
throw new WorkflowRuntimeException("Code gen src directory or classes directory is null");
}
File jarfile = null;
if (outputfilename == null && classes == null && !nojavac)
outputfilename = "xmltypes.jar";
if (outputfilename != null)
jarfile = new File(outputfilename);
if (src == null)
src = IOUtil.createDir(tempdir, "src");
if (classes == null)
classes = IOUtil.createDir(tempdir, "classes");
File[] classpath = null;
String cpString = cl.getOpt("cp");
if (cpString != null) {
String[] cpparts = cpString.split(File.pathSeparator);
List cpList = new ArrayList();
for (int i = 0; i < cpparts.length; i++) cpList.add(new File(cpparts[i]));
classpath = (File[]) cpList.toArray(new File[cpList.size()]);
} else {
classpath = CodeGenUtil.systemClasspath();
}
String javasource = cl.getOpt("javasource");
String compiler = cl.getOpt("compiler");
String jar = cl.getOpt("jar");
if (verbose && jar != null)
System.out.println("The 'jar' option is no longer supported.");
String memoryInitialSize = cl.getOpt("ms");
String memoryMaximumSize = cl.getOpt("mx");
File[] xsdFiles = cl.filesEndingWith(".xsd");
File[] wsdlFiles = cl.filesEndingWith(".wsdl");
File[] javaFiles = cl.filesEndingWith(".java");
File[] configFiles = cl.filesEndingWith(".xsdconfig");
URL[] urlFiles = cl.getURLs();
if (xsdFiles.length + wsdlFiles.length + urlFiles.length == 0) {
System.out.println("Could not find any xsd or wsdl files to process.");
return;
}
File baseDir = cl.getBaseDir();
URI baseURI = baseDir == null ? null : baseDir.toURI();
XmlErrorPrinter err = new XmlErrorPrinter(verbose, baseURI);
String catString = cl.getOpt("catalog");
Parameters params = new Parameters();
params.setBaseDir(baseDir);
params.setXsdFiles(xsdFiles);
params.setWsdlFiles(wsdlFiles);
params.setJavaFiles(javaFiles);
params.setConfigFiles(configFiles);
params.setUrlFiles(urlFiles);
params.setClasspath(classpath);
params.setOutputJar(jarfile);
params.setName(name);
params.setSrcDir(src);
params.setClassesDir(classes);
params.setCompiler(compiler);
params.setJavaSource(javasource);
params.setMemoryInitialSize(memoryInitialSize);
params.setMemoryMaximumSize(memoryMaximumSize);
params.setNojavac(nojavac);
params.setQuiet(quiet);
params.setVerbose(verbose);
params.setDownload(download);
params.setNoUpa(noUpa);
params.setNoPvr(noPvr);
params.setNoAnn(noAnn);
params.setNoVDoc(noVDoc);
params.setNoExt(noExt);
params.setDebug(debug);
params.setErrorListener(err);
params.setRepackage(repackage);
params.setExtensions(extensions);
params.setMdefNamespaces(mdefNamespaces);
params.setCatalogFile(catString);
params.setSchemaCodePrinter(codePrinter);
compile(params);
}
Aggregations