Author: alexsmirnov
Date: 2009-09-29 20:57:10 -0400 (Tue, 29 Sep 2009)
New Revision: 15689
Removed:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/velocity/
Modified:
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java
root/cdk/trunk/plugins/xinclude/pom.xml
Log:
maven plugin configuration
Modified:
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 2009-09-29
17:27:20 UTC (rev 15688)
+++
root/cdk/trunk/plugins/maven-cdk-plugin/src/main/java/org/richfaces/builder/mojo/GenerateMojo.java 2009-09-30
00:57:10 UTC (rev 15689)
@@ -44,10 +44,12 @@
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.DirectoryScanner;
+import org.richfaces.builder.maven.MavenLogger;
import org.richfaces.cdk.CdkContextBase;
import org.richfaces.cdk.CdkException;
import org.richfaces.cdk.CdkWorker;
import org.richfaces.cdk.LibraryBuilder;
+import org.richfaces.cdk.LoggerFactory;
import org.richfaces.cdk.ModelValidator;
import org.richfaces.cdk.NamingConventions;
import org.richfaces.cdk.RichFacesConventions;
@@ -64,6 +66,7 @@
* @author asmirnov(a)exadel.com
*
* @goal generate
+ * @phase generate-sources
*/
public class GenerateMojo extends AbstractMojo {
@@ -86,21 +89,31 @@
protected MavenProject project;
/**
+ * List of filename patterns that will be included to process by annotations processor.
+ * By default, all *.java files will be processed.
* @parameter
*/
protected String[] sourceIncludes;
/**
+ * List of filename patterns that will be excluded from process by annotations
processor.
+ * By default, all *.java files will be processed.
* @parameter
*/
protected String[] sourceExcludes;
/**
+ * The list of JSF configuration files that will be processed by CDK.
+ * By default, CDK looks for all files in the <code>src/main/config</code>
folder
+ * with "xml" extension.
* @parameter
*/
protected FileSet[] facesConfigs;
/**
+ * The list of Renderer template files that will be processed by CDK.
+ * By default, CDK looks for all files in the
<code>src/main/templates</code> folder
+ * with "xml" extension.
* @parameter
*/
protected FileSet[] templates;
@@ -108,20 +121,20 @@
/**
* Directory where the output Java Files will be located.
*
- * @parameter expression="${project.build.directory}/generated-sources/java"
+ * @parameter expression="${project.build.directory}/cdk-generated/main/java"
*/
protected File outputJavaDirectory;
/**
- * @parameter expression="${project.build.directory}/generated-sources/test"
+ * @parameter expression="${project.build.directory}/cdk-generated/test/java"
*/
- protected File outputTestsDirectory;
+ protected File outputTestDirectory;
/**
* Directory where the output Java Files will be located.
*
* @parameter
- *
expression="${project.build.directory}/generated-sources/resources"
+ *
expression="${project.build.directory}/cdk-generated/main/resources"
*/
protected File outputResourcesDirectory;
@@ -129,7 +142,7 @@
* Directory where the output Java Files will be located.
*
* @parameter
- *
expression="${project.build.directory}/generated-sources/testresources"
+ *
expression="${project.build.directory}/cdk-generated/test/resources"
*/
protected File outputTestResourcesDirectory;
/**
@@ -147,7 +160,7 @@
* @required
* @readonly
*/
- protected List classpathElements;
+ protected List<String> classpathElements;
/**
* The directory for compiled classes.
*
@@ -169,9 +182,11 @@
*/
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
- // TODO set logging.
+ // Setup logger.
+ LoggerFactory.setLogger(new MavenLogger(getLog()));
CdkContextBase context = new CdkContextBase(this
.createProjectClassLoader(project));
+ // Set source folders.
ArrayList<File> folders = new ArrayList<File>(compileSourceRoots.size());
for (String sourceFolder : compileSourceRoots) {
File folder = new File(sourceFolder);
@@ -180,28 +195,18 @@
}
}
context.setSourceFolders(StandardSources.JAVA_SOURCES, folders);
- if (!outputJavaDirectory.exists()) {
- outputJavaDirectory.mkdirs();
- }
- context.setOutputFolder(StandardOutputFolders.JAVA_CLASSES,
- outputJavaDirectory);
- if (!outputResourcesDirectory.exists()) {
- outputResourcesDirectory.mkdirs();
- }
- context.setOutputFolder(StandardOutputFolders.RESOURCES,
- outputResourcesDirectory);
-
- if (!outputTestsDirectory.exists()) {
- outputTestsDirectory.mkdirs();
- }
- context.setOutputFolder(StandardOutputFolders.TEST_JAVA_CLASSES,
- outputTestsDirectory);
- if (!outputTestResourcesDirectory.exists()) {
- outputTestResourcesDirectory.mkdirs();
- }
- context.setOutputFolder(StandardOutputFolders.TEST_RESOURCES,
- outputTestResourcesDirectory);
- // TODO - configure.
+ // Non-java sources.
+ context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
+ context.addSources(StandardSources.RENDERER_TEMPLATES,
+ findTemplateFiles());
+ context.addSources(StandardSources.FACES_CONFIGS,
+ findFacesConfigFiles());
+ // Setup output folders.
+ setOutput(context, outputJavaDirectory, StandardOutputFolders.JAVA_CLASSES);
+ setOutput(context, outputResourcesDirectory, StandardOutputFolders.RESOURCES);
+ setOutput(context, outputTestDirectory, StandardOutputFolders.TEST_JAVA_CLASSES);
+ setOutput(context, outputTestResourcesDirectory,
StandardOutputFolders.TEST_RESOURCES);
+ // configure CDK workers.
boolean namingConventionsConfigured = false;
boolean validatorConfigured = false;
if (null != workers) {
@@ -237,6 +242,7 @@
}
}
+ // Set default naming conventions if it was not configured.
if (namingConventionsConfigured) {
RichFacesConventions facesConventions = new RichFacesConventions();
try {
@@ -247,6 +253,7 @@
}
context.addWorker(NamingConventions.class, facesConventions);
}
+ // Set default model validator if it was not configured.
if (validatorConfigured) {
ValidatorImpl validatorImpl = new ValidatorImpl();
try {
@@ -257,21 +264,18 @@
}
context.addWorker(ModelValidator.class, validatorImpl);
}
- context.addSources(StandardSources.JAVA_SOURCES, findJavaFiles());
- context.addSources(StandardSources.RENDERER_TEMPLATES,
- findTemplateFiles());
- context.addSources(StandardSources.FACES_CONFIGS,
- findFacesConfigFiles());
try {
+ // Build JSF library.
LibraryBuilder builder = LibraryBuilder.createInstance(context);
ComponentLibrary model = builder.buildModel();
builder.generate(model);
+ // Tell project about generated files.
project.addCompileSourceRoot(outputJavaDirectory.getAbsolutePath());
Resource resource = new Resource();
resource.setDirectory(outputResourcesDirectory.getAbsolutePath());
project.addResource(resource);
- project.addTestCompileSourceRoot(outputTestsDirectory
+ project.addTestCompileSourceRoot(outputTestDirectory
.getAbsolutePath());
Resource testResource = new Resource();
testResource.setDirectory(outputTestResourcesDirectory
@@ -282,6 +286,25 @@
}
}
+ /**
+ * <p class="changed_added_4_0">This utility method sets output
directory for particular type.
+ * I such directory does not exist, it is created.</p>
+ * @param context
+ * @param directory
+ * @param type
+ */
+ private static void setOutput(CdkContextBase context, File directory,
+ StandardOutputFolders type) {
+ if (!directory.exists()) {
+ directory.mkdirs();
+ }
+ context.setOutputFolder(type,
+ directory);
+ }
+
+ /**
+ * <p class="changed_added_4_0">This method checks library configuration
and sets default values if necessary.</p>
+ */
protected void checkLibraryConfig() {
// TODO Auto-generated method stub
@@ -331,22 +354,18 @@
protected ClassLoader createProjectClassLoader(MavenProject project) {
ClassLoader classLoader = null;
try {
- List<?> compileClasspathElements = project
- .getCompileClasspathElements();
String outputDirectory = project.getBuild().getOutputDirectory();
- URL[] urls = new URL[compileClasspathElements.size() + 1];
+ URL[] urls = new URL[classpathElements.size() + 1];
int i = 0;
urls[i++] = new File(outputDirectory).toURI().toURL();
- for (Iterator<?> iter = compileClasspathElements.iterator(); iter
+ for (Iterator<String> iter = classpathElements.iterator(); iter
.hasNext();) {
- String element = (String) iter.next();
+ String element = iter.next();
urls[i++] = new File(element).toURI().toURL();
}
classLoader = new URLClassLoader(urls);
} catch (MalformedURLException e) {
getLog().error("Bad URL in classpath", e);
- } catch (DependencyResolutionRequiredException e) {
- getLog().error("Dependencies not resolved ", e);
}
return classLoader;
Modified: root/cdk/trunk/plugins/xinclude/pom.xml
===================================================================
--- root/cdk/trunk/plugins/xinclude/pom.xml 2009-09-29 17:27:20 UTC (rev 15688)
+++ root/cdk/trunk/plugins/xinclude/pom.xml 2009-09-30 00:57:10 UTC (rev 15689)
@@ -46,12 +46,12 @@
</dependency>
<!-- Other dependencies -->
- <dependency>
+ <!-- dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.14</version>
<scope>runtime</scope>
- </dependency>
+ </dependency -->
<!-- Test dependencies -->
<dependency>