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

include root directory in .classpath (in sbt build) #186

Open
mighdoll opened this issue Nov 21, 2013 · 9 comments
Open

include root directory in .classpath (in sbt build) #186

mighdoll opened this issue Nov 21, 2013 · 9 comments

Comments

@mighdoll
Copy link

When following standard conventions, users put .scala files in the root of the project directory in sbt. However, sbt-eclipse doesn't add a .classpath entry for these .scala files in the root directory.

see stack overflow for an example where the .classpath generated for the sbt build is missing the the root directory, and for a manually generated solution.

It's probably possible to detect this situation automatically by noticing .scala files in the root directory. But even without an automatic detection, an option like sourcesInRootDirectory=true would be nice.

@hseeberger
Copy link
Member

I think putting .scala files into the project root directory is bad style. Could you please explain why you consider this "standard conventions"?

Anyway, Eclipse doesn't like nested source directories. There are ways to work around it (exclusion rules), but this feature would definitely add some complexity.

@mighdoll
Copy link
Author

I mean in the directory called 'project' if that was unclear.

http://www.scala-sbt.org/release/docs/Getting-Started/Directories.htmlshows
build.scala at the root of the 'project' directory - I think this has
been the convention for some years now.

In the stack overflow example, I showed an inclusion rule - probably
simpler than exclusion in this case..

On Thursday, November 21, 2013, Heiko Seeberger wrote:

I think putting .scala files into the project root directory is bad style.
Could you please explain why you consider this "standard conventions"?

Anyway, Eclipse doesn't like nested source directories. There are ways to
work around it (exclusion rules), but this feature would definitely add
some complexity.


Reply to this email directly or view it on GitHubhttps://github.com//issues/186#issuecomment-28965940
.

@hseeberger
Copy link
Member

Thanks for the clarification.

Scala files under project/ are part of the sbt build definition. Therefore they (might) depend on sbt libraries, hence a general solution requires more than just adding a src entry. See issue #26.

@jsuereth
Copy link
Member

@hseeberger If you do "reload plugins" "eclipse", then you everything seems to work.

What you actually need to be able to add the root directory is the appropriate mechanisms of "excluded" directories. If that issue was fixed, I'd say we should be able to enable this, so we can eclipsify our build.scala files.

@mighdoll
Copy link
Author

@jsuereth - not quite everything works. I see in #26, someone noticed the same issue and also proposed adding:

        <classpathentry including="*.scala" kind="src" path=""/>

Perhaps the plugin could check whether there are .scala files in root path by examining the 'sources' key and if so, then add the above entry to the classpath. I think that would solve the common case at least.

@hseeberger this issue is is just about adding the above classpath entry when you do "reload plugins" "eclipse". (I suppose it would also fix this stack overflow request too.)

#26 would trigger all this without requiring "reload plugins" which would be nice (but #26 is separate, and would benefit from this logic).

@godenji
Copy link
Contributor

godenji commented Dec 22, 2013

@jsuereth blows up here in a Play sub project enabled build

reload plugins // fine
eclipse // boom

[debug] Project dependencies for configuration 'compile': Success(List())
[debug] Project dependencies for configuration 'test': Success(List())
java.util.NoSuchElementException: None.get
at scala.None$.get(Option.scala:313)
at scala.None$.get(Option.scala:311)
at com.typesafe.sbteclipse.core.Eclipse$.relativize(Eclipse.scala:576)

Have periodically tried since forever to get project/*.scala files recognized by Eclipse -- the inner workings of SBT would be far more accessible with live type inference vs. blindly groping in the dark ;-)

@hrj
Copy link

hrj commented Mar 6, 2014

Could this plugin generate a separate Eclipse project for the .scala files relevant to the sbt project? That way there won't be a namespace collision across different concerns.

@jsuereth
Copy link
Member

jsuereth commented Mar 6, 2014

@hrj I think I just found the piece that would allow us to do it. THere'sa pluginData key that has the right classpath.

@teldosas
Copy link
Contributor

Any progress on this? I too have a project that has sources in the root folder but nested. That is com/company/lib. So the contents of this folder should have package com.compay.lib

The plugin currently adds

<classpathentry output="C:-Users-User-Projects-Project1" kind="src" path="C:-Users-User-Projects-Project1"/>

that's the path to my project dash separated and it doesn't work

I fix it manually from eclipse ui by adding the project root as a source folder and an inclusion rule and I get the following classpathentry

<classpathentry including="com/**" kind="src" path=""/>

which works

Can this be done automatically? I would gladly create a PR if someone points me to the right direction. :)

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

6 participants