protected boolean compileJavaSrc(String classPath, List<File> srcList, String dest) { org.apache.cxf.common.util.Compiler javaCompiler = new org.apache.cxf.common.util.Compiler(); javaCompiler.setClassPath(classPath); javaCompiler.setOutputDir(dest); javaCompiler.setTarget("1.6"); return javaCompiler.compileFiles(srcList); }
protected boolean internalJava6Compile(JavaCompiler compiler, JavaFileManager fileManager, DiagnosticListener<JavaFileObject> listener, Iterable<? extends JavaFileObject> fileList) { List<String> args = new ArrayList<>(); addArgs(args); CompilationTask task = compiler.getTask(null, fileManager, listener, args, null, fileList); Boolean ret = task.call(); try { fileManager.close(); } catch (IOException e) { System.err.print("[ERROR] IOException during compiling."); e.printStackTrace(); } return ret; }
private void checkLongClasspath(String classpath, List<String> list, int classpathIdx) { if (isLongClasspath(classpath)) { PrintWriter out = null; try { classpathTmpFile = FileUtils.createTempFile("cxf-compiler-classpath", null); out = new PrintWriter(new FileWriter(classpathTmpFile)); out.println(classpath); out.flush(); out.close(); list.set(classpathIdx + 1, "@" + classpathTmpFile); } catch (IOException e) { System.err.print("[ERROR] can't write long classpath to @argfile"); } } }
protected boolean useJava6Compiler(String[] files) { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fileList = fileManager.getJavaFileObjectsFromStrings(Arrays .asList(files)); return internalJava6Compile(compiler, wrapJavaFileManager(fileManager), setupDiagnosticListener(), fileList); }
public boolean compileFiles(String[] files) { String endorsed = SystemPropertyAction.getProperty("java.endorsed.dirs"); if (!forceFork) { return useJava6Compiler(files); addArgs(list); int classpathIdx = list.indexOf("-classpath"); String classpath = list.get(classpathIdx + 1); checkLongClasspath(classpath, list, classpathIdx); int idx = list.size(); list.addAll(Arrays.asList(files)); return internalCompile(list.toArray(new String[list.size()]), idx);
public void compile(ToolContext context) throws ToolException { Compiler compiler = (Compiler)context.get(ToolConstants.COMPILER); if (compiler == null) { compiler = new Compiler(); compiler.setVerbose(true); compiler.setEncoding((String)context.get(ToolConstants.CFG_ENCODING)); compiler.setOutputDir((String)context.get(ToolConstants.CFG_CLASSDIR)); if (javaClasspath != null) { if (context.get(ToolConstants.CFG_OUTPUTDIR) != null) { compiler.setClassPath(javaClasspath + File.pathSeparatorChar + context.get(ToolConstants.CFG_OUTPUTDIR)); } else { compiler.setClassPath(javaClasspath); if (!compiler.compileFiles(fileList.toArray(new String[0]))) { Message msg = new Message("FAIL_TO_COMPILE_GENERATE_CODES", LOG); throw new ToolException(msg);
public boolean compileFiles(File[] files) { List<String> f = new ArrayList<>(files.length); for (File file : files) { f.add(file.getAbsolutePath()); } return compileFiles(f.toArray(new String[0])); } public boolean compileFiles(List<File> files) {
compiler = new Compiler(); compiler.setOutputDir(compileToDir); List<String> files = new ArrayList<>(generatedFiles.size()); for (File file : generatedFiles) { files.add(file.getAbsolutePath()); compiler.compileFiles(files.toArray(new String[0])); } catch (Exception e) { e.printStackTrace();
File tmpFile = null; try { if (isLongCommandLines(args) && sourceFileIndex >= 0) { PrintWriter out = null; tmpFile = FileUtils.createTempFile("cxf-compiler", null);
try { Class.forName("javax.tools.JavaCompiler"); return useJava6Compiler(files); } catch (Exception ex) { addArgs(list); int classpathIdx = list.indexOf("-classpath"); String classpath = list.get(classpathIdx + 1); checkLongClasspath(classpath, list, classpathIdx); int idx = list.size(); list.addAll(Arrays.asList(files)); return internalCompile(list.toArray(new String[list.size()]), idx);
public void compile(ToolContext context) throws ToolException { Compiler compiler = (Compiler)context.get(ToolConstants.COMPILER); if (compiler == null) { compiler = new Compiler(); compiler.setVerbose(true); compiler.setEncoding((String)context.get(ToolConstants.CFG_ENCODING)); compiler.setOutputDir((String)context.get(ToolConstants.CFG_CLASSDIR)); if (javaClasspath != null) { if (context.get(ToolConstants.CFG_OUTPUTDIR) != null) { compiler.setClassPath(javaClasspath + File.pathSeparatorChar + context.get(ToolConstants.CFG_OUTPUTDIR)); } else { compiler.setClassPath(javaClasspath); if (!compiler.compileFiles(fileList.toArray(new String[0]))) { Message msg = new Message("FAIL_TO_COMPILE_GENERATE_CODES", LOG); throw new ToolException(msg);
public boolean compileFiles(File[] files) { List<String> f = new ArrayList<String>(files.length); for (File file : files) { f.add(file.getAbsolutePath()); } return compileFiles(f.toArray(new String[files.length])); } public boolean compileFiles(List<File> files) {
compiler = new Compiler(); compiler.setOutputDir(compileToDir); List<String> files = new ArrayList<>(generatedFiles.size()); for (File file : generatedFiles) { files.add(file.getAbsolutePath()); compiler.compileFiles(files.toArray(new String[0])); } catch (Exception e) { e.printStackTrace();
protected boolean useJava6Compiler(String[] files) { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) { throw new IllegalStateException( "No compiler detected, make sure you are running on top of a JDK instead of a JRE."); } StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fileList = fileManager.getJavaFileObjectsFromStrings(Arrays .asList(files)); return internalJava6Compile(compiler, wrapJavaFileManager(fileManager), setupDiagnosticListener(), fileList); }
File tmpFile = null; try { if (isLongCommandLines(args) && sourceFileIndex >= 0) { PrintWriter out = null; tmpFile = FileUtils.createTempFile("cxf-compiler", null);
protected boolean compileJavaSrc(String classPath, List<File> srcList, String dest) { org.apache.cxf.common.util.Compiler javaCompiler = new org.apache.cxf.common.util.Compiler(); javaCompiler.setClassPath(classPath); javaCompiler.setOutputDir(dest); javaCompiler.setTarget("1.6"); return javaCompiler.compileFiles(srcList); }
public boolean compileFiles(String[] files) { String endorsed = SystemPropertyAction.getProperty("java.endorsed.dirs"); if (!forceFork) { return useJava6Compiler(files); addArgs(list); int classpathIdx = list.indexOf("-classpath"); String classpath = list.get(classpathIdx + 1); checkLongClasspath(classpath, list, classpathIdx); int idx = list.size(); list.addAll(Arrays.asList(files)); return internalCompile(list.toArray(new String[list.size()]), idx);
public boolean compileFiles(File[] files) { List<String> f = new ArrayList<String>(files.length); for (File file : files) { f.add(file.getAbsolutePath()); } return compileFiles(f.toArray(new String[files.length])); } public boolean compileFiles(List<File> files) {
protected boolean useJava6Compiler(String[] files) { JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); if (compiler == null) { throw new IllegalStateException( "No compiler detected, make sure you are running on top of a JDK instead of a JRE."); } StandardJavaFileManager fileManager = compiler.getStandardFileManager(null, null, null); Iterable<? extends JavaFileObject> fileList = fileManager.getJavaFileObjectsFromStrings(Arrays .asList(files)); return internalJava6Compile(compiler, wrapJavaFileManager(fileManager), setupDiagnosticListener(), fileList); }
protected boolean internalJava6Compile(JavaCompiler compiler, JavaFileManager fileManager, DiagnosticListener<JavaFileObject> listener, Iterable<? extends JavaFileObject> fileList) { List<String> args = new ArrayList<String>(); addArgs(args); CompilationTask task = compiler.getTask(null, fileManager, listener, args, null, fileList); Boolean ret = task.call(); try { fileManager.close(); } catch (IOException e) { System.err.print("[ERROR] IOException during compiling."); e.printStackTrace(); } return ret; }