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.

  1. Start Eclipse, verify your version of Subclipse, and set the Subversion interface to the Java-only interface as described on the tools website.
  2. Visit the project webpage, and add the course Subversion repository as per the instructions.
  3. Open up the "Homework 2" subproject, and check it out as an Eclipse project.
  4. 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.
  5. 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.

  1. In Eclipse, make a change to src/HelloWorld.java at the location marked "edit #1", as described in the comments.
  2. Next edit the file again in the location labeled "edit #2", in the manner described in the comments.
  3. Run the program to make sure it works correctly. Do not commit broken code.
  4. 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.
  5. You should encounter a checkin conflict. (It will complain that your version is out of date.)
  6. Compare your version to the latest version in the repository. (Right click the file, then Compare With → Base Revision.)
  7. 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?)
  8. 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.
  9. 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.
  10. 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.

  1. Right-click the project, then choose Properties. Select Builders → New.
  2. Next select Ant Build, and click the OK button.
  3. 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.
  4. Click OK.
  5. 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.
  6. Go back to the project properties and uncheck the Ant Builder to disable it. Turn automatic builds back on in the Project menu.
  7. 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.
  8. 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.)
  9. 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.

  1. 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.)
  2. 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.
  3. 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.
  4. Run the program using ant run.
  5. Now run ant clean to clear the .class files out.
  6. Create a HelloWorld.jar file by running ant jar.
  7. 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 Back to the CSci 435/535 Homepage.

Last changed January 31 2007 12:49:08. David Coppit, coppit@cs.wm.edu

There have been 1232678 hits since Thu Jun 9 14:49:55 2005

Valid CSS!
Valid HTML 4.01!