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);
}
}
}
}
Aggregations