Question

When I run sbt publishLocal, the plugin will be generated in <ivy-repository>/<org>/<plugin>/<scala-version>/<sbt-version>/<plugin-version>/...

For example:

[info]  published sbt-cloudengine to /Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1/jars/sbt-cloudengine.jar

How can I exclude <scala-version> and <sbt-version> from the output path?

This path is causing resolution failure when I add the plugin as a dependency in build.sbt:

[warn] ==== Local Ivy Repository: tried
[warn]   file:///Users/hanxue/.ivy2/local/net/entrypass/sbt-cloudengine/0.2.1/sbt-cloudengine-0.2.1.pom

Plugin's build.sbt is:

sbtPlugin := true

name := "sbt-cloudengine"

organization := "net.entrypass"

version := "0.2.1"

description := "sbt plugin for managing Google Cloud Engine resources"

licenses := Seq("BSD License" -> url("https://github.com/hanxue/sbt-cloudengine/blob/master/LICENSE"))

scalacOptions := Seq("-deprecation", "-unchecked")

publishArtifact in (Compile, packageBin) := true

publishArtifact in (Test, packageBin) := false

publishArtifact in (Compile, packageDoc) := false

publishArtifact in (Compile, packageSrc) := false

publishMavenStyle := false

Update 1

This is how the plugin is referenced in a project's <rootdir>/build.sbt

resolvers += "Local Ivy Repository" at "file://"+Path.userHome.absolutePath+"/.ivy2/local"

libraryDependencies ++= Seq(
    "net.entrypass" % "sbt-cloudengine" % "0.2.1"
)

This is the directory listing

$ ls -R ~/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1/
ivys    jars    poms

/Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1//ivys:
ivy.xml     ivy.xml.md5 ivy.xml.sha1

/Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1//jars:
sbt-cloudengine.jar     sbt-cloudengine.jar.sha1
sbt-cloudengine.jar.md5

/Users/hanxue/.ivy2/local/net.entrypass/sbt-cloudengine/scala_2.10/sbt_0.13/0.2.1//poms:
sbt-cloudengine.pom     sbt-cloudengine.pom.sha1
sbt-cloudengine.pom.md5
Was it helpful?

Solution

Since you're publishing a sbt plugin and not a library, the path will correctly contain the sbt version and the scala version. Your problem comes from the fact you're trying to load the plugin using the libraryDependencies. Instead, you have to use the file project/plugins.sbt with the following inside:

addSbtPlugin("net.entrypass" % "sbt-cloudengine" % "0.2.1")

This way, sbt will search the plugin using the correct path with the help of the current scala and sbt versions.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top