CSci 435/535: Software Engineering
Homework 2: Implementation Tools #1
Due Wednesday, Jan 31st by
11am
Summary
This is an introduction to Subversion and Eclipse. General instructions for
accessing our repository are on the project webpage.
You will need to consult the Subversion book on the exact syntax of the
various svn commands.
Assignment
You must do the following steps by 9am Tuesday.
Check out the "Homework 2" project from the repository.
- Start Eclipse, verify your version of Subclipse, and set the Subversion
interface to the Java-only interface as described on the tools website.
- Visit the project webpage, and add the course
Subversion repository as per the instructions.
- Open up the "Homework 2" subproject, and check it out as an Eclipse
project.
- Switch to the Java perspective, and you should see the project. You
may have to refresh the project to see the newly checked out files.
- Run the project as a Java application, using Run → Run As → Java Application. (Once you have done this once,
selecting Run in the future will always use the Java application
configuration.)
Between 9am and 10am on Tuesday, I will make a change to the files so
that the assignment will work right for the first person to do the remainder
of the assignment.
You must do the following steps after 10am
Tuesday.
- In Eclipse, make a change to src/HelloWorld.java at the location marked
"edit #1", as described in the comments.
- Next edit the file again in the location labeled "edit #2", in the manner
described in the comments.
- Run the program to make sure it works correctly. Do not commit broken code.
- Try to commit your changes to the project by selecting by right-clicking
the project and then selecting Team → Commit from the
right-click menu. Enter a message saying what you changed for the commit
comment. Notice how the bin directory is not versioned. We don't want to fill
out our repository with .class files that can be regenerated.
- You should encounter a checkin conflict. (It will complain that your
version is out of date.)
- Compare your version to the latest version in the repository. (Right
click the file, then Compare With → Base Revision.)
- Update the project in order to merge the changes into your version. You
may also notice that additional lines have been added by other students in the
printSomeWords() method. But there are no conflicts there. (Do
you know why?)
- Resolve the conflict by editing the file and forcing your change to
override the other one. After you've resolved the conflict, run the program
again to make sure it works.
- Next mark the file as resolved, and try to commit again. You may get
unlucky, and someone else may have beaten you to the repository. If you get
another conflict, resolve it in the same manner as before, and commit again.
- Your changes are now in the repository. Compare against the base revision
again---there should be no source code differences.
Apache Ant in Eclipse
When you compiled the code in the previous step, Eclipse used its built-in
build manager. Now we'll set up Eclipse to use an Ant build.xml file that
we'll distribute with our code. That way you can build the code either in
Eclipse or on the command line.
- Right-click the project, then choose Properties. Select Builders → New.
- Next select Ant Build, and click the OK button.
- Give the builder the name "Ant Builder". Browse the workspace and select
build.xml for the buildfile. Browse the workspace and select
Homework 2 as the base directory.
- Click OK.
- Now the project will use the Ant build.xml file to build the code.
Disable automatic builds, then rebuild all. You will see Ant's output in the
console.
- Go back to the project properties and uncheck the Ant Builder to disable
it. Turn automatic builds back on in the Project menu.
- Now compare your project against the repository using Team → Synchronize. Change to the synchronize perspective, and you'll see
file differences on the left. For example, .project is changed.
Double click it to see the new build command that Eclipse added to the
file. Also note that the directory .externalToolBuilders has been
added and is new.
- Normally you would add the new directory and updated project file to the
repository, but don't do this now. (Otherwise other students wouldn't be able
to do these steps.)
- Exit Eclipse.
Subversion and Ant Without Eclipse
If you don't like Eclipse, you can still work on the project as long as you
have subversion and Ant.
- Check out the code using
svn checkout svn+ssh://<USERNAME>@<MACHINE>.cs.wm.edu/\
home/f85/coppit/classes/csci435-spring2007/435root/Homework\ 2
Note the backslash at the end of the line, to escape the newline that I used
to break the long line in two. When you issue the command, remove the "\" at
the end of the line and the whitespace at the start of the next line.
However, be careful to keep the backslash in front of the space before "2", or
else svn will see the "2" separate from the rest of the URL. (You
could put single quotes around the whole URL instead.)
- Look at a log of all the changes:
cd Homework\ 2
svn log
Note that by default subversion uses a directory name that matches the one
checked out from the repository. You can change this by providing a second
argument to the svn checkout command. For example, to check out a
"trunk" for a project:
svn checkout svn+ssh://<USERNAME>@<MACHINE>.cs.wm.edu/\
home/f85/coppit/classes/csci435-spring2007/435root/project/trunk project
You could use this to check out "Homework 2" as "Homework2" so that you don't
have to deal with the space in the directory name.
- Ant uses the build.xml file that you got out of the subversion repository
to tell it how to compile your code. Type
ant
to compile the source files.
- Run the program using
ant run.
- Now run
ant clean to clear the .class files
out.
- Create a HelloWorld.jar file by running
ant jar.
- Re-compile the code, but save the output this time:
ant run > $USER.ant_output. Email this file to
coppit@cs.wm.edu to get credit
for this part of the assignment.
Grading
75 points total
Back to the CSci 435/535 Homepage.