COMP 402: Production Programming← DrJava Build Process →
|Home — Spring 2009|||||Information|||||Resources|||||DrJava|||||SourceForge|||||Blog|
Please create an account on the DrJava Blog. The site is password-protected; for username and password please contact the instructor.
Beginning next week, please post weekly logs recording your work.
Today's topics are described in the DrJava Developer Documentation.
On CSNet, you should edit your
~/.bashrc file and set the following environment variables at the end of the file:
You can edit the file by opening a shell (terminal) and typing
emacs ~/.bashrc .
You should start a new shell to set these variables. Check that the following commands can be found:
You should probably create a directory for all DrJava work, e.g.
~/drjava. Underneath this directory, you should create other directories for your different working copies, e.g.
~/drjava/drjava for your normal copy,
~/drjava/drjava.all for a check-out of the entire trunk,
~/drjava/drjava.4700 for revision 4700, etc.
Check out the latest revision of the main DrJava code using the following command line:
svn co https://drjava.svn.sourceforge.net/svnroot/drjava/trunk/drjava
This tells Subversion (svn) to do a check-out (co) from the specified URL. It creates a directory
drjava with the latest versions of the source files. It may ask you if you want to trust the host; say "permanently".
The most commonly used Subversion commands are:
svn add filename- to add a new file with name
filenameto the repository; just because a file is in your working directory doesn't mean it goes into the repository!
svn log- show a log of the changes; you might want to pipe it into
svn status- show the files that you have changed, etc.
svn revert filename- revert the changes you made, i.e. get the file from the repository back
svn diff filename- show the changes you made in the specified file
svn annotate filename- show who changed which lines last
svn commit- commit your changes to the repository; WARNING: DO NOT DO THIS UNTIL AFTER YOU HAVE RUN THE UNIT TESTS, preferably on several systems.
svn update- to get new revisions from the repository
All of these commands have many options and parameters. For the most comprehensive reference, read the Subversion book. You should do this especially before you use more complicated commands, such as
svn copy or
svn merge to work with branches.
Another useful resource is the SourceForge Subversion HTML interface. It allows you to look at files in your web browser, compare versions, and read the change logs.
After you have checked out the latest revision of the DrJava main source code with the code>svn co command above, change into the
drjava directory that was created and look at the directory contents. Here is a description of the files and directories:
build.xml- this is the Ant build script
COPYRIGHT- DrJava copyright block. Should be at the beginning of all Java files
lib/- this directory contains libraries we use
LICENSE- the license text file
packaging/- this directory contains resources to create Windows and MacOS executables
README- README file for DrJava; don't expect too much
relicense- script to update the COPYRIGHT blocks in Java files; watch out, may not work
src/- this directory contains all the source code
strip-license- remove the COPYRIGHT blocks from Java files; watch out, may not work
testFiles/- data files used by our unit tests
ant -p and
ant options to get some help for how to use Ant.
ant -p lists all the available targets. The most important targets are:
ant compile- to compile the source code
ant jar- to create a jar file that you can run
ant clean- to clean up any files from the build process
ant test- to run the unit tests
ant build- to compile, create a jar and run the unit tests
ant commit- to do a build and an
svn commitonly if the tests pass
You should be able to do an
ant jar to create a
drjava.jar file that you can then run using
java -jar drjava.jar . You should also be able to run the unit tests using
ant test . Please try these commands to make sure your account is set up correctly.
You will probably not have to edit the
build.xml file or know much about Ant internals, but if you want to learn more, please reference the Ant User Manual.
You should keep a current copy of the drjava.jar file somewhere convenient, e.g. on your desktop (i.e. ~/Desktop/drjava.jar on CSnet). Run this copy when you work on DrJava (unless it is too buggy, then use a stable or beta version), e.g. by starting it from the command line using:
java -jar ~/Desktop/drjava.jar &
& tells the shell not to wait until DrJava has finished executing. Instead, you can use the terminal window in parallel.
Check the DrJava code out into a working directory as described above, e.g. into ~/drjava/drjava, then start the drjava.jar file and create a new project for DrJava. The source code you checked out from the Subversion repository does not include a DrJava project file, since the user systems differ too much. You have to create this project yourself. Do not check it into the repository.
We always edit in DrJava, but compile outside DrJava using
ant compile from the command line.
As an exercise, do the following:
ant compile. Study the error output.
svn statusand an
svn difffrom the command line. You should see the change you made. Then use
svn revertto undo the change by overwriting it with the file from the repository.
ant test. There should not be any failures.
StringOpsTest.javaand change the code in
testReplace()so that the test fails. Then run
ant testagain and study the error output.
Copyright © 2008-2010 Mathias Ricken