How to make Intellij follow sbt GitHub dependencies? - scala

I managed how to add github dependencies to my sbt project following the instructions in this link.
However, Intellij could not find the github dependencies.

After om-nom-nom sugestion, only Scala plugin is needed:
Installing the Scala plugin from a fresh idea install
Import project from external model -> SBT project
? use auto import ?
Register "unregistered Vcs root"
Set module SDK with your JDK folder and adopt it for the project
Write a main file and press ctrl+shift+F10
The step 4 is important because you won't need to keep the working copies of the sub-projects anymore.
Idea creates them inside ~/.IdeaIC13 folder.
This link talks about multi-root Projects and synchronous branch control.
ps. the SBT plugin somehow was disabled and ideia became cofused about a subproject with a (nested) subsubproject.

Related

IntelliJ-Scala - how can I import Scala-SBT project from Github to directly into IntelliJ

I am importing my Scala-SBT projects from Github. I select
New
Project from Version Controller
GitHub
Giving my project .git url and click clone.
After it import,
IntelliJ not considering as Scala-SBT project.
I saw,
Settings -> Build, Execution and Deployement -> SBT
I did not find my project, it was nil in Linked SBT Projects.
How can I import as Scala SBT project directly from Github.
is It mandatory that I should chack-out local and import as Scala SBT project as two steps?
or
can I do direct import from github.
You do everything as you said File | New | Project from Version Controller | GitHub ...
Now at this point you have bare project.
To show IntelliJ that this is SBT project open build.sbt file and you will see yellow alert with suggestion to Import Project press on it. After indexing it will be recognized as SBT one.
I found there is no direct way to import Scala-SBT project from version control system unless your source already have IntelliJ project setup files (.idea folder in simple words). So:
You should clone to your local.
Import as Scala SBT project in IntelliJ.
Note: you will import Scala-SBT project into IntelliJ, but it won't consider as SBT project it treats a Java project.
I would be interested in any solution for this.

Scala-SBT - How can I remove all 'class not found' issues in imported project in IntelliJ IDEA

I am new to IntelliJ IDEA. I am importing my Scala-SBT project for the first time.
After import, it showing lot of Class Not Found problems. But in IntelliJ SBT console, clean, update, compile everything working fine. Because it is not a startup project, it is running project, lot of other people are already working.
Now, clone seperately and imported as local Scala SBT project still it not recognising my dependenty jar. Still, Class Not Found in all classes.
But I don't know, how to make automatically consider my dependencies from by build.sbt.
Also should I need to import in project settings as third party jars?
Check if there is no errors during import. If they are disable "download source" checkbox in project import settings.
You can always reimport project in IntelliJ from SBT panel
I found solution finally,
I imported as Scala SBT project and i selected build.sbt file in the root folder instead of project root folder.
Downloaded exact Scala version of my project and put in project settings.
Refresh Project - It downloaded all needed jars and took 15mins to complete.
Anyway, All class not found errors thank God.

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.

How to use existing Intellij projects as a I move forward with SBT?

Novice SBT question - Now that I've started with some basic SBT tutorials, I'd like to start using SBT build files (within Intellij) a lot more often. However, there's a couple of problems with this :
1) Existing projects that I currently publish to a jar, and later import into other projects... how do I publish this jar file to my local repository? SBT publish-local doesn't seem to fit my situation, because the project was made in Intellij and is not (yet) an SBT project.
2) Suppose I do convert the project to an SBT build setup (and then import it into Intellij).. how do I configure Intellij to to publish-local (update) each time I build the project? I do not see many configurable settings around SBT within the new Intellij SBT support.
Using Intellij 13 and SBT 0.13.1
Thanks!
to get you started up quickly on using SBT to drive Idea, have a look at my template project called skeleton
It supports most of the basic tasks you'd want to do.
To publish to your repository, use the publish task.
hope that helps!
For publishing, you simply use the publish action:
To specify the repository, assign a repository to publishTo and optionally set the publishing style. For example, to upload to Nexus:
publishTo := Some("Sonatype Snapshots Nexus" at "https://oss.sonatype.org/content/repositories/snapshots")
As for your second question, despite being a JetBrains fanboy, I have found SBT integration quite disappointing. For one thing, as the JetBrains documentation states itself, you need two plugins: their plugin and sbt-idea. You use sbt-idea to synchronize the IDEA module structure with the SBT build, and you use JetBrains' idea-sbt-plugin to execute SBT tasks in the "Before Launch" action in Run Configurations.
It sounds like you want to do an "install" on every build, so "Before Launch" action support isn't useful. I would suggest writing your own custom SBT task to install on build and using the Command Line Tools Console to execute that task with SBT as if from the command line. I know; that indirection is annoying.
Bear in mind one more thing. I have found numerous bugs with idea-sbt-plugin. At least on Mac. JetBrains told me the next version will be much better, and you can see for yourself with the next EAP version.
I certainly welcome others who have managed to have more success than I have to chime in.

How to import playframework sources into eclipse?

After cloning playframework from github and importing java sources into eclipse there are a lot of build errors shown.
Running the goals from ant file in eclipse works fine as well as building from cli directly.
How can i resolve these errors in eclipse?
I took the following steps to import play into eclipse:
new -> other -> Java>New Java Project from Existing Ant Buildfile
select play/framework/build.xml
checking the 'Link to the build file in the file system' checkbox
Finish
The errors result from differences between eclipse internal build path
and classpath available for ant at runtime.
First Eclipse only imports rt.jar from system path. This may lead to
missing dependecies in javax.net packages (e.g.
javax.net.ssl.SSLException), which is located in jsse.jar. To fix, right
click on project->Properties->Java Build Path->Libraries->Add Library->
JRE System Library.
Second, play has dependencies to classes from ant runtime. To fix, right
click on project->Properties->Java Build Path->Libraries->Add
Library->User Library
There you have to add a new User Library (perhaps call it ANT) and add
all ant-jars from your ant installation (/usr/share/ant/lib/ worked for
me). Then add this user library to play projects build path.
From the Oliver's answer, I had also to add the jce.jar lib in my classpath.
It comes from the $JDK/jre/lib directory.