Jun 04 2008

OpenGrok: Can You Dig It?

Published by sparky under Java Development

Raise your hand if you use OpenGrok.

O.K. you folks are free to leave.

Now raise your hand if you’ve ever read Robert A. Heinlein’s Stranger in a Strange Land.

If you haven’t read the book (and why not?) then you probably don’t know that Heinlein coined the phrase “grok” in his 1961 novel. Grok was used to describe the state of fully understanding someone or something. The entry on Wikipedia states that in the book it “literally means “to drink”, and had a much more profound figurative meaning that is hard for Earthlings to understand because of our assumption of a singular reality. . . The water becomes part of the drinker, and the drinker part of the water. Both grok each other.”

Along those lines OpenGrok, from the gang at OpenSolaris, is a source code search utility that aims to help you search and better “grok” your code base in such a way that after having used it for only a few months I ‘ve found it indispensable for code development. The OpenGrok developers have termed it “wicked fast” and they are spot on in their description.

Simply put OpenGrok allows you to quickly and completely search a code base for text phrases or code snippets with such stunning speed that you’ll never use the search command in you IDE, or the more direct “grep” command at the command line, ever again. No, really, I mean it. Alright I know forever is a long time but ya gotta roll with me on this one. Whatta ya say we just install the software? OpenGrok will run pretty much anywhere you can run OpenSolaris but I’ll focus today on getting it working under Windows XP.

Getting and Installing the Software
You’ll want to point your web browser at http://opensolaris.org/os/project/opengrok/ to read about the latest version of OpenGrok (0.61 at this time) and download the binaries for your platform. Unless you are running on Solaris (I wish) you can download the file named “opengrok-0.6.1.tar.gz.”

In addition you’ll need the Exuberant CTAGS binaries located at http://ctags.sourceforge.net/. Ctags, and I quote their website, “generate(s) an index (or tag) file of language objects found in source files that allows these items to be quickly and easily located by a text editor or other utility.” I feel better already don’t you? The version available works not only for Java but also for Assembler, AWK, ASP, BETA, Bourne/Korn/Zsh Shell, C, C++, COBOL, Eiffel, Fortran, Lisp, Lua, Make, Pascal, Perl, PHP, Python, REXX, Ruby, S-Lang, Scheme, Tcl, Vim, and YACC. (What no Qbasic?)

Now that you have both of these binary packages downloaded extract them to the location of your choice. I chose c:\grok as I am a horrible typist. After you are done extracting the archives you should have a directory structure similar to this:

Please note that the “ec57w32″ directory is the one that has the CTAGS binaries in it.

Now open the “opengrok-0.6.1″ folder and edit the “run.bat” file located there. Then comment out the last exec line for the EFTAR tags unless you know that you need them. If you do use EFTAR tags, and you know who you are, send me $35.00 in unmarked bills or I’m goin’ to the cops.

Next you will need to set the SRC_ROOT to whichever code-base you want to search. e.g. “C:\code\myapp.” Then set the DATA_ROOT to where you want the index files to be. For example “C:\grok\GrokData” like in the screen shot above. If you have multiple branches of source code put them in branch specific subdirectories underneath DATA_ROOT. That way later on you can “grok” multiple branches.

Set the path to the EXUB_CTAGS to where you put ctags.exe. Mine is located at “C:\grok\ec57w32\ctags\ctags.exe.” You will also probably want to change the memory setting for grok. I had to add “-Xms100M -Xmx1000M” as arguments to the java calls to increase the allowed memory size (indexing can suck a bit of memory) Others at our place have noticed that you need to put the memory changes on their own line i.e. “java -Xms100m -Xmx100m” to get this to work.

Now you can run the “run.bat” file and start the indexing process. Go get a cup of coffee and a doughnut as this can take a while.

If you do have multiple branches to index you’ll want to create an xml file, something named “configuration_branchName.xml,” uniquely named for each branch, and put the following lines into it. (for java anyway):

Then you’ll need to create another “run.bat” for each branch you want to index and edit it accordingly to point to the location of the files it is supposed to index. For instance I have a “runbranch1.bat” and a “runBranch2.bat” and so on.

Note the “ctags,” “dataRoot,” and “sourceRoot” info will be specific to your setup. For those of you not using Java you’ll have to go to the OpenGrok and CTAGS websites and check the documentation there. Hey! I can’t please everybody!

Finishing Up
That’s pretty much it. You’ll want to place a soft link or shortcut to the OpenGrok jar file (located at C:\Grok\opengrok-0.6.1\opengrok.jar) somewhere that is easy for you to find so you can launch the app without a lot of trouble. You can see a nice picture of how the GUI looks at: http://www.flickr.com/photos/chandanlog/102978562/ or also here: http://www.flickr.com/photos/chandanlog/71852240/.

There are plug-ins available for both Eclipse and Netbeans. I am using the Netbeans plug-in, which is a little annoying to install but it is tons better than the one for Eclipse. (Which is another reason to use Netbeans!) In the Netbeans version the entire OpenGrok gui appears in a window. The Eclipse version is just not as pretty. But then again neither am I and it has never held me back as least as far as I know.

Other Tips
I set my system up to re-index every night at 3:00 a.m., a time when you should all be home and in bed I hasten to add, by setting up a Scheduled task in Windows. You can do this easier with a cron job on a Mac or a *nix/Solaris box.

Issues You Might Encounter
One thing that I have noticed is that the re-indexing will fail if a “write.lock” file remains in the index folder of your “dataRoot” directory listed in your configuration.xml file. If this is the case your indexing will fail. The fix is to just remove this file if it remains behind after a re-index. You’ll then have to re-index to get you code base up to date.

More info on installing OpenGrok. including other means of deploying the software, can be found here: http://opensolaris.org/os/project/opengrok/manual/installdescription/.

Now get back to work!

One response so far

May 23 2008

What Happened?

Published by sparky under Site News

What can I say but the site blew-up.

The hosting company I use for this site featured a link to “upgrade” Wordpress to 2.5.1.

So naturally I tried it and naturally it failed miserably. They wanted $59.95 to restore my backup (gee thanks fellas) so I had little choice but to try and recover it myself.

After a day and a half of messing around I decided to just start over.

I lost most of the posts, there weren’t that many to begin with really, so I figured we can just start over from here.

Regards to all,

Sparky

2 responses so far

May 23 2008

Netbeans 6.1: What? Still No Perforce Support?

Published by sparky under Java Development

Note: This is a restored version of an earlier post

Netbeans 6.1 was released just today. I downloaded it right away and started using it on a project at work.

Sigh . . . Of course I can’t get it to work with Perforce (P4). When trying to install the VCS Generic plug-in, required in all previous versions of Netbeans to integrate with P4, I get an error.

Since this version of the IDE is so new there is little I can do in terms of searching for support at this time. That coupled with Netbeans’ historic refusal to address P4 support directly has left me with the following choices:

  1. Stick with Netbeans 6.0.1
  2. Use 6.1 without Perforce
  3. Switch to Eclipse

Option number 3 is starting to look good. I’ve been an unofficial Netbeans Evangelist for a long time now but the difficulties in getting it to work with P4 has always been a sticking point for a lot of developers. This is especially true here where we have to use Perforce.

It’s not that I don’t like Subversion or CVS either. Nowadays at most places you work they have already decided on a form of version control. In nearly all cases they are not likely to change just because your IDE of choice practically refuses to acknowledge the existence of P4.

I’ll stick with 6.01 for now as I am in the middle of a large development effort. But after that if things have not improved I think I’ll move to Eclipse.

Come on Netbeans! Throw me a bone here!

6 responses so far

May 23 2008

George of the Jungle . . . Disk

Published by sparky under Technology

Note: this is a restored version of an earlier post.

How much do I love Jungle Disk? (http://www.jungledisk.com/) Let me count the ways:

  1. It allows me to back up files off-site to Amazon’s S3 “cloud” with minimal fuss.
  2. It’s incredibly affordable.
  3. It’s web-based and doesn’t care what OS you are running on.
  4. With each purchase you get a dozen free doughnuts! (just kidding).

O.K. Chumly. Just What the Heck is Jungle Disk?

Glad you asked there Schleprock! Jungle Disk is an application that lets you store files and backup data securely to Amazon.com’s S3 ™ Storage Service. There is very little to buy. The cost of the software is $20.00. For roughly the price of two cases of cold cheap beer you get lifetime free upgrades, software that runs on Macs (yeah!), Linux (wahoo!), and Windows PC’s. (yawn . . .). In addition there is no limit to the number of machines you can install the software on.

There is an “advanced version” of the Jungle Disk software that costs $1.00 more a month above the original $20.00 purchase price. I “splurged” and went for this version as it allows you to only backup “changed” files which keeps the total stored on Amazon lower. I’d recommend going this route if you decide to spring for Jungle Disk.

You will also need an Amazon S3 account but signing up for the account is free. You only pay for what you store on the S3 cloud. And get this you tightwads. It’s 15 cents a gigabyte.

At this point a concerned reader interrupts: “Excuse me sir did you stutter? I would have sworn you said 15 cents a gigabyte.”

Sparky: “You heard me right boychik, it’s $0.15 a gig.”

I have all of my digital photos stored there and my monthly bill is $0.29 for storage and $1.00 for the software. If you were a professional photographer, or a more serious hobbyist, you’d definitely pay more if you had a lot of pictures but then again you probably don’t have to back up eveything you take. So Amazon’s “pay for what you use” strategy makes as much fiduciary sense as selling your Humvee and buying a Honda Civic.

Still More of the Jungle Disk Love Fest

In the words of Raymond Chandler: “I’m an occasional drinker, the kind of guy who goes out for a beer and wakes up in Singapore with a full beard.”

What does that quote have to do with Jungle Disk you ask? In fact what does that quote have to do with anything?

Well if you are the kind of occasional drinker who wakes up in Singapore after Happy Hour at the local Brew and Munch you’ll be happy to know that Jungle Disk can be set up to work automatically. That’s right. It will backup your files even if you forget.

I have been searching for a couple of years for a way to back up our family’s digital photos someplace off-site in case we suffer some kid of home-network-destroying-disaster. This includes the possibility of fire although none of us smoke. (besides an occasional cigar on the back porch during the summer but you didn’t hear that from me) Since we live in the mid-western U.S. there is always the chance of tornado and some people have had their basements ruined when the sewers back up, an issue with our crumbling infrastructure here, and the basement is where my Linux file servers sit.

Setup is easy and takes only about 20 minutes. You’ll need the S3 account, and to organize your files a little bit so you can “point” Jungle Disk at the directories you want to back up. I won’t bore you with all of the details on installation. It’s real straightforward. If you are reading this article I assume you know enough to be able to set it up.

So you see? There’s no longer any reason not to have a good safe remote backup of all your important files.

Just a note, I am not a representative of Jungle Disk, and I don’t work for Amazon either. My total renumeration for this article? Zero, zilch, nada. I’m just doing it for the love baby. The love of Jungle Disk.

No responses yet