sbt-eclipse icon indicating copy to clipboard operation
sbt-eclipse copied to clipboard

Eclipse per-source folder output directory

Open dragos opened this issue 9 years ago • 10 comments

A while ago sbt-eclipse used to use the target/ output directory, just like maven and Sbt. I like that behavior and I want it back. How can I do that? I can't find any setting that would make each source folder go to the right directory under target/

dragos avatar Jul 02 '15 14:07 dragos

#202 seems to be related

Locke avatar Jul 09 '15 08:07 Locke

@dragos I disliked the change too, but mostly because undocumented. And I'm not so sure I dislike that change. Eclipse won't reuse code produced by SBT, since it doesn't know that the classes are up-to-date. And on some projects, I end up using two checkouts just to run both SBT and Eclipse and have different build dirs.

From #202, it'd seem you want a cleaner variant of:

EclipseKeys.eclipseOutput in ThisBuild in Compile := Some("target/scala-2.11/classes")
EclipseKeys.eclipseOutput in ThisBuild in Test := Some("target/scala-2.11/test-classes")

(with less hardcoded strings). @dragos, I think you can clean that up faster than me.

Blaisorblade avatar Jul 25 '15 13:07 Blaisorblade

Eclipse uses the same incremental compiler, so there's no reason why it shouldn't work. It probably won't work with ~compile in Sbt.

I agree that changing the default without proper documentation is really bad practice... Thanks for the workaround.

dragos avatar Jul 26 '15 12:07 dragos

Eclipse uses the same incremental compiler, so there's no reason why it shouldn't work. It probably won't work with ~compile in Sbt.

I've not seen it working, but I wasn't sure what to look for (and I like my ~compile). I think that, after an SBT full build, Eclipse will only be too happy to rebuild from scratch.

But do Eclipse and SBT share the info used to compute which class files are up-to-date*? Without any locking? I'll see whether that works given enough refreshing. *Timestamps don't cut it, so SBT must at least store extra dependency info, though I'm not sure of the internal format.

Blaisorblade avatar Jul 27 '15 09:07 Blaisorblade

Yes, they save info in .cache files. The problem might be that the names diverged. At some point at least, they used to save it to the same file. Obviously, they don't know about each other, so running at the same time might corrupt these files. That's why I suggested ~compile is a bad idea (only one of Eclipse and Sbt should compile). Probably it's a risky configuration, so not sure how many people use it, if any.

dragos avatar Jul 27 '15 10:07 dragos

Yes, they save info in .cache files. The problem might be that the names diverged. At some point at least, they used to save it to the same file.

That's it! On most of my projects I don't use Eclipse, and SBT doesn't create .cache* files in the root. Thanks.

Blaisorblade avatar Jul 27 '15 11:07 Blaisorblade

This is still an issue for me. I have different configurations between my main and test source folders: src/[main/test]/resources/application.conf.

Since sbteclipse is configuring all source folders to have the same output folder the test and main configurations are clobbering each other.

Normally, you would have separate output folders for test and main.

Is there a way to configure this? If so, I would think this is a common setup, so should be at least documented in the user guide, or the default behavior.

craigjar avatar Mar 10 '17 22:03 craigjar

@craigjar I posted a workaround above, see mentions of EclipseKeys.eclipseOutput above. You probably don't want those paths though, better pick any other pair of distinct paths, since they're the same output folders SBT uses but IIRC Eclipse and SBT clobber each other's outputs as discussed above.

Your desire might be common, but I see few people bothering to set up eclipseOutput. One reason might be that conflicts are less common, so few people HAVE to configure it.

If that snippet doesn't work as is: That might need updating, see docs for configuration of this plugin regarding eclipseOutput, or (worst case) other issues, in particular from me.

On mobile and rush, sorry I can't recheck details. And yes, better or more prominent docs might be needed, but time is scarce and I'm afraid you're in the best position

Blaisorblade avatar Mar 10 '17 22:03 Blaisorblade

Sorry, finishing: you're likely in a good position to contribute docs that would have you'd have found, in the sense that you know where you'd have expected the info. Makes sense?

Blaisorblade avatar Mar 10 '17 22:03 Blaisorblade

I've had a similar problem lately, and the EclipseKeys.eclipseOutput advice here was great. Unfortunately, I'm still running into classpath clobbering within Scala-IDE (eclipse) itself. I'm guessing it's actually a bug in Eclipse so I've updated this ticket: https://scala-ide-portfolio.assembla.com/spaces/scala-ide/support/tickets/1002863

Basically, while classes and testClasses are output to separate areas, running my application still includes both test and non-test classes in the classpath. Anything marked with Test scope (or output to test-classes) will be in the runtime classpath when executing "Run As..." a Scala Application.

I'm using Scale IDE 4.6.0-RC1 with support for scala 2.12

drobert avatar May 04 '17 14:05 drobert