Creating a new Java project
|Revision as of 18:49, 6 February 2009
Kdorff (Talk | contribs)
← Previous diff
|Revision as of 17:43, 24 August 2009
Kdorff (Talk | contribs)
Next diff →
|Line 15:||Line 15:|
|$ mkdir project-name||$ mkdir project-name|
|-||$ cd maq-java||+||$ cd project-name|
|$ mkdir src||$ mkdir src|
|$ mkdir test-src||$ mkdir test-src|
Revision as of 17:43, 24 August 2009
This page will help with creating a new Java project using the command line. It assumes you are doing this either on Linux or on Windows using Cygwin. If you are using Cygwin, you need to make sure Cygwin has installed "subversion".
Below, anywhere you see "project-name" you should use the name of your project. The project name should not contain spaces but dashes, letters, numbers, etc are fine.
The standard Java directory layout is (+ indicates a folder, . indicates a file).
+ project-name + src + test-src + lib + config . build.xml
First we will create the directory structure with the following commands
$ mkdir project-name $ cd project-name $ mkdir src $ mkdir test-src $ mkdir lib $ mkdir config
We will then import this project into Subversion
$ svn import . https://pbtech-vc.med.cornell.edu/public/svn/icb/trunk/project-name --message 'project creation'
The above command added the directory structure to Subversion, but the project's directory is not yet a working Subversion project. We next need to check out the project
$ cd .. $ rm -r project-name $ svn co https://pbtech-vc.med.cornell.edu/public/svn/icb/trunk/project-name $ cd project-name
The next step is to include "testsupport" into this project, which is an ICB standard way to enable unit tests, etc. for your project.
$ echo "testsupport https://pbtech-vc.med.cornell.edu/public/svn/icb/testsupport" > externals.txt $ svn propset svn:externals . -F externals.txt $ svn update $ rm externals.txt $ svn commit -m 'added testsupport'
To build ICB Java projects we use Ant. Ant build files are generally named build.xml. To obtain a template Ant build file
$ cp testsupport/build.xml_PROJECT-SAMPLE-BUILD-FILE build.xml
You will then want to edit the build.xml file to suit your projects needs. Review the comment toward the top of the build.xml file.
Finally, we want to add your projects Ant build file to subversion.
$ svn add build.xml $ svn commit -m 'added project build file'
From here, the next steps are up to you. You can add Java library ".jar" files to the "lib" directory and Java source ".java" files to the src and test-src directories.
Next, you will probably want to import the project into IntelliJ IDEA. To do this, within IDEA go to File | New Project. Select to Create Java project from existing sources and then give the project a name. The Project file location should be the same as the directory you created as the first step above. Once you have imported the project into IDEA, you will want to add your project's ".iml" and ".ipr" project files to Subversion.
The final step is to add the project to CruiseControl. See Adding a Project to Cruise Control