Re: How to add a Jar to classpath? The jar is installed locally somewhere on the system.

284 views
Skip to first unread message
Message has been deleted

Eric Bowman

unread,
Sep 17, 2012, 9:24:40 PM9/17/12
to simple-b...@googlegroups.com
Hi Alexander,


If you have a build.sbt file, it's usually just a one-liner.

Suppose your project has a directory "libs", and you've put the jar or jars that are "unmanaged" in that directory.

Then just this line, separated by a blank line above & below, should do it:
unmanagedBase <<= baseDirectory { base => base / "libs" }

This will add all the jars in the "libs" directory to the compiler classpath.

Good luck,
Eric


Alexander Obuschenko

unread,
Sep 18, 2012, 5:10:30 AM9/18/12
to simple-b...@googlegroups.com
Eric, thanks for the reply, but unfortunately this line of code in build.sbt did change nothing:
unmanagedBase <<= baseDirectory { base => base / "libs" }
Also i found that inspect unmanaged-base returns path set to "lib" (relative to project root, i.e. project folder contains README lib project src target). And this lib folder works! All jars placed in the "lib" folder are added to the classpath and the project is compiled. But the mentioned code is not working properly :-/

nafg

unread,
Sep 21, 2012, 5:04:47 PM9/21/12
to simple-b...@googlegroups.com
It says there:

Manually managing dependencies involves copying any jars that you want to use to the libdirectory. sbt will put these jars on the classpath during compilation, testing, running, and when using the interpreter. You are responsible for adding, removing, updating, and otherwise managing the jars in this directory. No modifications to your project definition are required to use this method unless you would like to change the location of the directory you store the jars in.


nafg

unread,
Sep 21, 2012, 5:05:52 PM9/21/12
to simple-b...@googlegroups.com
Also, there's this, which may work with a file: url (haven't tried):

Explicit URL

If your project requires a dependency that is not present in a repository, a direct URL to its jar can be specified as follows:

libraryDependencies += "slinky" % "slinky" % "2.1" from "http://slinky2.googlecode.com/svn/artifacts/2.1/slinky.jar"

The URL is only used as a fallback if the dependency cannot be found through the configured repositories. Also, the explicit URL is not included in published metadata (that is, the pom or ivy.xml).



Reply all
Reply to author
Forward
0 new messages