use of org.openntf.nsfodp.commons.PrintStreamProgressMonitor 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();
}
}
use of org.openntf.nsfodp.commons.PrintStreamProgressMonitor in project org.openntf.nsfodp by OpenNTF.
the class CompilerApplication 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");
try (NotesAPI api = NotesAPI.get()) {
// $NON-NLS-1$
api.NotesInitExtended(execDir, "=" + notesIni);
}
}
try {
NotesThread.sinitThread();
} catch (Exception e) {
// Known exception message during Notes initialization - error code 0x0102
if (String.valueOf(e.getMessage()).endsWith(" - err 258")) {
// $NON-NLS-1$
throw new Exception("Encountered Notes exception ERR_PROTECTED (0x0102): Cannot write or create file (file or disk is read-only)");
}
throw e;
}
try {
Path odpDirectory = toPath(System.getenv(NSFODPConstants.PROP_ODPDIRECTORY));
List<Path> updateSites = toPaths(System.getenv(NSFODPConstants.PROP_UPDATESITE));
Path outputFile = toPath(System.getenv(NSFODPConstants.PROP_OUTPUTFILE));
IProgressMonitor mon = new PrintStreamProgressMonitor(System.out);
OnDiskProject odp = new OnDiskProject(odpDirectory);
ODPCompiler compiler = new ODPCompiler(ODPCompilerActivator.instance.getBundle().getBundleContext(), odp, mon);
// See if the client requested a specific compiler level
String compilerLevel = System.getenv(NSFODPConstants.PROP_COMPILERLEVEL);
if (StringUtil.isNotEmpty(compilerLevel)) {
compiler.setCompilerLevel(compilerLevel);
}
String appendTimestamp = System.getenv(NSFODPConstants.PROP_APPENDTIMESTAMPTOTITLE);
if ("true".equals(appendTimestamp)) {
// $NON-NLS-1$
compiler.setAppendTimestampToTitle(true);
}
String templateName = System.getenv(NSFODPConstants.PROP_TEMPLATENAME);
if (StringUtil.isNotEmpty(templateName)) {
compiler.setTemplateName(templateName);
String templateVersion = System.getenv(NSFODPConstants.PROP_TEMPLATEVERSION);
if (StringUtil.isNotEmpty(templateVersion)) {
compiler.setTemplateVersion(templateVersion);
}
}
String setXspOptions = System.getenv(NSFODPConstants.PROP_SETPRODUCTIONXSPOPTIONS);
if ("true".equals(setXspOptions)) {
// $NON-NLS-1$
compiler.setSetProductionXspOptions(true);
}
String odsRelease = System.getenv(NSFODPConstants.PROP_ODSRELEASE);
if (StringUtil.isNotEmpty(odsRelease)) {
compiler.setOdsRelease(odsRelease);
}
String compileBasicLs = System.getenv(NSFODPConstants.PROP_COMPILEBASICLS);
if ("true".equals(compileBasicLs)) {
// $NON-NLS-1$
compiler.setCompileBasicElementLotusScript(true);
}
if (updateSites != null && !updateSites.isEmpty()) {
updateSites.stream().map(FilesystemUpdateSite::new).forEach(compiler::addUpdateSite);
}
exec.submit(() -> {
try {
Path nsf = compiler.compile();
Files.move(nsf, outputFile, StandardCopyOption.REPLACE_EXISTING);
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