use of org.openntf.nsfodp.transpiler.XspTranspiler in project org.openntf.nsfodp by OpenNTF.
the class TranspilerApplication method start.
@Override
public Object start(IApplicationContext context) throws Exception {
String notesIni = System.getenv(NSFODPConstants.PROP_NOTESINI);
if (notesIni != null && !notesIni.isEmpty()) {
// $NON-NLS-1$
String execDir = System.getenv("Notes_ExecDirectory");
// $NON-NLS-1$
DominoAPI.get().NotesInitExtended(execDir, "=" + notesIni);
}
NotesThread.sinitThread();
try {
Path xspSourceRoot = toPath(System.getenv(NSFODPConstants.PROP_XSP_SOURCE_ROOT));
Path ccSourceRoot = toPath(System.getenv(NSFODPConstants.PROP_CC_SOURCE_ROOT));
List<Path> updateSites = toPaths(System.getenv(NSFODPConstants.PROP_UPDATESITE));
Path outputDirectory = toPath(System.getenv(NSFODPConstants.PROP_OUTPUTFILE));
IProgressMonitor mon = new PrintStreamProgressMonitor(System.out);
XspTranspiler transpiler = new XspTranspiler(TranspilerActivator.instance.getBundle().getBundleContext(), xspSourceRoot, ccSourceRoot, mon);
if (updateSites != null && !updateSites.isEmpty()) {
updateSites.stream().map(FilesystemUpdateSite::new).forEach(transpiler::addUpdateSite);
}
exec.submit(() -> {
try {
Path javaSourceRoot = transpiler.transpile();
Files.walk(javaSourceRoot, FileVisitOption.FOLLOW_LINKS).forEach(p -> {
Path relativePath = javaSourceRoot.relativize(p);
Path dest = outputDirectory.resolve(relativePath);
try {
if (Files.isDirectory(p)) {
Files.createDirectories(dest);
} else {
Files.copy(p, dest, StandardCopyOption.REPLACE_EXISTING);
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
});
mon.done();
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new RuntimeException(e);
}
}).get();
// $NON-NLS-1$
System.out.println(getClass().getName() + "#end");
exec.shutdownNow();
exec.awaitTermination(30, TimeUnit.SECONDS);
return EXIT_OK;
} finally {
NotesThread.stermThread();
}
}
Aggregations