COMP 402: Production Programming← DrJava Build Process → |
Home — Spring 2012 | | | 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: java
, javac
, ant
, svn
.
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 filename
to 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 log|less
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 backsvn diff filename
- show the changes you made in the specified filesvn annotate filename
- show who changed which lines lastsvn 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 repositoryAll 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 scriptCOPYRIGHT
- DrJava copyright block. Should be at the beginning of all Java fileslib/
- this directory contains libraries we useLICENSE
- the license text filepackaging/
- this directory contains resources to create Windows and MacOS executablesREADME
- README file for DrJava; don't expect too muchrelicense
- script to update the COPYRIGHT blocks in Java files; watch out, may not worksrc/
- this directory contains all the source codestrip-license
- remove the COPYRIGHT blocks from Java files; watch out, may not worktestFiles/
- data files used by our unit testsType in ant
, 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 codeant jar
- to create a jar file that you can runant clean
- to clean up any files from the build processant test
- to run the unit testsant build
- to compile, create a jar and run the unit testsant commit
- to do a build and an svn commit
only if the tests passYou 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 &
The &
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 status
and an svn diff
from the command line. You should see the change you made. Then use svn revert
to undo the change by overwriting it with the file from the repository.ant test
. There should not be any failures.StringOpsTest.java
and change the code in testReplace()
so that the test fails. Then run ant test
again and study the error output.URL: http://www.cs.rice.edu/~javaplt/402/12-spring/lectures/drjava/index.shtml