The latest version of the CDK source code is available from GitHub project page, github.com/cdk/cdk. The project page has option to clone or download the source code from the browser. The
git command line tool can also be used to clone the source code into a local repository.
git clone https://github.com/cdk/cdk.git
The project can be built on the command line using the maven command line tool,
mvn. You can download the latest version from http://maven.apache.org/download.cgi.
Locate the directory with the project
pom.xml that you which to compile or install. The top level
pom.xml will build the whole project. The
mvn install goal will install the
.jar file for each module in your local repository,
~/.m2/repository/. By default, maven will run all the tests when installing an artefact and stop the build if a failure is found. For now we can disable this by enabling the
cd ~/workspace/cdk mvn install -DskipTests=true
Alternatively we can build a single module by moving to its
pom.xml location. In this example we run the tests for the fingerprint module.
cd ~/workspace/cdk/descriptor/fingerprint mvn test
Building the JavaDoc requires the cdk/cdk-build-util dependency is installed or available from a repository. Currently this must be installed locally. At the root pom of the project the goal
javadoc:aggregate will create the API documentation in the
cd ~/workspace/cdk mvn javadoc:aggregate ls target/site/apidocs
Although it is feasible to make changes using a plain text editor many Java developers prefer to use an Integrated Development Environment (IDE). These desktop applications simplify interactions with large projects and provide utilities to help with code organisation and assist in modifications. There are several IDEs available each of which has advantages and disadvantages.
This section details how to open, build and test the CDK with several popular IDEs. If you are familiar with an IDE already the opening and import of a project should be relatively straight forward.
Maven support in Eclipse is unfortunately complicated. It was previously provided by a separate plugin - http://eclipse.org/m2e/ that is now installed by default. You can check if the plugin is in installed in the Market Place.
The CDK can be imported with 'File > Import > Existing Maven Project'
Browse the location of the CDK project in the dialog.
Make sure to let the import finish (i.e. don't run in background). The project should build automatically but if not select 'Build All' from the menu bar. Once the project has finished there should be no errors.
To test if the build worked correctly try selecting a test class and running a JUnit test.
Netbeans is an open source IDE, written in Java and maintained by Oracle. The latest version can be downloaded from - http://netbeans.org. This tutorial uses Netbeans version 7.4 and may be incorrect for later versions.
Netbeans has first class support for Maven projects. Select the menu item,
File > Open Project.
This will open a file chooser from which you may select the project location. Maven projects than can be opened will have the 'Ma' icon. Select the location of the CDK project and open it.
The project will appear in the navigator.
To build the project,
right click to open a popup menu and then select
An output console will open an after a short time the build finish. If the build was unsuccessful please see Trouble Shooting.
We will now run some tests on the fingerprint module. To do this, we must first open the module as a project. Expand the modules branch in the project tree, the cdk-fingerprint module is located under the descriptors aggregate module. Expand the descriptors branch and open the fingerprint module.
cdk-fingerprint module will now appear as a root project in the navigator. The source files can be opened by expanding the
Source Packages and
We can run the tests for this module by right clicking the
cdk-fingerprint module and selecting
After a short time, the tests will complete and the results will be displayed.
We can explore what other libraries the module depends on by expanding the
Dependancies branch. Intermodule dependancies are displayed with an
Ma icon whilst external libraries have a Jar icon. The intermodule dependancies are
upstream of this project and, when built as a whole, be compiled first.
Changes to upstream modules are only compiled if we select
Build with dependancies (opposed to
Build) or we have already rebuilt those modules.
Netbeans PermGenSize in Maven Opts Disable tests
IntelliJ IDEA is an IDE developed and maintained by JetBrains - http://www.jetbrains.com/idea/. A commercial version (free to open source projects) and a free and open source community edition are available. You can download the application from - http://www.jetbrains.com/idea/download/.
This tutorial is using the IntelliJ IDEA Community Edition 13.
Once IntelliJ has open - select
Import Project from the Quick Start dialog.
Navigate to and select the location of the CDK project on the file system.
Import the project from a Maven module.
After several dialogs, where the default options should suffice, you will be asked to name the project and finish the import. Check the name and location is acceptable and import the project. Leaving the location the same as the local git repository is desirable.
The project modules will be imported and visible in the navigator.
We can build the project either with maven goals or by using the IDE. First we shall use the maven goals as this offers precise control over what is executed. Open the
Maven Projects view, you may notice there are many modules shown. Select the cog icon on the top right and enable the
Group Modules item.
Lifecycle branch and chose the
The output will be displayed on a console.
We can run the tests of the
cdk-fingerprint module by navigating to it's lifecycle and choosing the
The test output will show text output from maven.
We can also run the tests from the project navigator. Locate the fingerprint module and right click to open a popup menu.
Run 'All Tests' to run the tests for the fingerprint module. Unfortunately as the CDK shares test dependencies, upstream tests will also be run.
The test summary is more accessible than the maven goal but also includes upstream tests. Individual test classes and methods can be run to alleviate this problem.
Please report any problems encountered to the cdk-user mailing list.