setup CDK Guide

# Setting up the environment

In order to start working with the Component Development Kit (CDK) and to create your rich component, it's necessary to have the following installed:

- The Java SE 5 Development Kit (JDK)

- Apache Maven 2.0.9

- Apache Tomcat 6.0

- Browser (on the client side)

After the Maven is installed you should configure it. In this case, please, go to the directory where you've just installed Maven, open a conf/settings.xml file for editing and add to the profiles section this code:

    ...
    <profile>
        <id>cdk</id>
        <repositories>
            <repository>
                <id>maven2-repository.dev.java.net</id>
                <name>Java.net Repository for Maven</name>
                <url>http://download.java.net/maven/1</url>
                <layout>legacy</layout>
            </repository>
            <repository>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                    <updatePolicy>never</updatePolicy>
                </snapshots>
                <id>repository.jboss.com</id>
                <name>Jboss Repository for Maven</name>
                <url>http://repository.jboss.com/maven2/</url>
                <layout>default</layout>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>maven.jboss.org</id>
                <name>JBoss Repository for Maven Snapshots</name>
                <url>http://snapshots.jboss.org/maven2/</url>
                <releases>
                    <enabled>false</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                    <updatePolicy>always</updatePolicy>
                </snapshots>
            </pluginRepository>
            <pluginRepository>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                    <updatePolicy>never</updatePolicy>
                </snapshots>
                <id>repository.jboss.com</id>
                <name>Jboss Repository for Maven</name>
                <url>http://repository.jboss.com/maven2/ </url>
                <layout>default</layout>
            </pluginRepository>
        </pluginRepositories>
    </profile>
    ...

In order to activate a new profile, add the following after the profiles section:

    ...
    <activeProfiles>
        <activeProfile>cdk</activeProfile>
    </activeProfiles>
    ...

Note:

In order to work with Maven from Eclipse, it's possible to download and install the Maven plugin. Please, follow the instruction at Eclipse plugins for Maven page

The environment is set up now to use the Component Development Kit (CDK).

We are going to create two components throughout the RichFaces CDK Developer Guide, but at first you need take the following steps to set up the Project and create your library:

- Create a new directory where all the components will be stored (for example Sandbox).

- Create a file named pom.xml in the directory with the following content:

      <?xml version="1.0" encoding="UTF-8"?>
      <project    xmlns="http://maven.apache.org/POM/4.0.0"
                  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

          <modelVersion>4.0.0</modelVersion>
          <groupId>org.mycompany</groupId>
          <artifactId>sandbox</artifactId>
          <url>http://mycompany.org</url>
          <version>1.0-SNAPSHOT</version>
          <packaging>pom</packaging>
          <dependencies>
              <dependency>
                  <groupId>javax.servlet</groupId>
                  <artifactId>servlet-api</artifactId>
                  <version>2.4</version>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>javax.servlet</groupId>
                  <artifactId>jsp-api</artifactId>
                  <version>2.0</version>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>javax.servlet.jsp</groupId>
                  <artifactId>jsp-api</artifactId>
                  <version>2.1</version>
                  <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>javax.faces</groupId>
                  <artifactId>jsf-api</artifactId>
                  <version>1.2_12</version>
              </dependency>
              <dependency>
                  <groupId>javax.faces</groupId>
                   <artifactId>jsf-impl</artifactId>
                   <version>1.2_12</version>
               </dependency>
              <dependency>
                  <groupId>javax.el</groupId>
                  <artifactId>el-api</artifactId>
                  <version>1.0</version>
      	    <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>el-impl</groupId>
                  <artifactId>el-impl</artifactId>
                  <version>1.0</version>
      	    <scope>provided</scope>
              </dependency>
              <dependency>
                  <groupId>javax.annotation</groupId>
                  <artifactId>jsr250-api</artifactId>
                  <version>1.0</version>
              </dependency>
                  <dependency>
                  <groupId>org.richfaces.ui</groupId>
                  <artifactId>richfaces-ui</artifactId>
                  <version>3.3.1.GA</version>
              </dependency>
          </dependencies>
      </project>

- Close the file

Here are some of these elements with descriptions:

The POM elements

Element | Description
--- | ---
groupId | Prefix for the Java package structure of your library
url | Namespace for your library to be used in the TLD file
version | Version of your library
scope | Dependency scope is used to limit the transitivity of a depedency, and also to affect the classpath used for various build tasks. "Provided" scope indicates you expect the JDK or a container to provide the dependency at runtime. For example, when you build a web application with RichFaces, you would set the dependency on the Servlet API and related libraries to scope "provided" because the web container provides those classes.