use of net.jangaroo.jooc.config.JoocConfiguration in project jangaroo-tools by CoreMedia.
the class JoocTest method setup.
@Before
public void setup() throws Exception {
outputFolder = tmpFolder.newFolder("jangaroo-output");
apiOutputFolder = tmpFolder.newFolder("joo-api");
config = new JoocConfiguration();
File sourceDir = getFile("/");
List<File> sourcepath = new ArrayList<File>();
sourcepath.add(sourceDir);
config.setSourcePath(sourcepath);
config.setDebugMode(DebugMode.SOURCE);
config.setOutputDirectory(outputFolder);
//noinspection ResultOfMethodCallIgnored
config.setApiOutputDirectory(apiOutputFolder);
testLog.reset();
jooc = new Jooc(config, testLog);
}
use of net.jangaroo.jooc.config.JoocConfiguration in project jangaroo-tools by CoreMedia.
the class Jooc method run.
public static int run(String[] argv, CompileLog log) {
try {
JoocCommandLineParser commandLineParser = new JoocCommandLineParser();
JoocConfiguration config = commandLineParser.parse(argv);
if (config != null) {
return new Jooc(config, log).run().getResultCode();
}
} catch (CommandLineParseException e) {
// NOSONAR this is a commandline tool
System.out.println(e.getMessage());
return e.getExitCode();
}
return CompilationResult.RESULT_CODE_OK;
}
use of net.jangaroo.jooc.config.JoocConfiguration in project jangaroo-tools by CoreMedia.
the class AbstractCompilerMojo method execute.
/**
* Runs the compile mojo
*
* @throws MojoExecutionException
* @throws MojoFailureException
*/
public void execute() throws MojoExecutionException, MojoFailureException {
final Log log = getLog();
if (getCompileSourceRoots().isEmpty()) {
log.info("No sources to compile");
return;
}
// ----------------------------------------------------------------------
// Create the compiler configuration
// ----------------------------------------------------------------------
JoocConfiguration configuration = new JoocConfiguration();
configuration.setEnableAssertions(enableAssertions);
configuration.setAllowDuplicateLocalVariables(allowDuplicateLocalVariables);
configuration.setVerbose(verbose);
configuration.setExcludeClassByDefault(excludeClassByDefault);
if (StringUtils.isNotEmpty(debuglevel)) {
try {
configuration.setDebugMode(DebugMode.valueOf(debuglevel.toUpperCase()));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("The specified debug level: '" + debuglevel + "' is unsupported. " + "Legal values are 'none', 'lines', and 'source'.");
}
}
if (StringUtils.isNotEmpty(autoSemicolon)) {
try {
configuration.setSemicolonInsertionMode(SemicolonInsertionMode.valueOf(autoSemicolon.toUpperCase()));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("The specified semicolon insertion mode: '" + autoSemicolon + "' is unsupported. " + "Legal values are 'error', 'warn', and 'quirks'.");
}
}
if (StringUtils.isNotEmpty(publicApiViolations)) {
try {
configuration.setPublicApiViolationsMode(PublicApiViolationsMode.valueOf(publicApiViolations.toUpperCase()));
} catch (IllegalArgumentException e) {
throw new IllegalArgumentException("The specified public API violations mode: '" + publicApiViolations + "' is unsupported. " + "Legal values are 'error', 'warn', and 'allow'.");
}
}
HashSet<File> sources = new HashSet<File>();
log.debug("starting source inclusion scanner");
sources.addAll(computeStaleSources(staleMillis));
if (sources.isEmpty()) {
log.info("Nothing to compile - all classes are up to date");
return;
}
configuration.setSourceFiles(new ArrayList<File>(sources));
try {
configuration.setSourcePath(getCompileSourceRoots());
} catch (IOException e) {
throw new MojoFailureException("could not canonicalize source paths: " + getCompileSourceRoots(), e);
}
configuration.setClassPath(getActionScriptClassPath());
configuration.setOutputDirectory(getClassesOutputDirectory());
configuration.setApiOutputDirectory(getApiOutputDirectory());
if (log.isDebugEnabled()) {
log.debug("Source path: " + configuration.getSourcePath().toString().replace(',', '\n'));
log.debug("Class path: " + configuration.getClassPath().toString().replace(',', '\n'));
log.debug("Output directory: " + configuration.getOutputDirectory());
if (configuration.getApiOutputDirectory() != null) {
log.debug("API output directory: " + configuration.getApiOutputDirectory());
}
}
int result = compile(configuration);
boolean compilationError = (result != CompilationResult.RESULT_CODE_OK);
if (!compilationError) {
// for now, always set debug mode to "false" for concatenated file:
configuration.setDebugMode(null);
configuration.setOutputDirectory(getTempClassesOutputDirectory());
configuration.setApiOutputDirectory(null);
result = compile(configuration);
if (result == CompilationResult.RESULT_CODE_OK) {
buildOutputFile(getTempClassesOutputDirectory(), getModuleClassesJsFile());
}
compilationError = (result != CompilationResult.RESULT_CODE_OK);
}
List<CompilerError> messages = Collections.emptyList();
if (compilationError && failOnError) {
log.info("-------------------------------------------------------------");
log.error("COMPILATION ERROR : ");
log.info("-------------------------------------------------------------");
if (messages != null) {
for (CompilerError message : messages) {
log.error(message.toString());
}
log.info(messages.size() + ((messages.size() > 1) ? " errors " : "error"));
log.info("-------------------------------------------------------------");
}
throw new MojoFailureException("Compilation failed");
} else {
for (CompilerError message : messages) {
log.warn(message.toString());
}
}
}
use of net.jangaroo.jooc.config.JoocConfiguration in project jangaroo-tools by CoreMedia.
the class JsCodeGenerator method visitAssignmentOpExpr.
@Override
public void visitAssignmentOpExpr(AssignmentOpExpr assignmentOpExpr) throws IOException {
if (assignmentOpExpr.getOp().sym == sym.ANDANDEQ || assignmentOpExpr.getOp().sym == sym.OROREQ) {
assignmentOpExpr.getArg1().visit(this);
out.writeSymbolWhitespace(assignmentOpExpr.getOp());
out.writeToken("=");
// TODO: refactor for a simpler way to switch off white-space temporarily:
JoocConfiguration options = (JoocConfiguration) out.getOptions();
DebugMode mode = options.getDebugMode();
options.setDebugMode(null);
assignmentOpExpr.getArg1().visit(this);
options.setDebugMode(mode);
out.writeToken(assignmentOpExpr.getOp().sym == sym.ANDANDEQ ? "&&" : "||");
out.writeToken("(");
assignmentOpExpr.getArg2().visit(this);
out.writeToken(")");
} else {
visitBinaryOpExpr(assignmentOpExpr);
}
}
use of net.jangaroo.jooc.config.JoocConfiguration in project jangaroo-tools by CoreMedia.
the class JoocCommandLineParser method parse.
public JoocConfiguration parse(String[] args) throws CommandLineParseException {
JoocConfiguration config = new JoocConfiguration();
CmdLineParser parser = new CmdLineParser(config);
try {
// parse the arguments.
parser.parseArgument(args);
} catch (CmdLineException e) {
StringBuilder msg = extendedUsage(parser, e);
throw new CommandLineParseException(msg.toString(), -1);
}
return parseConfig(parser, config);
}
Aggregations