Maven project
As of the 4.0.0.Final release the RichFaces CDK integrates only with the Maven build tool - the main build system for RichFaces.
Prerequirements
- JDK 1.6. You can compile components to use JRE 1.5, but the CDK itself uses the Java Compiler API which is available in JDK 6 only.
- Maven build tool
- Jboss Maven Repository configuration
CDK Project
The easiest way to create Maven project is with a Maven archetype, but, unfortunately, all Richfaces archetypes are designed to be used inside the project itself, so just create simple java project:
mvn archetype:generate -DarchetypeArtifactId=maven-archetype-quickstart
Enter your own groupId, artifactId, version and Java package name.
As we now have a basic Maven project, let’s customise it for the CDK:
Java Compiler Setings
By default, Maven compiles Java files for JRE 1.4. The CDK uses Java 5 features ( Annotations, Generics ) so change the compiler plugin settings to use the proper source level:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.0.2</version> <configuration> <source>1.6</source> <target>1.6</target> </configuration> </plugin> </plugins> </build>
JEE Library dependency
Any JSF Component project requires at least the jsf-api library, and, most likely the el-api and servlet-api libraries. To avoid adding them one by one, you can use the single jee6 jar. Add these lines to the project pom.xml:
….......
<dependencies> .... <dependency> <groupId>javax</groupId> <artifactId>javaee-web-api</artifactId> <version>6.0</version> <scope>provided</scope> </dependency> .... </dependencies> Keep in mind, that this library doesn’t have any code so it cannot be used to run tests.
RichFaces CDK Dependency
Next add the Richfaces CDK annotations dependency:
<dependencies> .... <dependency> <groupId>org.richfaces.cdk</groupId> <artifactId>annotations</artifactId> <version>4.1.0-SNAPSHOT</version> </dependency> .... </dependencies>
RichFaces CDK Plugin
Until now, our project is just an ordinary Java library. To convert it into JSF component project all that we need to do is add the RichFaces CDK plugin:
<build> <plugins> ….. <plugin> <groupId>org.richfaces.cdk</groupId> <artifactId>maven-cdk-plugin</artifactId> <version>4.1.0-SNAPSHOT</version> <configuration> <!-- project specific settings, see below --> </configuration> <executions> <execution> <id>cdk-generate-sources</id> <phase>generate-sources</phase> <goals> <goal>generate</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
There you go, now we can start component development !
Plugin configuration
As with most Maven plugins, the RichFaces CDK uses conventions for the settings that are appropriate for the most projects. Of course, everything can be customised by configuration options:
Option | Default value | Description |
<facesConfigs> | src/main/config/**/*.xml | List of Maven fileSet’s used to get additional xml configuration files. Format: <fileset> <directory>src/foo</directory> <includes> <include>*.xml</include> …........ </includes> [<excludes> <exclude>bar.xml</exclude> …........ </excludes>] </fileset> |
<templates> | src/main/templates/**/*.xml | Renderer Templates, the format is same as for <facesConfigs> option. |
<sourceIncludes> | **/*.java | List of patterns for source files to be processed by CDK: <sourceIncludes> <include>foo/bar/*.java</include> <sourceIncludes> |
<sourceExcludes> | -- | Patterns for files to be excluded from CDK processing |
Comments