Thursday, March 26, 2009

Off to a Bad Start with GWT

So I've just spent the last few hours battling with an obscure Eclipse/GWT bug. 

The official bug report for this beast I find very appropriately titled: GWT project creation indefinetly creates folder recursively.

If you're new to GWT (like me) and you find your machine spinning in circles as you innocently follow the instructions listed in the Getting Started - Quick Start section of the otherwise generally helpful docs section of the Main GWT page, CLICK CANCEL IMMEDIATELY!!!

Confused code is creating a rabbit hole as deep as your wildest imagination on your computer.

Once the damage has been done, the tricky part is cleaning up the mess. The crucial problem here is that Windows can not deal with file names longer than 256 characters. "So what?!" you say, "Can't you just delete the directory and be done with it?"

Shouldn't it be so easy. No, Windows is so freaked out it can't even deal with deleting the thing.

Most of the suggestions I could find on the web as to how to delete these undeletable files suggesting a wierd trick where you map a network drive to one of the folders deep in the hierarchy... effectively chopping off all the preceding path and replacing it with a single drive letter. One friendly helper on the ticket/thread for this bug notes, helpfully, that "You may have to do this more than once."

Exactly. More than once indeed! This is recursion we are talking about here. Computers are fast... and yours truly multitasked the Eclipse window out of sight and mind for a good five minutes before checking back and kiling it. As you can imagine, this netted me a very, very, very, very deep mess of recursive directories.

So I figured, the best way to solve this issue was to take matters into my own hands. So I wrote a little batch script to fight fire with fire: recursively move and delete until all gone. 

IF EXIST MyProject/MyProject GOTO :KillAChunk

move MyProject/MyProject foo
rmdir /s /q MyProject
move foo MyProject
GOTO LoopStart

IF EXIST MyProject rmdir /s /q MyProject

...create a new notepad file called "killer.bat" or something of the sort, paste that text into it, and save it in the directory where you find the first "MyProject" directory. Now just double-click killer.bat or run it from the cmd prompt and voila! All cleaned up.

I hope that helps someone/anyone out there who ran into this problem. Very annoying! It would be kind of the good people at Google to at least add a warning in their documentation to prevent others from falling into this trap.

1 comment:

  1. Thank you SO MUCH! I've been searching for a solution for hours and hours. I set up an Eclipse workspace without paying attention to what I had named folders, and before I knew it I had an infinite nest of folders. This fixed it in 1 minute!

    Many thanks again.