Search in sources :

Example 1 with Exmlc

use of net.jangaroo.exml.compiler.Exmlc in project jangaroo-tools by CoreMedia.

the class AbstractExmlTest method setUp.

protected void setUp(String configClassPackage, String sourcePathFileName, String classPathFileName) throws Exception {
    File sourcePathFile = new File(getClass().getResource(sourcePathFileName).toURI());
    File classPathFile = new File(getClass().getResource(classPathFileName).toURI());
    ExmlConfiguration config = new ExmlConfiguration();
    config.setSourcePath(Arrays.asList(sourcePathFile));
    config.setClassPath(Arrays.asList(classPathFile));
    config.setOutputDirectory(outputFolder.getRoot());
    config.setConfigClassPackage(configClassPackage);
    exmlc = new Exmlc(config);
}
Also used : Exmlc(net.jangaroo.exml.compiler.Exmlc) ExmlConfiguration(net.jangaroo.exml.config.ExmlConfiguration) File(java.io.File)

Example 2 with Exmlc

use of net.jangaroo.exml.compiler.Exmlc in project jangaroo-tools by CoreMedia.

the class AbstractExmlCompileMojo method execute.

public void execute() throws MojoExecutionException, MojoFailureException {
    File gSourcesDirectory = getGeneratedSourcesDirectory();
    if (!gSourcesDirectory.exists()) {
        getLog().info("generating sources into: " + gSourcesDirectory.getPath());
        getLog().debug("created " + gSourcesDirectory.mkdirs());
    }
    if (!generatedResourcesDirectory.exists()) {
        getLog().info("generating resources into: " + generatedResourcesDirectory.getPath());
        getLog().debug("created " + generatedResourcesDirectory.mkdirs());
    }
    List<File> sourcePath = getSourcePath();
    ExmlConfiguration exmlConfiguration = createExmlConfiguration(getActionScriptClassPath(), sourcePath, gSourcesDirectory);
    exmlConfiguration.setResourceOutputDirectory(generatedResourcesDirectory);
    exmlConfiguration.setSourceFiles(getMavenPluginHelper().computeStaleSources(sourcePath, includes, excludes, gSourcesDirectory, Exmlc.EXML_SUFFIX, Jooc.AS_SUFFIX, staleMillis));
    if (StringUtils.isNotEmpty(validationMode)) {
        try {
            exmlConfiguration.setValidationMode(ValidationMode.valueOf(validationMode.toUpperCase()));
        } catch (IllegalArgumentException e) {
            throw new MojoFailureException("The specified EXML validation mode '" + validationMode + "' is unsupported. " + "Legal values are 'error', 'warn', and 'off'.");
        }
    }
    CompileLog compileLog = new MavenCompileLog();
    exmlConfiguration.setLog(compileLog);
    Exmlc exmlc;
    try {
        getLog().debug("Exmlc configuration: " + exmlConfiguration);
        exmlc = new Exmlc(exmlConfiguration);
        executeExmlc(exmlc);
    } catch (ExmlcException e) {
        throw new MojoFailureException(e.toString(), e);
    }
    if (compileLog.hasErrors()) {
        throw new MojoFailureException("There were EXML compiler errors, see log for details.");
    }
    getProject().addCompileSourceRoot(gSourcesDirectory.getPath());
}
Also used : Exmlc(net.jangaroo.exml.compiler.Exmlc) ExmlcException(net.jangaroo.exml.api.ExmlcException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) ExmlConfiguration(net.jangaroo.exml.config.ExmlConfiguration) File(java.io.File) CompileLog(net.jangaroo.jooc.api.CompileLog)

Example 3 with Exmlc

use of net.jangaroo.exml.compiler.Exmlc in project jangaroo-tools by CoreMedia.

the class ExmlToMxmlMojo method execute.

@Override
public void execute() throws MojoExecutionException {
    if (!renameOnly && hasExmlConfiguration()) {
        getLog().info("removing exml-maven-plugin from POM");
        PomConverter.removeExmlPlugin(getProject().getBasedir());
    }
    if (!renameOnly && "jangaroo".equals(getProject().getPackaging())) {
        getLog().info("changing packaging from jangaroo to jangaroo-pkg");
        PomConverter.changePackaging(getProject().getBasedir());
    }
    if (!isExmlProject()) {
        getLog().info("not an EXML project, skipping MXML conversion");
        return;
    }
    if (renameOnly) {
        getLog().info("Renaming EXML files to MXML files");
        try {
            renameFiles(getSourceDirectory(), "exml", "mxml");
            renameFiles(getTestSourceDirectory(), "exml", "mxml");
        } catch (IOException e) {
            throw new MojoExecutionException("error while renaming EXML files", e);
        }
        return;
    }
    if (alreadyRenamed) {
        getLog().info("Renaming MXML files back to EXML files before running the conversion");
        try {
            renameFiles(getSourceDirectory(), "mxml", "exml");
            renameFiles(getTestSourceDirectory(), "mxml", "exml");
        } catch (IOException e) {
            throw new MojoExecutionException("error while renaming files", e);
        }
    }
    if (extAsJar != null && !extAsJar.exists()) {
        throw new MojoExecutionException("error: extAsJar " + extAsJar.getAbsolutePath() + " does not exist.");
    }
    // Convert main EXML sources to MXML:
    ExmlConfiguration config = createExmlConfiguration(getActionScriptClassPath(), Collections.singletonList(getSourceDirectory()), getGeneratedSourcesDirectory());
    config.setExtAsJar(extAsJar);
    new Exmlc(config).convertAllExmlToMxml();
    // Also convert test EXML sources to MXML:
    if (getTestSourceDirectory() != null && getTestSourceDirectory().exists()) {
        ExmlConfiguration testConfig = createExmlConfiguration(getActionScriptTestClassPath(), Collections.singletonList(getTestSourceDirectory()), getGeneratedTestSourcesDirectory());
        testConfig.setExtAsJar(extAsJar);
        new Exmlc(testConfig).convertAllExmlToMxml();
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) Exmlc(net.jangaroo.exml.compiler.Exmlc) IOException(java.io.IOException) ExmlConfiguration(net.jangaroo.exml.config.ExmlConfiguration)

Aggregations

Exmlc (net.jangaroo.exml.compiler.Exmlc)3 ExmlConfiguration (net.jangaroo.exml.config.ExmlConfiguration)3 File (java.io.File)2 IOException (java.io.IOException)1 ExmlcException (net.jangaroo.exml.api.ExmlcException)1 CompileLog (net.jangaroo.jooc.api.CompileLog)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1