| | |
| | | import static de.uhilger.filecms.api.FileMgr.HOME_DIR_PATH;
|
| | | import static de.uhilger.filecms.api.FileMgr.PUB_DIR_NAME;
|
| | | import static de.uhilger.filecms.api.FileMgr.PUB_DIR_PATH;
|
| | | import de.uhilger.filecms.data.CompilerIssue;
|
| | | import de.uhilger.filecms.data.FileRef;
|
| | | import de.uhilger.filecms.web.Initialiser;
|
| | | import de.uhilger.transit.web.RequestKontext;
|
| | |
| | | import javax.tools.JavaFileObject;
|
| | | import javax.tools.StandardJavaFileManager;
|
| | | import javax.tools.ToolProvider;
|
| | | import org.apache.commons.io.FileUtils;
|
| | |
|
| | | /**
|
| | | *
|
| | |
| | | private ServletContext ctx;
|
| | | private HttpServletRequest request;
|
| | |
|
| | | public String compile(String relPath, List fileNames) throws IOException {
|
| | | public List<CompilerIssue> compile(String relPath, List fileNames) throws IOException {
|
| | | //Files[] files1 = ... ; // input for first compilation task
|
| | | //Files[] files2 = ... ; // input for second compilation task
|
| | |
|
| | |
| | |
|
| | | Iterable<? extends JavaFileObject> compilationUnits1 = fileManager.getJavaFileObjectsFromFiles(files);
|
| | |
|
| | | /*
|
| | | final Iterable<String> options =
|
| | | Arrays.asList(new String[]{"-Xlint",
|
| | | /*"-cp", project.getClassPath(),*/
|
| | | "-cp", project.getClassPath(),
|
| | | "-d", targetDir.getAbsolutePath()
|
| | | });
|
| | |
|
| | | compiler.getTask(null, fileManager, diagnostics, options, null, compilationUnits1).call();
|
| | | */
|
| | | compiler.getTask(null, fileManager, diagnostics, null, null, compilationUnits1).call();
|
| | |
|
| | | /*
|
| | | Iterable<? extends JavaFileObject> compilationUnits2
|
| | |
| | | */
|
| | | fileManager.close();
|
| | |
|
| | | StringBuilder msg = new StringBuilder();
|
| | | msg.append("Result of compile to Java bytecode (empty means no error):");
|
| | | for (Diagnostic<? extends JavaFileObject> err : diagnostics.getDiagnostics()) {
|
| | | msg.append('\n');
|
| | | msg.append(err.getKind());
|
| | | msg.append(": ");
|
| | | if (err.getSource() != null) {
|
| | | msg.append(err.getSource().getName());
|
| | | List compileResults = diagnostics.getDiagnostics();
|
| | | List<CompilerIssue> compilerIssues = new ArrayList();
|
| | | Iterator i = compileResults.iterator();
|
| | | while(i.hasNext()) {
|
| | | Object o = i.next();
|
| | | Diagnostic<? extends JavaFileObject> err;
|
| | | if(o instanceof Diagnostic) {
|
| | | err = (Diagnostic) o;
|
| | | CompilerIssue issue = new CompilerIssue();
|
| | | issue.setKind(err.getKind().name());
|
| | | issue.setLineNumber(err.getLineNumber());
|
| | | issue.setMessage(err.getMessage(Locale.GERMANY));
|
| | | issue.setSoureName(err.getSource().getName());
|
| | | compilerIssues.add(issue);
|
| | | }
|
| | | msg.append(':');
|
| | | msg.append(err.getLineNumber());
|
| | | msg.append(": ");
|
| | | msg.append(err.getMessage(Locale.GERMANY));
|
| | | } |
| | | |
| | | return msg.toString();
|
| | | }
|
| | | return compilerIssues;
|
| | | }
|
| | | |
| | | private File getTargetDir(String relPath) {
|
| | | logger.fine(relPath);
|
| | | String targetPath = null;
|