score:33
In the IntelliJ Idea window of your project, got to File >> Project structure >> Libraries. After clicking that Libraries option, two panes will show up. At the top of the left-most pane, click the green "+" button.
score:0
Create a lib directory in your project root path, paste your JARs in there, run sbt reload, close the project and open it again. Works for me in IntelliJ 2018.2.4 and SBT 1.0
score:0
Go to File -> Project Structure -> Modules
Select module in left pane and go to Dependencies tab
Click + to add JARs or directories
score:0
One way we can do is by adding jar explicitly in the Intellij but the problem with this approach is every time we build the project we need to add it again.
First way to do is :
In Intellij Idea:
File > Project Structure > Libraries
Another way is to publish the jar in local
Step 1 : Place the jar in any accessible folder.
Step 2 Create a build.sbt file which contains the detail of the jar.
Step 3 Open cmd to that path and execute command sbt publishLocal.
Step 4 Build your code and you would observe that you are able to access the classes belong to that jar.
build.sbt would look something like this:
organization := "com.abc.core"
name := "abc-test-logging"
version := "1.0-SNAPSHOT"
crossPaths := false
packageBin in Compile := file(s"${name.value}-${version.value}.jar")
score:2
For a multi-module SBT project (Intellij 2017.3.4, Scala 12.2.4, sbt 1.1.1), the accepted solution only worked until restart or a project refresh. Indeed, "Project Settings-> Modules -> Dependencies", then "+" and "JARs or directories" gives a warning "Module X is imported from Sbt. Any changes made in its configuration may be lost after reimporting".
Possible workaround:
The suggestion by @zero worked for me as follows:
Put the JAR(s) into the project's
lib
directory.In
build.sbt
, insidelazy var baseSettings = Seq( ... )
add the lineunmanagedJars in Compile += file("YourPath/ProjectBla/lib/controlsfx-8.40.14.jar")
.Still no luck? In the SBT tool window, in a module's sbt settings under unmanagedBase, unmanagedSourceDirectories (and the like) try calling the pop-up commands "Show value" and "Inspect" a few times. Somehow, it might work.
From Eugene Yokota's answer to How can I add unmanaged JARs in sbt-assembly to the final fat JAR? another option (which I didn't try) is to add an individual
lib
directory to each required module.
Hopefully, these steps will solve the problem or at least help debugging.
score:6
In Intellij Idea:
- File > Project Structure > Libraries
In Netbeans:
- File > Project Properties > Libraries
In Eclipse:
- Right click the project > Properties > Java Build Path > Libraries
score:10
Just Declare this in build.sbt
unmanagedJars in Compile += file(Path.userHome+"/Your-Jar-Path/Full-Jar-Name.jar")
and required jar will appear in External Library>unmanaged-jars>Full-Jar-Name.jar. This will also change if the jar file(in the provided path) is modified.
score:14
The better way to do it is to add your unmanaged dependencies to your build.sbt and refrain from leaving part of your dependency management to your IDE.
Refer to http://www.scala-sbt.org/release/docs/Library-Management.html for details on how to define your unmanagedBase and unmanagedJars tasks.
Source: stackoverflow.com
Related Query
- How to add Jar libraries to an IntelliJ Idea SBT Scala project?
- How to Point Intellij at SBT Libraries for Scala Project
- How to set up a scala project in IntelliJ IDEA that uses git libraries
- IntelliJ IDEA 13: new Scala SBT project hasn't src directory structure generated
- How to run tests on every code change in IntelliJ IDEA from Scala sbt project?
- How to set up an IntelliJ Idea Scala project to recognize local Ivy2 cache?
- Intellij Idea add Scala support to existing Java project
- How to synchronize Intellij and sbt builds for a scala project
- IntelliJ IDEA doesn't load Lift libraries from a SBT project
- How to debug a Scala SBT project in IntelliJ 13?
- How to avoid adding a 'root' scala sbt project in IntelliJ when defining github dependencies?
- How to add other Scala project as dependencies in IntelliJ (Scala Plugin)
- Scala code compiles through command-line sbt but fails when compiled through Intellij Idea - how set up Intellij to use external sbt?
- How to add external Excel file in Scala Jar in Intellij
- How to add keycloak-admin-client-api in sbt scala project
- How to attach sources to scala sbt project at Intellij Idea?
- How to build Android project with Scala sources in IntelliJ IDEA (Community Edition)?
- How to mute Intellij IDEA after sbt project is imported
- How to run an SBT project in IntelliJ Idea 2016.2.4?
- How to create a Scala executable jar file that is built with Maven, and has log4j included, using IntelliJ IDEA IDE
- sbt version and scala version. project configuration for intellij idea with sbt-idea plugin
- How can I use scala sources from a different location in a sbt project and also make it work with IntelliJ IDEA?
- How to add external jar files to a spark scala project
- "Need to install JAI Image I/O package." error when using tess4j in IntelliJ IDEA Scala SBT project
- How to build a jar file out of github project in sbt to be used in a scala program
- How to add a scala dependency to a Java project in intelliJ that use maven
- importing sbt scala project to intellij idea takes long time
- How to create SBT project with IntelliJ Idea?
- How to build an Uber JAR (Fat JAR) using SBT within IntelliJ IDEA?
- How to use Scala in IntelliJ IDEA (or: why is it so difficult to get a working IDE for Scala)?
More Query from same tag
- Scala's Nothing vs partial unification
- How are co- and contra-variance used in designing business applications?
- How to handle different JSON schemas and dispatch hem to be handled by the right parser?
- Phantom-DSL cassandra with frozen type
- Adding java classes to sbt assembly
- Jackson Scala JSON Deserialization to case classes
- Why do I need an extra asInstanceOf
- ScalaIDE 3.0.3 gives error with scala 2.9.x
- Method returning Future[Unit] containing nested future that is expected to complete
- Monotonically increasing ID based on column
- converting Akka's Future[A] to Future[Either[Exception,A]]
- Slick 3.0.3 error: could not find implicit value for parameter rconv
- How do I write a JSON Format for an object in the Java library that doesn't have an apply method?
- Only bind part of the Form mappings from request
- How to recursively build up a json lens
- spark filter hbase to get samples
- Python style decorator in Scala
- Pattern matching after update with ReactiveMongo
- Access type parameters of generic parameter scala
- How to send a KeyValue list to Kafka?
- Play 2.4 WebSocket Actor doesn't respond
- How do I refer to a variable while assigning a value to it, whilst retaining immutability?
- Gatlin test with multiple urls
- Scala getLines() with yield not as I expect
- Load logback configurations based on environment with Scala Play2.5
- Can I apply filters server-side for finagle-thrift?
- Validation error while trying to parse a json array to List[Object] in Scala
- Swagger, how to add file upload
- Spark: scala Any conversion
- java.io.IOException: Could not locate executable null\bin\winutils.exe in the Hadoop binaries. spark Eclipse on windows 7