SBT Resolve Locally from workspace - eclipse

In SBT/SBT eclipse is there a way to tell eclipse to (temporarily) resolve a dependency from a checked out elipse project rather than from the repository. Basically functionality similar to that offered by the workspace resolver in Ivy DE
My use case here is that I want to make some changes to a library project and instantly see the effect they have on one my applications that uses that library.
If such functioanality is not offered- is there another way I could achieve the desired result?

I don't know if this is the best or fastest way but you could do:
sbt "~publish-local"
In the folder of the external lib to publish to your local repository. Everytime a change is made in that code, it will be compiled and resent to the local repository.
Then just
sbt compile
In your project

Related

How to find or add build.sbt file to existing Eclipse project?

I need the ability to parse XML files in Scala for a regression modelling project of mine. It seems that there is no longer a scala.xml package ready form the get-go so we need it externally. Solution seems to be the project scala.xml from GitHub: https://github.com/scala/scala-xml
Thing is, in order for me to get the JAR file to Eclipse it seems I need to use sbt. I have sbt installed but the regression modelling project was originally made in Eclipse by File -> New -> Scala Project.
Last time I used sbt was when I tried to get ScalaFX to work in Eclipse. I then understood why they changed the name from Simple Build Tools to Scala Build Tools. It was pure hell to get the JAR file (which I did not get by using sbt).
The only way to get the library scala.xml in Scala version 2.12 is via sbt. So now the situation is that I need to make modifications to sbt.build file which doesn't (?) exist in the Eclipse project as the project wasn't made using sbt. How do I do this?
Answering to my own question for anyone having this same problem:
You can make a Git project into a JAR file really easily. What you need is git commands and sbt installed. Here's what you do
i) Open up any directory. Preferably make a new directory with descriptive name.
ii) Go to the Git project you want, click the green box "Clone or download" and copy the url.
iii) Open console, go to the directory you want the project and type git clone _ where _ is the url of the project.
iv) Once the project is cloned open it with console.
v) Type sbt and wait until sbt sets everything up.
vi) Depending on the Scala version you want to use you can do it now after compiling.
vii) Type compile and wait for the sbt to compile.
viii) Once compiling is done type package and you have the JAR file in the projects target directory. After compiling path is shown in the console.

IntelliJ - use imported modules as dependencies like maven projects in Eclipse

I've been asking myself this question for a couple of years but never really found the solution.
I used to work with eclipse (on maven java projects). I could import a project -let's call it 'proj-A'- and if one of proj-A's dependencies was found in the workspace with the same exact version, eclipse would use that project's source instead of the jar from the repository. This way I could edit a library and see the changes in the project that used it right away.
For example, in Eclipse, if proj-A depended on dep-B-1.2.3-SNAPSHOT, I could import proj-A and dep-B in the same workspace, and if dep-B version was 1.2.3-SNAPSHOT I could see the live changes in dep-B sources from proj-A classes.
I'm now working in scala in IntelliJ. I don't seem to be able to do that. what's the best workflow if you want to avoid publishing the library and then reloading the whole project that uses it along with all its dependencies every time?
If I import proj-A as sbt project I can find dep-B snapshot jar in the libraries (loaded from some repo, be it local or remote), and I can't see the code changes to the dep-B module imported in the same intellij project (i.e. the equivalent of eclispe workspace).
If I manually remove the dep-B jar and add the dep-B module as a dependency for proj-A I'm forced to do it everytime I reimport proj-A for some reason.
I'm not sure there's a way of doing this as straightforward as the eclipse way (automatic), but maybe you know something I don't ...
thanks
It should work out of box for dependencies, which are imported to the project as modules, no additional settings needed. At least for Java.
Just do not run a Maven goal, that would use dependencies from the repository.

Attempting to modify typesafe activator UI. How do I import/modify the activator jar files in eclipse scala IDE?

I am new to the scala eclipse environment and also new to typesafe/activator.
I need to modify some of the activator initialization code because of some very specific host-side dependencies.
I cannot see how to "import" the actual jar files into eclipse. I know exactly what I need to change and how (via manually opening the jar and looking at the code). But I want to maintain complete integrity with the change management (ivy and sbt) but I do understand how to do this.
Is there some basic way to pull in/open a source jar, modify it, and build/deploy it? I see lots of help on the export/build, but I need help with the open/import/modify portion of this task.
Thanks for your kind help.
Typically if you wanted to change how a project works you'd go back to the source repository (in Activator's case https://github.com/typesafehub/activator ) and modify from there and then rebuild. Source jars don't have the build configuration so they are not useful for creating new binaries. Usually source jars are used to show source in a debugger or to click on a type in the IDE and see the source code for that type.

How does sbt integrate with IntelliJ?

Is there a definite doc somewhere that explains all the magic that happens behind the "Typesafe Activator" generation of "IntelliJ supported" project?
The sbt build files look absolutely monstrous, and I have no idea what and where IntelliJ looks for.
This is frustrating as working from two different PCs the scala seed project refers to different hard-coded paths.
Is there a good place to start?
Last time I checked, the typesafe activator was using SBT as the underlying build tool. When creating an intellij project it would thus use the sbt-idea plugin.
I guess a possible place to start would be that plugin's documentation.
However I think there is something else going on here. I think you have the activator installed on two different PCs and are trying to share the project between both PCs whether using version control or copying the folders.
The sbt-idea plugin will indeed write some absolute path in ideas project files (most likely the absolute paths to the sbt managed libraries in the ivy cache of your home folder) since this is required for the intellij project to work.
There should be no reason to "share" the idea project files, these should be considered computer specific and should not be checked into source control, or expected to work when copied from a random computer to another. You are expected to regenerate them for each computer the project is worked on.
If that sounds like a burden, you may want to install the Intellij scala plugin. Once installed, the sbt integration will allow you to import any sbt project even if you haven't generated the intellij support in the activator. Have a look at the features page, there is a video showing how to use the plugin.

Remote Play framework and Eclipse

I have a play framework project which run on remote server.
I'm trying to configure eclipse to work remotely on the project.
since no build is required my requirements are to be able to edit the project files from eclipse and automatically save on server, auto complete and debug.
I've installed Remote System Explorer on eclipse and setup a remote ftp connection to my server.
The play environment on my server is under
/play-2.0.2/
My project path is
/play-2.0.2/test
In RSE I clicked on /play-2.0.2/test and 'Create Remote Project'
Now in Java perspective I can browse through the project, change files and then automatically save to server.
My problem is auto completion of play framework library doesn't work well since all the reference are to /play-2.0.2/repository/...
any idea how to solve it? I tried to play with the build path but no success
Thanks!
So, I was looking into achieving the same thing myself.
The problem you are experiencing is due to the fact that the .classpath file has absolute values. While for me, besides the symlink that doesn't work between two different kinds of O.S., I thought on another two solutions:
Use sed to rewrite the classpath on the .classpath file after it's generated
Use a "classpathTransformerFactory" for the sbt eclipse command
I haven't had to deal with it (it's more of want to than whatnot) as soon as I do, I will explore the two options and post details. I just leave the answer here in case someone wants to pick up where you left.
Another thing is:
Seen that sbt picks up the libs referenced in build.sbt, downloads the jars and puts them in the ~/.ivy2 directory, if you use any of those methods to change the reference from the remote machine to the local one, you would need to make sure that the same libs are on the local ivy cache. So, just as I wrote this, another idea came to mind:
sbt eclipse or play eclipse or activator eclipse [it should be the same] on a local environment, and on the remote one, then, transfer the .project and .classpath files from the local to the remote, and see what happens (if it doesn't work, scan them for absolute and incorrect paths that might need to be changed)
Sorry for the unproved answer, still I think it's better than no answer.
Cheers