Search in sources :

Example 1 with GenerateGuiSources

use of com.codename1.build.client.GenerateGuiSources in project CodenameOne by codenameone.

the class GenerateGuiSourcesMojo method executeImpl.

@Override
protected void executeImpl() throws MojoExecutionException, MojoFailureException {
    if (!isCN1ProjectDir()) {
        return;
    }
    if (System.getProperty("generate-gui-sources-done") != null) {
        return;
    }
    System.setProperty("generate-gui-sources-done", "true");
    System.setProperty("javax.xml.bind.context.factory", "com.sun.xml.bind.v2.ContextFactory");
    GenerateGuiSources g = new GenerateGuiSources();
    g.setSrcDir(new File(getCN1ProjectDir(), "src" + File.separator + "main" + File.separator + "java"));
    g.setGuiDir(new File(getCN1ProjectDir(), "src" + File.separator + "main" + File.separator + "guibuilder"));
    g.execute();
    // Generate the RAD templates while we're at it
    File radViews = getRADViewsDirectory();
    getLog().debug("Looking for views in " + radViews);
    if (radViews.isDirectory()) {
        project.addCompileSourceRoot(getRADGeneratedSourcesDirectory().getAbsolutePath());
        Exception res = forEach(radViews, child -> {
            if (!child.getName().endsWith(".xml")) {
                return null;
            }
            File destClassFile = getDestClassForRADView(child);
            getLog().debug("Found view " + child + ".  Checking against " + destClassFile);
            if (!destClassFile.exists() || child.lastModified() > destClassFile.lastModified()) {
                try {
                    generateRADViewClass(child);
                } catch (IOException ex) {
                    return new MojoFailureException("Failed to generate class for RAD fragment XML file " + child, ex);
                }
            }
            return null;
        });
        if (res != null) {
            if (res instanceof MojoExecutionException) {
                throw (MojoFailureException) res;
            } else {
                throw new MojoFailureException("Failed to compile RAD views:" + res.getMessage(), res);
            }
        }
    }
}
Also used : GenerateGuiSources(com.codename1.build.client.GenerateGuiSources) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) IOException(java.io.IOException) File(java.io.File) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

GenerateGuiSources (com.codename1.build.client.GenerateGuiSources)1 File (java.io.File)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1