// ----------------------------------------------------------------------
// 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());
}