I'm creating a sbt plugin that requires another scalaj library. I publish the library locally and try to run/test it with another project.
However, when I test the plugin with another project, it shows java.lang.NoClassDefFoundError: scalaj/http/Http$
Here's my code..
plugin build.sbt
name := "hello-sbt-plugin"
version := "1.0"
scalaVersion := "2.10.4"
scalacOptions ++= Seq("-deprecation", "-feature")
organization := "com.abc.dev"
sbtPlugin := true
publishMavenStyle := false
libraryDependencies += "org.scalaj" %% "scalaj-http" % "0.3.16"
initialCommands in console := "import com.typesafe.sbt.rss._"
plugin project/plugins.sbt
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.4")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "0.8.1")
libraryDependencies <+= (sbtVersion) { sv =>
"org.scala-sbt" % "scripted-plugin" % sv
}
// Scripted plugin needs to declare this as a dependency
libraryDependencies += "jline" % "jline" % "2.11"
libraryDependencies += "org.scalaj" %% "scalaj-http" % "0.3.16"
plugin plugin.scala
package com.abc.dev
import sbt._
import Keys._
import plugins._
import sbt.plugins.JvmPlugin
import scalaj.http.Http
import scalaj.http.HttpOptions
object HelloPlugin extends AutoPlugin {
object autoImport {
val rssList = settingKey[Map[String, String]]("The list of RSS urls to update.")
val gatlingses = inputKey[Unit]("Prints RSS")
}
import autoImport._
override def trigger: PluginTrigger = allRequirements
override def requires = JvmPlugin
override def projectSettings: Seq[Setting[_]] = Seq(
gatlingsesSetting
)
def gatlingsesSetting: Setting[_] = gatlingses := {
/*Things*/
}
}
Below is the code of testing project.
build.sbt
name := "sbt-tester"
version := "1.0"
scalaVersion := "2.12.1"
lazy val myProject = (project in file(".")).enablePlugins(HelloPlugin)
libraryDependencies += "org.apache.httpcomponents" % "httpclient" % "4.5.3"
libraryDependencies += "org.scalaj" %% "scalaj-http" % "2.3.0"
rssList := Map(
"key" -> "value",
)
project/plugin.sbt
addSbtPlugin("com.abc.dev" % "hello-sbt-plugin" % "1.0")