com.sun.tools.xjc.Driver Java Examples

The following examples show how to use com.sun.tools.xjc.Driver. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: JAXBDataBinding.java    From cxf with Apache License 2.0 6 votes vote down vote up
private void checkEncoding(ToolContext c) {
    String encoding = (String)c.get(ToolConstants.CFG_ENCODING);
    if (encoding != null) {
        try {
            CodeWriter.class.getDeclaredField("encoding");
        } catch (Throwable t) {
            c.remove(ToolConstants.CFG_ENCODING);
            String fenc = System.getProperty("file.encoding");
            if (!encoding.equals(fenc)) {
                LOG.log(Level.WARNING, "JAXB_NO_ENCODING_SUPPORT",
                        new String[] {Driver.getBuildID(), fenc});
            }
        }
    }

}
 
Example #2
Source File: XjcMain.java    From jax-maven-plugin with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) throws Throwable {
    if (Driver.run(args, System.out, System.out) != 0) {
        throw new Exception("xjc call failed, see logs above for details");
    }
}
 
Example #3
Source File: RunXJC.java    From maven-jaxb2-plugin with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static void main(String args[]) throws Exception {
	Driver.main(new String[] { "src\\main\\resources\\purchaseorder.xsd",
			"-b", "src\\main\\resources\\binding.xjb", "-d",
			"target/generated-sources/xjc" });
}
 
Example #4
Source File: GenerateClasses.java    From jaxb2-rich-contract-plugin with MIT License 4 votes vote down vote up
/**
     * Useful for debugging the plugin
     */
    public static void main(String[] args) throws Exception {

        Path rootDir = Paths.get(".").normalize().toAbsolutePath();
        if (!rootDir.endsWith(TEST_MODULE_NAME)) {
            rootDir = Paths.get("." + File.separator + TEST_MODULE_NAME).normalize().toAbsolutePath();
        }
        final Path resourcesDir = rootDir.resolve("src").resolve("main").resolve("resources");
        final Path schemaFile = resourcesDir.resolve("jaxb2-plugin-test.xsd");
        final Path bindingFile = resourcesDir.resolve("binding-config.xjb");
        // Use the same dir that the maven plugin uses
        final Path outputDir = rootDir
                .resolve("target")
                .resolve("generated-sources")
                .resolve("xjc");

        System.out.println("rootDir: " + rootDir.toAbsolutePath().toString());
        System.out.println("schemaFile: " + schemaFile.toAbsolutePath().toString());
        System.out.println("bindingFile: " + bindingFile.toAbsolutePath().toString());
        System.out.println("outputDir: " + outputDir.toAbsolutePath().toString());

        clearDirectory(outputDir);

        // Ensure the full path exists
        Files.createDirectories(outputDir);

        final String[] xjcOptions = new String[]{
                "-xmlschema",
                "-nv",
                "-extension",
                "-verbose",
//                "-p", PACKAGE_NAME,
                "-d", outputDir.toAbsolutePath().toString(),
                "-b", bindingFile.toAbsolutePath().toString(),
//                "-quiet",
                schemaFile.toAbsolutePath().toString(), //the source schema to gen classes from
                "-Ximmutable",
                "-Xfluent-builder",
                "-generateJavadocFromAnnotations=true",
                "-Xclone",
                // TODO Not sure how to handle the episodes file that group-contract needs
//                "-Xgroup-contract",
        };

        System.out.println("Running XJC with arguments:");
        Arrays.stream(xjcOptions)
                .map(str -> "  " + str)
                .forEach(System.out::println);

        // Run the xjc code generation process
        final int exitStatus = Driver.run(xjcOptions, System.out, System.out);

        if (exitStatus != 0) {
            System.out.print("Executing xjc failed");
            System.exit(1);
        }
    }