improved error reporting when JDK home is not defined

This commit is contained in:
Renaud Pawlak 2016-01-06 15:45:44 +01:00
parent 43e58e6b57
commit 4b3fcff2e6

View File

@ -64,11 +64,11 @@ public class JSweetCommandLineLauncher {
printUsage(jsapSpec); printUsage(jsapSpec);
System.exit(-1); System.exit(-1);
} }
if (jsapArgs.getBoolean("help")) { if (jsapArgs.getBoolean("help")) {
printUsage(jsapSpec); printUsage(jsapSpec);
} }
if (jsapArgs.getBoolean("verbose")) { if (jsapArgs.getBoolean("verbose")) {
LogManager.getLogger("org.jsweet").setLevel(Level.ALL); LogManager.getLogger("org.jsweet").setLevel(Level.ALL);
} }
@ -78,25 +78,26 @@ public class JSweetCommandLineLauncher {
String classPath = jsapArgs.getString("classpath"); String classPath = jsapArgs.getString("classpath");
logger.info("classpath: " + classPath); logger.info("classpath: " + classPath);
File tsOutputDir = jsapArgs.getFile("tsout");
tsOutputDir.mkdirs();
logger.info("ts output dir: " + tsOutputDir);
File jsOutputDir = null;
if (jsapArgs.getFile("jsout") != null) {
jsOutputDir = jsapArgs.getFile("jsout");
jsOutputDir.mkdirs();
}
logger.info("js output dir: " + jsOutputDir);
File inputDir = new File(jsapArgs.getString("input"));
logger.info("input dir: " + inputDir);
LinkedList<File> files = new LinkedList<File>();
Util.addFiles(".java", inputDir, files);
ErrorCountTranspilationHandler transpilationHandler = new ErrorCountTranspilationHandler(new ConsoleTranspilationHandler()); ErrorCountTranspilationHandler transpilationHandler = new ErrorCountTranspilationHandler(new ConsoleTranspilationHandler());
try { try {
File tsOutputDir = jsapArgs.getFile("tsout");
tsOutputDir.mkdirs();
logger.info("ts output dir: " + tsOutputDir);
File jsOutputDir = null;
if (jsapArgs.getFile("jsout") != null) {
jsOutputDir = jsapArgs.getFile("jsout");
jsOutputDir.mkdirs();
}
logger.info("js output dir: " + jsOutputDir);
File inputDir = new File(jsapArgs.getString("input"));
logger.info("input dir: " + inputDir);
LinkedList<File> files = new LinkedList<File>();
Util.addFiles(".java", inputDir, files);
JSweetTranspiler transpiler = new JSweetTranspiler(tsOutputDir, jsOutputDir, classPath); JSweetTranspiler transpiler = new JSweetTranspiler(tsOutputDir, jsOutputDir, classPath);
transpiler.setBundle(jsapArgs.getBoolean("bundle")); transpiler.setBundle(jsapArgs.getBoolean("bundle"));
@ -256,11 +257,10 @@ public class JSweetCommandLineLauncher {
// Ignore assertions // Ignore assertions
switchArg = new Switch("ignoreAssertions"); switchArg = new Switch("ignoreAssertions");
switchArg.setLongFlag("ignoreAssertions"); switchArg.setLongFlag("ignoreAssertions");
switchArg.setHelp( switchArg.setHelp("Set the transpiler to ignore 'assert' statements, i.e. no code is generated for assertions.");
"Set the transpiler to ignore 'assert' statements, i.e. no code is generated for assertions.");
switchArg.setDefault("false"); switchArg.setDefault("false");
jsap.registerParameter(switchArg); jsap.registerParameter(switchArg);
return jsap; return jsap;
} }