- File > New > Project ...
- Checkout from SVN
- Choose "Select/Create Location"
- Enter URL of repository/directory, "Next >"
- Use tree display to pick project directory where ".settings" root of the source tree exists, "Next >"
- Enter project information (Project name, workspace location, allow local obstructions)
- "Finish" to allow it to check everything out.
A blog for me to record random things I do. I really don't expect anyone other than myself to ever look at it, but I'm happy if they do. Don't be surprised if posts are half complete, poorly edited, or don't make any sense. I'm sure they made perfect sense to me at the time. ;-)
Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts
Thursday, December 3, 2009
Checkout SVN project with subclipse
To beging working on an Eclipse project that is stored in Subversion, do the following:
Friday, September 25, 2009
Subclipse handles file renaming (refactoring) of Java classes properly
I started playing with CollabNet desktop and particularly Subclipse within Eclipse. Some things I liked.
To refactor without the subclipse plugin, I had to do the following:
I also noticed that Subclipse and Tortoise SVN seem to "play nice" with checked out versions of code. That is, you can alternate back and forth between using Subclipse and Tortoise to operate on files.
Refactoring
Subclipse DOES handle refactoring of classes. That is, if you rename a class, it will create subversion events to delete the old class and add the new class. For example, renaming A.java to B.java shows a "Add B.java with copy-from path of A.java." This means that it preserves the version history over time.To refactor without the subclipse plugin, I had to do the following:
- Use "Rename" to rename the class. This fixes all the code and simply renames the existing file as the new file. (OldClass --> NewClass)
- Do a SVN "Update" to get the old file back in the directory (OldClass.java)
- Delete that OldClass.java file and rename the NewClass.java back to OldClass.java. SVN should show you that the file has been locally modified.
- Do a SVN Rename to rename OldClass.java back to NewClass.java.
- SVN "Check for Modifications" (status) should show you a "delete" of OldClass.java and a "add" of NewClass.java with a copy-from path of OldClass.java
I also noticed that Subclipse and Tortoise SVN seem to "play nice" with checked out versions of code. That is, you can alternate back and forth between using Subclipse and Tortoise to operate on files.
Labels:
eclipse,
java,
refactoring,
subclipse,
subversion
Tuesday, September 22, 2009
HOWTO Include Subversion version identifiers in your Java source code with Eclipse
It's often useful to include version markers in your source code files, especially when it's possible they will be distributed outside the bounds of a version control system. In my case, I'm using Subversion and Eclipse to write code.
Subversion provides keyword substitution for special keywords that are managed by Subversion during checkin an checkout. (See: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html). These include Date, HeadURL, Revision, Author, and Id (a combination of the others). You can embed these in your text files and SVN will automatically replace them with appropriate values each time. To enable this, you need to do the following:
svn propset svn:keywords "Id HeadURL Revision Author Date" foo.java
Then, you embed a keyword like "$Id" in your file and next time SVN updates your file, it will replace the $Id string with something like
Subversion provides keyword substitution for special keywords that are managed by Subversion during checkin an checkout. (See: http://svnbook.red-bean.com/en/1.5/svn.advanced.props.special.keywords.html). These include Date, HeadURL, Revision, Author, and Id (a combination of the others). You can embed these in your text files and SVN will automatically replace them with appropriate values each time. To enable this, you need to do the following:
svn propset svn:keywords "Id HeadURL Revision Author Date" foo.java
Then, you embed a keyword like "$Id" in your file and next time SVN updates your file, it will replace the $Id string with something like
$Id: foo.java 148 2006-07-28 21:30:43Z sally $.
To make this easier, you might want to change the [auto-props] section of your config file to automatically set this property any time you create a new java file:
*.java: svn:keywords="Id HeadURL Revision Author Date";svn:eol-style:native
Typically, this is embedded in a comment block. To make this easy, you can include it in your Eclipse file templates so things get pre-populated when you generate new files.
For general purpose insertion in all your Java source files, use Window > Preferences > Java > Code Style > Templates, then edit the "Files" entry and add the following to the template:
/*
*
* $$Id$$
*/
That will automatically insert the "$Id$" tag into any new source file you create.
Another reference:
http://wiki.collectionspace.org/display/collectionspace/Java+Source+Files+-+Beginning+Comments+Block+Template
For more advanced usage, you can embed a string in a variable that gets compiled into the object code and can be used to identify versions of binaries.
For Java, insert a piece of code that looks like this:
// version identifier automatically filled by svn:keywords "Id"
public static final String __class_id = "$Id$";
This will expand when the files are checked in to be representative of the version of code that was committed.
This can automatically be inserted in new classes with code templates, again. Window > Preferences > Java > Code Style > Templates > Code > Class body. (Make sure you use $$ for the dollar signs when you create the template.)
Pitfall: Make sure you have cleanly committed/updated files when you do this. Don't make the mistake of building your modified code that is checked out, then distributing it. Once you commit this code, the version number will bump up and potentially be different.
Labels:
eclipse,
java,
subversion,
svn:keywords,
template
Subscribe to:
Posts (Atom)