use of org.apache.commons.io.FilenameUtils in project knime-core by knime.
the class JavaSnippetCompiler method getTask.
/**
* Creates a compilation task.
*
* @param out a Writer for additional output from the compiler;
* use System.err if null
* @param digsCollector a diagnostic listener; if null use the compiler's
* default method for reporting diagnostics
* @return an object representing the compilation process
* @throws IOException if temporary jar files cannot be created
*/
public CompilationTask getTask(final Writer out, final DiagnosticCollector<JavaFileObject> digsCollector) throws IOException {
if (m_compiler == null) {
m_compileArgs = new ArrayList<>();
final File[] classpaths = m_snippet.getCompiletimeClassPath();
m_compileArgs.add("-classpath");
m_compileArgs.add(Arrays.stream(classpaths).map(f -> f.getAbsolutePath()).map(FilenameUtils::normalize).collect(Collectors.joining(File.pathSeparator)));
m_compileArgs.add("-source");
m_compileArgs.add("1.8");
m_compileArgs.add("-target");
m_compileArgs.add("1.8");
m_compileArgs.add("-encoding");
m_compileArgs.add("UTF-8");
m_compiler = new EclipseCompiler();
}
final StandardJavaFileManager stdFileMgr = m_compiler.getStandardFileManager(digsCollector, null, Charset.forName("UTF-8"));
final CompilationTask compileTask = m_compiler.getTask(out, stdFileMgr, digsCollector, m_compileArgs, null, m_snippet.getCompilationUnits());
// Release all .jar files that may have been opened
stdFileMgr.close();
return compileTask;
}
Aggregations