Package org.apache.commons.jci.compilers

Examples of org.apache.commons.jci.compilers.JavaCompilerSettings


        String[] resources = new String[] {targetResource};

        JavaCompiler javaCompiler = (new JavaCompilerFactory()).createCompiler(options.getCompiler().substring(4));
        FileResourceReader reader = new FileResourceReader(ctxt.getOptions().getScratchDir());
        FileResourceStore store = new FileResourceStore(ctxt.getOptions().getScratchDir());
        JavaCompilerSettings settings = javaCompiler.createDefaultSettings();
        if (settings == null) {
            settings = new JavaCompilerSettings();
        }
        settings.setDeprecations(false);
        if (ctxt.getOptions().getJavaEncoding() != null) {
            settings.setSourceEncoding(ctxt.getOptions().getJavaEncoding());
        }
        if (ctxt.getOptions().getClassDebugInfo()) {
            // No support
        }
        // Source JVM
        if (ctxt.getOptions().getCompilerSourceVM() != null) {
            settings.setSourceVersion(ctxt.getOptions().getCompilerSourceVM());
        } else {
            // Default to 1.5
            settings.setSourceVersion("1.5");
        }
        // Target JVM
        if (ctxt.getOptions().getCompilerTargetVM() != null) {
            settings.setTargetVersion(ctxt.getOptions().getCompilerTargetVM());
        } else {
            // Default to 1.5
            settings.setTargetVersion("1.5");
        }

        CompilationResult result = javaCompiler.compile(resources, reader, store, classLoader, settings);
       
        ArrayList<JavacErrorDetail> problemList = new ArrayList<JavacErrorDetail>();
View Full Code Here


        int maxwarns = 10;
        final boolean nowarn = cmd.hasOption("nowarn");


        final JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse");
        final JavaCompilerSettings settings = compiler.createDefaultSettings();


        for (Iterator it = cmd.iterator(); it.hasNext();) {
            final Option option = (Option) it.next();
            if ("classpath".equals(option.getOpt())) {
                final String[] values = option.getValues();
                final URL[] urls = new URL[values.length];
                for (int i = 0; i < urls.length; i++) {
                    urls[i] = new File(values[i]).toURL();
                }
                classloader = new URLClassLoader(urls);
            } else if ("source".equals(option.getOpt())) {
                settings.setSourceVersion(option.getValue());
            } else if ("target".equals(option.getOpt())) {
                settings.setTargetVersion(option.getValue());
            } else if ("sourcepath".equals(option.getOpt())) {
                sourcepath = new File(option.getValue());
            } else if ("d".equals(option.getOpt())) {
                targetpath = new File(option.getValue());
            } else if ("Xmaxerrs".equals(option.getOpt())) {
View Full Code Here

        int maxwarns = 10;
        final boolean nowarn = cmd.hasOption("nowarn");


        final JavaCompiler compiler = new JavaCompilerFactory().createCompiler("eclipse");
        final JavaCompilerSettings settings = compiler.createDefaultSettings();


        for (Iterator it = cmd.iterator(); it.hasNext();) {
            final Option option = (Option) it.next();

            if ("classpath".equals(option.getOpt())) {
                final String[] values = option.getValues();
                final URL[] urls = new URL[values.length];
                for (int i = 0; i < urls.length; i++) {
                    urls[i] = new File(values[i]).toURL();
                }
                classloader = new URLClassLoader(urls);
            } else if ("source".equals(option.getOpt())) {
                settings.setSourceVersion(option.getValue());
            } else if ("target".equals(option.getOpt())) {
                settings.setTargetVersion(option.getValue());
            } else if ("sourcepath".equals(option.getOpt())) {
                sourcepath = new File(option.getValue());
            } else if ("d".equals(option.getOpt())) {
                targetpath = new File(option.getValue());
            } else if ("Xmaxerrs".equals(option.getOpt())) {
View Full Code Here

        String[] resources = new String[] {targetResource};

        JavaCompiler javaCompiler = (new JavaCompilerFactory()).createCompiler(options.getCompiler().substring(4));
        FileResourceReader reader = new FileResourceReader(ctxt.getOptions().getScratchDir());
        FileResourceStore store = new FileResourceStore(ctxt.getOptions().getScratchDir());
        JavaCompilerSettings settings = javaCompiler.createDefaultSettings();
        if (settings == null) {
            settings = new JavaCompilerSettings();
        }
        settings.setDeprecations(false);
        if (ctxt.getOptions().getJavaEncoding() != null) {
            settings.setSourceEncoding(ctxt.getOptions().getJavaEncoding());
        }
        if (ctxt.getOptions().getClassDebugInfo()) {
            // No support
        }
        // Source JVM
        if (ctxt.getOptions().getCompilerSourceVM() != null) {
            settings.setSourceVersion(ctxt.getOptions().getCompilerSourceVM());
        } else {
            // Default to 1.5
            settings.setSourceVersion("1.5");
        }
        // Target JVM
        if (ctxt.getOptions().getCompilerTargetVM() != null) {
            settings.setTargetVersion(ctxt.getOptions().getCompilerTargetVM());
        } else {
            // Default to 1.5
            settings.setTargetVersion("1.5");
        }

        CompilationResult result = javaCompiler.compile(resources, reader, store, classLoader, settings);
       
        ArrayList<JavacErrorDetail> problemList = new ArrayList<JavacErrorDetail>();
View Full Code Here

TOP

Related Classes of org.apache.commons.jci.compilers.JavaCompilerSettings

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.