Search code examples
sbtbintraysbt-plugin

Sbt plugin publication and resolution on bintray, different paths (sbt-bintray plugin)


I have some troubles to publish/use a custom sbt plugin from bintray. I'm able to publish sbt-plugin on bintray but when I try to use it the resolver uses another path.

I have followed the official guide but adapted it to the latest version of the plugin, I have this build.sbt into my plugin :

lazy val commons = Seq(
  organization in ThisBuild := "me.my.app",
  version in ThisBuild := "0.1.0"
)

lazy val root = (project in file(".")).
  settings(commons ++ BintrayPlugin.bintrayPublishSettings: _*).
  settings(
    sbtPlugin := true,
    name := "sbt-plugin",
    description := "Share configuration and plugins accros app projects",
    bintrayOmitLicense := true,
    publishMavenStyle := false,
    bintrayRepository := "sbt-plugins",
    bintrayOrganization := None
  ).
  settings(
    addSbtPlugin("me.lessis" % "bintray-sbt" % "0.3.0"),
    addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0"),
    addSbtPlugin("org.scalastyle" % "scalastyle-sbt-plugin" % "0.8.0")
  )

The sbt-plugin> publish task complete successfully and publish my plugin into me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar

Then I add addSbtPlugin("me.my.app" % "sbt-plugin" % "0.1.0") to my-project\project\plugins.sbt and reload it. But he fail with

[warn] ==== bintray-{organization}-{repo}: tried
[warn]   https://dl.bintray.com/{organization}/sbt-plugins/me/my/app/sbt-plugin_2.10_0.13/0.1.0/sbt-plugin-0.1.0.pom
...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: me.my.app#sbt-plugin;0.1.0: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn]  Note: Some unresolved dependencies have extra attributes.  Check that these dependencies exist with the requested attributes.
[warn]      me.my.app:sbt-plugin:0.1.0 (scalaVersion=2.10, sbtVersion=0.13)
[warn]
[warn]  Note: Unresolved dependencies path:
[warn]      me.my.app:sbt-plugin:0.1.0 (scalaVersion=2.10, sbtVersion=0.13) (/home/me/Projects/app/app-web/project/plugins.sbt#L7-8)
[warn]        +- default:app-web-build:0.1-SNAPSHOT (scalaVersion=2.10, sbtVersion=0.13)
sbt.ResolveException: unresolved dependency: me.my.app#sbt-plugin;0.1.0: not found
 at sbt.IvyActions$.sbt$IvyActions$$resolve(IvyActions.scala:313)
[error] (*:update) sbt.ResolveException: unresolved dependency: me.my.app#sbt-plugin;0.1.0: not found

As you can see the URL used to download the plugin is not the same as the one where the plugin has been published. (with publishLocal my plugin is published under the same path but resolved successfully.

  • Local : me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
  • Upload : me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
  • Downlad: me/my/app/sbt-plugin_2.10_0.13/0.1.0/sbt-plugin-0.1.0.pom

I have tried with or without publishMavenStyle := false and with Resolver.bintrayRepo and Resolver.bintrayIvyRepo but without success.

I will be missing something but I have to admit that I feel a bit lost. So what are the missing configuration that should align the upload and download paths ?

Details :

  • publishMavenStyle := false -> me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar
  • publishMavenStyle := true -> me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/jars/sbt-plugin.jar

  • Resolver.bintrayRepo -> me/my/app/sbt-plugin_2.10_0.13/0.1.0/sbt-plugin-0.1.0.pom

  • Resolver.bintrayIvyRepo -> me.my.app/sbt-plugin/scala_2.10/sbt_0.13/0.1.0/ivys/ivy.xml

Solution

  • The publication part was ok. The only problem was on the resolution side.

    I had to add a custom resolver with explicit ivyStylePatterns resolver into my-project\build.sbt:

    resolvers += Resolver.url("me @ bintray", url("https://dl.bintray.com/{my-bintray-account}/{my-bintray-generic-repo}"))(Resolver.ivyStylePatterns)