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

Crash in relativize when source directory not in subfolder #128

Closed
lrytz opened this issue Aug 2, 2012 · 9 comments · Fixed by #214
Closed

Crash in relativize when source directory not in subfolder #128

lrytz opened this issue Aug 2, 2012 · 9 comments · Fixed by #214
Labels
Milestone

Comments

@lrytz
Copy link

lrytz commented Aug 2, 2012

I have a project where (sourceDirectory in Test) is not a child of baseDirectory, it's only accessible through the parent. Calling sbt.IO.relativize will return None and therefore def relativize in Eclipse.scala crashes.

@hseeberger
Copy link
Member

Thanks for reporting. Please give me access to a reproducible test case.

In the meantime you may want to consider the following quick fix: Try to avoid non standard project layouts, they are confusing for beginners anyway.

@lrytz
Copy link
Author

lrytz commented Aug 2, 2012

I could only reproduce it with two projects:

https://gist.github.com/3236082

> eclipse
[info] About to create Eclipse project files for your project(s).
[error] java.util.NoSuchElementException: None.get
[error] Use 'last' for the full log.

@hseeberger
Copy link
Member

Thanks.

I think what you are trying to do is not possible in Eclipse. Could you please confirm?

Of course sbteclipse should not fail with an error, but if your scenario was valid for Eclipse, then I would have to treat it differently.

@lrytz
Copy link
Author

lrytz commented Aug 2, 2012

I don't know if it's possible in eclipse, I don't actually use eclipse currently.

As you say, sbteclipse should just not crash, and skip the project if it cannot be expressed as an eclipse classpath.

@ghost ghost assigned hseeberger Aug 2, 2012
@Rotsor
Copy link

Rotsor commented Feb 25, 2013

Another way to reproduce the problem is to have your target directory outside of the project base path.

The contents of project/Build.scala reproducing the problem:

import sbt._
import Keys._
object B extends Build {
lazy val dummy = Project(id = "dummy", base = file("Dummy"))
.settings(target := file("target/Dummy"))
}

My preferred solution would be to have sbteclipse produce an Eclipse-compatible directory layout with the help of symbolic links.

@jsuereth
Copy link
Member

Here's what you need for relative directories in Eclipse:

in the .project file:

<projectDescription>
    ...
    <linkedResources>
            <link>
                    <name>NAME_OF_EXTERNAL_LINK</name>
                    <type>2</type>
                    <location>LOCATION_TO_EXTERNAL_DIR</location>
            </link>
    </linkedResources>
</projectDescription

In the .classpath file:

<classpathentry kind="src" path="NAME_OF_EXTERNAL_LINK"/>

It appears eclipse is emulating symlinks. If you look in the build path settings, the feature is the "link source" button.

I'm adding a +10 for adding this feature. I run into it all the time on my current project. IF you guide me in how to fix it (what files I should be touching) I'm more than willing to submit a patch.

  • Josh

@jsuereth
Copy link
Member

OH, also related, if the path has ".." in it, this plugin is not catching that it is non-relative. I think this may be due to SBT's relativize function, if so I can report against SBT.

@jsuereth
Copy link
Member

BTW this is ffixed in 2.2.0-RC1 if you could give it a try.

@Rotsor
Copy link

Rotsor commented Apr 18, 2013

Fails the same way on my example even after switching to sbteclipse-plugin 2.2.0-RC1.

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

Successfully merging a pull request may close this issue.

4 participants