Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add com.typesafe.sbt.* dependencies to my project?

Tags:

scala

sbt

I was playing with one sbt web plugin and I wanted to reuse the code in my project. Unfortunately I wasn't even able to compile the original code in my project because of missing dependencies. These are the imports:

import com.typesafe.sbt.jse.SbtJsTask
import com.typesafe.sbt.web.{CompileProblems, LineBasedProblem}
import sbt.Keys._
import sbt._
import xsbti.Severity

None of these could be resolved. The build fails with messages like not found: object sbt. I checked the original project's build.sbt file but there was nothing relevant in libraryDependencies.

I'm using Intellij Idea and the strange thing is that when I expand External Libraries in the Project View I can find all the required stuff under SBT: sbt-and-plugins (for example object com.typesafe.sbt.web.CompileProblems is there and I can see its definition in the class file).

It seems to me that the stuff I need is a core part of sbt but somehow it won't load to the project. What am I doing wrong?

like image 431
tobik Avatar asked Mar 21 '15 23:03

tobik


1 Answers

short answer: from here

EDIT (3): answer:

use a custom ivy resolver:

resolvers += Resolver.url("SBT Plugins", url("https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/"))(Resolver.ivyStylePatterns)

libraryDependencies += ("com.typesafe.sbt" % "sbt-js-engine" % "1.0.2")
  .extra(
    sbt.mavenint.PomExtraDependencyAttributes.SbtVersionKey -> sbtBinaryVersion.value,
    sbt.mavenint.PomExtraDependencyAttributes.ScalaVersionKey -> scalaBinaryVersion.value)
  .copy(crossVersion = CrossVersion.Disabled)

how to find plugin jars:

to figure out from where exactly sbt downloads the jars, I used this (somewhat awkward) process:

first, I wanted to see where sbt stores the file localy. so:

sbt "reload plugins" "show fullClasspath" | sed s/\),\ Attributed\(/\\n/g

and I searched the output (or you can use grep).

then, I deleted the file, and executed sbt again with: reload plugins, update & last update to see the full update log. searching the log, I found a line saying where sbt got the plugin from.

like image 152
gilad hoch Avatar answered Nov 15 '22 04:11

gilad hoch