Given a JAR, namely ojdbc6.jar from Oracle, I tried to add it as an external JAR to my SBT project.
Note -I'm using this project as a sandbox, which explains the external JAR approach.
First, I copied it to my $SBT_HOME/lib directory, per this answer to use unmanaged JARs.
To determine the version of the JAR, i.e. the third argument of the libraryDependency, I ran:
$unzip ojdbc6.jar
$cat ./META-INF/MANIFEST.MF
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_51-b10 (Sun Microsystems Inc.)
Implementation-Vendor: Oracle Corporation
Implementation-Title: JDBC
Implementation-Version: 11.2.0.4.0
So, then I updated my build.sbt with:
libraryDependencies ++= Seq(
"com.oracle.jdbc" % "ojdbc6" % "11.2.0.4.0"
)
But, upon running sbt run, I see:
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: UNRESOLVED DEPENDENCIES ::
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
[warn] :: com.oracle.jdbc#ojdbc6;11.2.0.4.0: not found
[warn] ::::::::::::::::::::::::::::::::::::::::::::::
How can I add this JAR to my SBT project as an external dependency?
Related
I have downloaded sbt and to resolve the proxy maven repository errors, I have created repositories files with my-maven-proxy-releases: under ~/.sbt
When I do a sbt about, I get the below details:
"~\.sbt\preloaded\org.scala-sbt\sbt\"1.0.4"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0
[warn] No sbt.version set in project/build.properties, base directory: C:\
[info] Set current project to root (in build file:/C:/)
[info] This is sbt 1.0.4
[info] The current project is {file:/C:/}root 0.1-SNAPSHOT
[info] The current project is built against Scala 2.12.4
[info] Available Plugins: sbt.plugins.IvyPlugin, sbt.plugins.JvmPlugin, sbt.plugins.CorePlugin, sbt.plugins.JUnitXmlReportPlugin, sbt.plugins.Giter8TemplatePlugin
[info] sbt, sbt plugins, and build definitions are using Scala 2.12.4
Now, I wanted to import a project in eclipse and I googled. This is the details I found.
1. ~/.sbt/<sbt-version>/plugins/plugins.sbt
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.2.4")
sbteclipse
2. ~/.sbt/<sbt-version>/plugins/build.sbt
for scala versions and dependencies.
But I am confused on where to create the build.sbt and plugins.sbt as my folder structure is like this:
~/.sbt/1.0
~/.sbt/1.3
and I do not see ~/.sbt/1.0.4 which is displayed in sbt about.
Please guide if my understanding wrong.
First, you need to understand sbt project structure and the difference between project-local and global plugins.
As you would usually use eclipse plugin globally you should put it in
~/.sbt/<sbt-version>/plugins/plugins.sbt
(as you wrote correctly), where <sbt-version> is
0.13 for any sbt 0.13.*
1.0 for any sbt 1.*.* (this may seem unintuitive, but it's okay)
I guess, ~/.sbt/1.3 is just a typo and is meant to be ~/.sbt/0.13.
Also you normally don't put anything in ~/.sbt/<sbt-version>/plugins/build.sbt. If you need to have some global settings (including those for the global plugins), you should put them in
~/.sbt/<sbt-version>/global.sbt
Read about global settings here.
With non-global plugins and settings it's all the same minus the ~/.sbt/<sbt-version>/ part:
use <your-project>/plugins/plugins.sbt for plugins
and <your-project>/build.sbt for project settings
I am trying to publish my SBT project to mvnrepository. I am following the directions at these links:
http://www.scala-sbt.org/release/docs/Using-Sonatype.html, and
https://github.com/xerial/sbt-pack
When I add the xerial sbt-sonatype plugin to my build.sbt file:
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "1.1")
The compiler gives me the following error:
UNRESOLVED DEPENDENCIES
org.xerial.sbt#sbt-sonatype;1.1 not found
Note: Some unresolved dependencies have extra attributes. Check that these dependencies exist with the requested attributes.
[warn] org.xerial.sbt:sbt-sonatype:1.1 (scalaVersion=2.11, sbtVersion=0.13)
[warn]
[warn] Note: Unresolved dependencies path:
[warn] org.xerial.sbt:sbt-sonatype:1.1 (scalaVersion=2.11, sbtVersion=0.13) (/richstat/build.sbt#L56-57)
[warn] +- com.github.shafiquejamal:richstat_2.11:0.0.1
My SBT version is 0.13, and I am using Scala 2.11. How can I fix this? Thanks!
You have to add plugins in project/plugins.sbt, because plugins are dependencies of the meta-project, not your library/application.
Check sbt documentation: Using Plugins.
Also regarding sbt version and Scala version: there is Scala version used to compile your project's code (2.11 in your case), and there is Scala version used by sbt itself. The latter is determined by the sbt version: sbt-0.13 uses Scala 2.10, sbt-1.0 uses Scala 2.12.
P.S. I recommend you updating to sbt-1.0.2: just change the version in project/build.properties and use sbt-sonatype 2.0.
Once I run 'sbt compile' on a 2.3 play project, I can't use 'sbt compile' to compile any Play 2.2.x projects anymore. This is the error when I run sbt command.
[info] Loading project definition from /Users/macbookpro/playproject/project
[error] java.lang.NoClassDefFoundError: play/Play$
[error] Use 'last' for the full log.
Project loading failed: (r)etry, (q)uit, (l)ast, or (i)gnore?
I just had this same issue. In my case I was using Play 2.4, but it's probably the same cause. I had run activator ui in my project directory accidentally. It created a project/play-fork-run.sbt file which is for activator support, but was preventing sbt from working directly. Deleting that file cleared up the issue and I can now use sbt again.
Try updating play-fork-run.sbt
addSbtPlugin("com.typesafe.play" % "sbt-fork-run-plugin" % "2.3.8")
update to
addSbtPlugin("com.typesafe.play" % "sbt-fork-run-plugin" % "2.4.0")
Then project will be able to build.
That's interesting issue since it works for me (TM) on Mac OS X 10.9.3 with Java 7.
I downloaded the versions of Play - the latest 2.3.1 and the latest in 2.2.x stream - 2.2.3. With these two versions I've used activator (2.3.1) to create the web application and play for 2.2.3. Both worked well.
When I executed sbt compile in 2.3.1 and then 2.2.3, both commands worked fine, too. It took me some time to have all the dependencies downloaded, but at the end the results were as follows:
jacek:~/sandbox/play231-app
$ sbt compile
[info] Loading project definition from /Users/jacek/sandbox/play231-app/project
[info] Updating {file:/Users/jacek/sandbox/play231-app/project/}play231-app-build...
...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /Users/jacek/sandbox/play231-app/target/scala-2.11/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.11.1. Compiling...
[info] Compilation completed in 14.895 s
[success] Total time: 200 s, completed Jun 25, 2014 1:00:18 PM
And for 2.2.3:
jacek:~/sandbox/play223-app
$ sbt compile
[info] Loading project definition from /Users/jacek/sandbox/play223-app/project
[info] Set current project to play223-app (in build file:/Users/jacek/sandbox/play223-app/)
[info] Updating {file:/Users/jacek/sandbox/play223-app/}play223-app...
...
[info] Done updating.
[info] Compiling 5 Scala sources and 1 Java source to /Users/jacek/sandbox/play223-app/target/scala-2.10/classes...
[info] 'compiler-interface' not yet compiled for Scala 2.10.3. Compiling...
[info] Compilation completed in 19.626 s
[success] Total time: 45 s, completed Jun 25, 2014 3:15:34 PM
I'm using sbt 0.13.5 installed using homebrew.
$ sbt --version
sbt launcher version 0.13.5
$ java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) 64-Bit Server VM (build 24.60-b09, mixed mode)
Play 2.3 app is supposed to be built using activator, to ensure proper sbt configuration. Best
I had the same issue. Make sure that you are using the java-8 version.
I was using java-7, changing to java-8 fixed my problem.
Apparently the version of a transitive dependency within my sbt project has been bumped - but the direct dependency has not "caught up" with that change.
[error] (*:update) sbt.ResolveException: unresolved dependency: net.sf.py4j#py4j;0.7: not found
The updated (and only available) version is 0.8 (why did they do that is another question.. )
I have attempted to remedy this temporarily by installing the new version into my local maven repo under the old version number of 0.7 - in order to attempt to mollify the dependent library.
mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file \
-Dfile=c:\shared\py4j-0.8.1.jar -DgroupId=net.sf.py4j -DartifactId=py4j -Dversion=version=0.7 -Dpackaging=jar
However, when running sbt yet again, the same error persists. So I need another strategy for dependency resolution.
What about declaring the new version as the dependency in your build and force it (but guess you won't need it as "By default, the latest revision is selected")?
libraryDependencies += "net.sf.py4j" % "py4j" % "0.8" force()
It assumes you've your local Maven repository set up in resolvers - see Resolvers:
sbt can search your local Maven repository if you add it as a
repository:
resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository"
I'm getting an error when running SBT, which I don't know where it originates from:
[info] Set current project to root (in build file:/home/dcs/.sbt/plugins/)
[warn] Potentially incompatible versions specified:
[warn] org.scala-tools.sbt: 0.10.1, 0.10.0
The JAR file for the sbt laucher is version's 0.10.1. The error happens even outside projects, such as when running screpl.
How do I fix it?
Do you have a build.sbt in /home/dcs/.sbt/build.properties that sets a particular sbt.version?
If not, you may have a global plugin installed that requires 0.10.0 as mentioned at https://groups.google.com/forum/#!topic/simple-build-tool/YoXd0Tp_cjo/discussion. The solution there was to wipe the global .sbt directory (your /home/dcs/.sbt).