Had an interesting case come up, as I’m using JBoss 4.0.4 GA with NetBeans 5.5 Beta 2, which effectively gives me a J2EE environment in which I can run my Enterprise JavaBeans, which happen to be using the EJB3 standard.
The problem that I ran into was when checking my source code into Subversion, as I was getting an obstruction error message during an SVN Commit. When asked to perform a Clean Up, that didn’t help rectify the problem.
Here’s what was going on, and how to fix it.
Subversion stores in the versioned directories a hidden directory of its own called .svn which is used to record the meta-data of what’s in that folder. Before you can check in anything to the repository, you must be up to date with it. Subversion doesn’t want you, or anyone else, to lose data, especially during an update.
Normally with development environments like VisualStudio, a set of directories is created (such as obj, bin, Debug, and Release); these are directories you may want to preserve the directory structure of in version control, but not the contents of those directories. In general, compiler auto-generated content or transient files don’t belong in version control, as these files are usually binary and often big, wasting space.
NetBeans creates a build and dist directories for Java projects. And, while it may seem safe to check these into subversion, it is not.
If you were to check in the build directory, even if you ignored the contents, subversion has to keep track of what’s going on and created its hidden .svn directory inside it.
However, when NetBeans does a Clean and Rebuild, instead of erasing the directory’s contents, it deletes the whole directory and recreates it. Anything inside that directory is lost forever, including the .svn directory.
Now when you go to do a Subversion Check In, it sees the directory exists, but it doesn’t see its .svn file. Subversion thinks you accidently deleted its directory and recreated another directory with new content in it by the same name! Hence, you’ve obscured it.
Clean Up is going to fail as well, as there’s no .svn directory to twiddle. You’re at a standstill until you correct the problem.
Doing so is easy.
- Get rid of the offending directory – delete it, move it, whatever.
- Perform a svn
update to get yourself in sync with what’s in version control. - Right click and do a SVN Delete… on the offending files and directories.
- Perform a commit, which saves the state that those do not belong in version control.
- Open your development environment and do a Clean / Build, recreating the problematic directories – not to worry, they are not in version control
- Perform another commit, however this time select all the files and directories that don’t belong and ignore them (right click, it’s in the pop-up); repeat until you have the smallest set of top level directories.
- Let the commit happen, recording the fact you do not want version those directories in the future.
At this point you should be good. Subversion won’t save them, and NetBeans will delete and recreate them without stomping on Subversion’s meta data.