Search in sources :

Example 1 with Jooc

use of net.jangaroo.jooc.Jooc in project jangaroo-tools by CoreMedia.

the class ConfigClassBuilderTest method buildConfigClass.

private ConfigClass buildConfigClass(String resourceName, String module) throws URISyntaxException {
    File sourceFile = new File(getClass().getResource("/" + module + "/" + resourceName).toURI());
    InputSource inputSource = new FileInputSource(sourceFile, true);
    CompilationUnit compilationUnit = new Jooc().doParse(inputSource, new StdOutCompileLog(), SemicolonInsertionMode.QUIRKS);
    ConfigClassBuilder configClassBuilder = new ConfigClassBuilder(compilationUnit);
    return configClassBuilder.buildConfigClass();
}
Also used : CompilationUnit(net.jangaroo.jooc.ast.CompilationUnit) InputSource(net.jangaroo.jooc.input.InputSource) FileInputSource(net.jangaroo.jooc.input.FileInputSource) FileInputSource(net.jangaroo.jooc.input.FileInputSource) ConfigClassBuilder(net.jangaroo.exml.as.ConfigClassBuilder) Jooc(net.jangaroo.jooc.Jooc) StdOutCompileLog(net.jangaroo.jooc.StdOutCompileLog) File(java.io.File)

Example 2 with Jooc

use of net.jangaroo.jooc.Jooc in project jangaroo-tools by CoreMedia.

the class AbstractCompilerMojo method compile.

private int compile(JoocConfiguration config) throws MojoExecutionException {
    File outputDirectory = config.getOutputDirectory();
    // create output directory if it does not exist
    if (!outputDirectory.exists()) {
        if (!outputDirectory.mkdirs()) {
            throw new MojoExecutionException("Failed to create output directory " + outputDirectory.getAbsolutePath());
        }
    }
    // create api output directory if it does not exist
    File apiOutputDirectory = getApiOutputDirectory();
    if (apiOutputDirectory != null && !apiOutputDirectory.exists()) {
        if (!apiOutputDirectory.mkdirs()) {
            throw new MojoExecutionException("Failed to create api output directory " + apiOutputDirectory.getAbsolutePath());
        }
    }
    final List<File> sources = config.getSourceFiles();
    final Log log = getLog();
    log.info("Compiling " + sources.size() + " joo source file" + (sources.size() == 1 ? "" : "s") + " to " + outputDirectory);
    Jooc jooc = new Jooc(config, new AbstractCompileLog() {

        @Override
        protected void doLogError(String msg) {
            log.error(msg);
        }

        @Override
        public void warning(String msg) {
            log.warn(msg);
        }
    });
    return jooc.run().getResultCode();
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) AbstractCompileLog(net.jangaroo.jooc.AbstractCompileLog) Log(org.apache.maven.plugin.logging.Log) Jooc(net.jangaroo.jooc.Jooc) File(java.io.File) AbstractCompileLog(net.jangaroo.jooc.AbstractCompileLog)

Aggregations

File (java.io.File)2 Jooc (net.jangaroo.jooc.Jooc)2 ConfigClassBuilder (net.jangaroo.exml.as.ConfigClassBuilder)1 AbstractCompileLog (net.jangaroo.jooc.AbstractCompileLog)1 StdOutCompileLog (net.jangaroo.jooc.StdOutCompileLog)1 CompilationUnit (net.jangaroo.jooc.ast.CompilationUnit)1 FileInputSource (net.jangaroo.jooc.input.FileInputSource)1 InputSource (net.jangaroo.jooc.input.InputSource)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 Log (org.apache.maven.plugin.logging.Log)1