Author: alexsmirnov
Date: 2009-08-17 20:57:04 -0400 (Mon, 17 Aug 2009)
New Revision: 15188
Added:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java
Log:
New build mojo created
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-08-17
23:31:33 UTC (rev 15187)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/AbstractCDKMojo.java 2009-08-18
00:57:04 UTC (rev 15188)
@@ -36,6 +36,7 @@
import org.apache.maven.artifact.Artifact;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.plugin.AbstractMojo;
+import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.project.MavenProject;
import org.apache.velocity.Template;
import org.apache.velocity.VelocityContext;
@@ -43,6 +44,7 @@
import org.apache.velocity.exception.MethodInvocationException;
import org.apache.velocity.exception.ParseErrorException;
import org.apache.velocity.exception.ResourceNotFoundException;
+import org.codehaus.plexus.util.DirectoryScanner;
import org.codehaus.plexus.velocity.VelocityComponent;
/**
@@ -141,7 +143,7 @@
* @required
* @readonly
*/
- protected List compileSourceRoots;
+ protected List<File> compileSourceRoots;
/**
* Project classpath.
*
@@ -358,4 +360,23 @@
getLog().debug("Taglib version is " + taglib.getTlibVersion());
}
+ protected String[] doScan(String[] includes, String[] excludes, File rootFolder)
+ throws MojoExecutionException {
+ try {
+ DirectoryScanner directoryScanner = new DirectoryScanner();
+ directoryScanner.setFollowSymlinks(true);
+ directoryScanner.setBasedir(rootFolder);
+ directoryScanner.setExcludes(excludes);
+ directoryScanner.setIncludes(includes);
+ directoryScanner.addDefaultExcludes();
+
+ directoryScanner.scan();
+
+ return directoryScanner.getIncludedFiles();
+ } catch (IllegalStateException e) {
+ throw new MojoExecutionException(
+ "Error scanning source root: \'" + rootFolder +
"\'", e );
+ }
+ }
+
}
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java 2009-08-17
23:31:33 UTC (rev 15187)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/BuildLibraryMojo.java 2009-08-18
00:57:04 UTC (rev 15188)
@@ -29,7 +29,6 @@
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.DirectoryScanner;
import org.richfaces.builder.model.JavaClass;
import org.richfaces.builder.render.JavaClassRenderer;
import org.richfaces.builder.templates.TemplateReader;
@@ -79,25 +78,6 @@
this.templatesFileExcludes = templatesFileExcludes;
}
- private String[] doScan(String[] includes, String[] excludes, File rootFolder)
- throws MojoExecutionException {
- try {
- DirectoryScanner directoryScanner = new DirectoryScanner();
- directoryScanner.setFollowSymlinks(true);
- directoryScanner.setBasedir(rootFolder);
- directoryScanner.setExcludes(excludes);
- directoryScanner.setIncludes(includes);
- directoryScanner.addDefaultExcludes();
-
- directoryScanner.scan();
-
- return directoryScanner.getIncludedFiles();
- } catch (IllegalStateException e) {
- throw new MojoExecutionException(
- "Error scanning source root: \'" + rootFolder +
"\'", e );
- }
- }
-
private Iterable<File> findTemplateFiles() throws MojoExecutionException {
Set<File> sourceFiles = new HashSet<File>();
if (templatesDirectory.exists() && templatesDirectory.isDirectory()) {
Added:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
===================================================================
---
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
(rev 0)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-08-18
00:57:04 UTC (rev 15188)
@@ -0,0 +1,77 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.builder.mojo;
+
+import java.io.File;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.richfaces.cdk.AbstractCdkContext;
+import org.richfaces.cdk.CdkException;
+import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.RichFacesConventions;
+import org.richfaces.cdk.StandardOutputs;
+import org.richfaces.cdk.StandardSources;
+import org.richfaces.cdk.model.ComponentLibrary;
+
+/**
+ * <p class="changed_added_4_0"></p>
+ * @author asmirnov(a)exadel.com
+ *
+ * @goal generate
+ */
+public class GenerateMojo extends AbstractCDKMojo {
+
+ /* (non-Javadoc)
+ * @see org.apache.maven.plugin.Mojo#execute()
+ */
+ @Override
+ public void execute() throws MojoExecutionException, MojoFailureException {
+ // TODO set logging.
+ checkLibraryConfig();
+ AbstractCdkContext context = new
AbstractCdkContext(this.createProjectClassLoader(project));
+ context.setJavaSource((File) compileSourceRoots.get(0));
+ context.setJavaSourceOutput(outputJavaDirectory);
+ context.setResourceOutput(outputResourcesDirectory);
+ context.setNamingConventions(new RichFacesConventions(library.getPrefix()));
+ Set<File> javaSources = new HashSet<File>();
+ for (File compileRoot : compileSourceRoots) {
+ String[] sources = doScan(new String[]{"**/*.java"}, null, compileRoot);
+ for (String src : sources) {
+ javaSources.add(new File(compileRoot,src));
+ }
+ }
+ context.addSources(StandardSources.JAVA_SOURCES, javaSources);
+ LibraryBuilder builder = LibraryBuilder.createInstance(context);
+ try {
+ ComponentLibrary model = builder.buildModel();
+ builder.generate(model, StandardOutputs.COMPONENT_CLASSES);
+ } catch (CdkException e) {
+ throw new MojoExecutionException("CDK build error", e);
+ }
+ }
+
+}
Property changes on:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Show replies by date