Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eclipse per-source folder output directory #293

Open
dragos opened this issue Jul 2, 2015 · 10 comments
Open

Eclipse per-source folder output directory #293

dragos opened this issue Jul 2, 2015 · 10 comments

Comments

@dragos
Copy link
Contributor

dragos commented Jul 2, 2015

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/

@Locke
Copy link

Locke commented Jul 9, 2015

#202 seems to be related

@Blaisorblade
Copy link
Contributor

@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.

@dragos
Copy link
Contributor Author

dragos commented Jul 26, 2015

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.

@Blaisorblade
Copy link
Contributor

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.

@dragos
Copy link
Contributor Author

dragos commented Jul 27, 2015

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.

@Blaisorblade
Copy link
Contributor

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.

@craigjar
Copy link

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.

@Blaisorblade
Copy link
Contributor

@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
Copy link
Contributor

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?

@drobert
Copy link

drobert commented May 4, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants