onlywei
onlywei

Reputation: 1517

How best to handle .classpath files in Git when developers are using different versions of JBoss in their project build paths?

I am new to Git and I'm having a lot of difficulty figuring this out.

We are using JBoss Application Server 5.1 in Eclipse. Some people have downloaded the JBoss Tools Eclipse Plugin so they can add the JBoss 5.1 Runtime Server as "JBoss AS 5.1" to their Eclipse workspace. This results in a classpath line that looks like this:

<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/JBoss 5.1 Runtime"/>

Other people do not see the value of downloading and installing the JBoss Tools plugin, so they just use Eclipse's built-in JBoss server adapter, which only goes up to JBoss v.50. They have a classpath line that looks like this:

<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.generic.runtimeTarget/JBoss v5.0"/>

I don't want to add .classpath to my .gitignore file because:

  1. The files are already pushed to my origin, and removing them is a super painful process that I have tried and failed to understand in the past.
  2. I want people who are setting up new workspaces to just be able to import the projects from Git and get going right away.

So far we have just tried each modifying our .classpath files in our working directory but never committing. This is annoying not only because they keep showing up in our git status, but sometimes they will not allow us to merge or switch branches in Egit - complaining about uncommitted changes.

I've read on the internet about using Classpath Variables instead, but I cannot seem to find the correct path to the JBoss libraries at all. The classpath lines I listed above seem to point to somewhere inside the Eclipse/plugins directory somewhere? But I can't find it. I also tried pointing some variables to my C:\jboss-5.1.0.GA\ directory, but that does not seem to do anything either.

Is there a way to just leave the .classpath file inside the repository as it is now in its current state, so that new users who clone the repository still get them, but then just ignore all future changes any developers make to the files?

Upvotes: 6

Views: 7808

Answers (2)

coberlin
coberlin

Reputation: 618

An easy, once-per-developer solution from Pagebakers and git is

git update-index --assume-unchanged <file>

To undo it, just use

git update-index --no-assume-unchanged <file>

Upvotes: 6

VonC
VonC

Reputation: 1326892

Another answer can be using a content filter driver, ie a script that you declare in a .gitattribute file.

filter driver

On checkout of your repo, the smudge script would be in charge of analyzing the local environment, detecting the JBoss in place and adapting the classpathentry accordingly.
That way, you can keep the most useful content of that file already versioned, while adapting to the few special cases where the classpathentry is not the correct one.

Upvotes: 1

Related Questions