1

I have a Scala project I share via git between two (windows) machines. I have them set up using SBT and sbt-eclipse so I can edit and test within eclipse or build and test from the command-line.

Unfortunately my user name (and, therefore, the user profile directory) is different on the different machines. This means that when sbt fetches dependencies it puts them in different base directories on the two platforms. This wouldn't be a problem except that the full pathname is hardcoded into the eclipse .classpath file from sbt-eclipse. This means that I have to rerun the 'eclipse' task when I do a pull on my 'current' machine.

This must be even worse for others who do this kind of thing as a team. How is this normally handled? I would prefer to do a pull on whatever machine, even from within eclipse, and get started right away.

melston
  • 2,198
  • 22
  • 39

1 Answers1

2

I would strongly recommend removing the eclipse-sbt-generated files (and all other generated files) from git. Each machine will have it's own .classpath file that is generated on that machine that is generated on that machine for that machine and can be regenerated whenever you want/need. Your build.sbt project files should be in git, so when you pull onto each machine, it will have the updated config, and you can just run sbt eclipse only when you have a dependency change.

Really, you should always avoid having generated files in source control. Have only the important stuff in your git project, and generate the rest as necessary.

dhg
  • 52,383
  • 8
  • 123
  • 144
  • OK. That explains it. I hadn't realized the issue since I have always (on java projects, anyway) just included the `.classpath`, etc, files. I assume the `.project` file is still ok, right? – melston Jul 30 '14 at 21:17
  • I would not include .project either. Both of these are generated by the `sbt eclipse` command, and, therefore, there is no value to having them in git (but that are potentially downsides if there are conflicts). I also wouldn't include these files on a java project for the same reasons. – dhg Jul 30 '14 at 21:19
  • So that means I really need to change how I work with eclipse on Scala projects. I cannot just import from git anymore since it won't include a complete project. I have to import, go to a command line, execute `sbt eclipse`, then refresh my workspace. Does that cover it? Oh, and add the `.classpath` and `.project` to my `.gitignore` file. – melston Jul 30 '14 at 21:21
  • Yep. That's the right way to go about things. Though it shouldn't be a big deal to run one command from the command line when you're setting up a project on a new workstation; you have to do it anyway to get it to download the dependency jars. – dhg Jul 30 '14 at 21:24