sbt / sbt

sbt, the interactive build tool
https://scala-sbt.org
Apache License 2.0
4.8k stars 936 forks source link

Cannot resolve sbt plugin from local ivy repository #4015

Closed jastice closed 5 years ago

jastice commented 6 years ago

steps

I am trying to publish an sbt plugin to a local file repo. In the plugin's build.sbt I have:

publishTo := Some(Resolver.file("localtrix", file("/Users/jast/repo/localtrix")))

I run the publish task and it gets published fine to /Users/jast/repo/localtrix/org/me/sbt-plugin_2.12_1.0/1.2.3

In another project, I want to resolve this plugin. in project/plugins.sbt I have:

resolvers += Resolver.file("localtrix", file("/Users/jast/repo/localtrix"))
addSbtPlugin("org.me" % "sbt-plugin" % "1.2.3")

problem

I try to run sbt in the this project and I get:

[info] Updating ProjectRef(uri("file:/Users/jast/playspace/untitled38/project/"), "untitled38-build")...
[warn]  module not found: org.me#sbt-plugin;1.2.3
[warn] ==== typesafe-ivy-releases: tried
[warn]   https://repo.typesafe.com/typesafe/ivy-releases/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml
[warn] ==== sbt-plugin-releases: tried
[warn]   https://repo.scala-sbt.org/scalasbt/sbt-plugin-releases/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml/2017.2+4-3037ba82+20180314-1919/ivys/ivy.xml
[warn] ==== local: tried
[warn]   /Users/jast/.ivy2/local/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml
[warn] ==== public: tried
[warn]   https://repo1.maven.org/maven2/org/me/sbt-plugin_2.12_1.0/1.2.3/sbt-plugin-1.2.3.pom
[warn] ==== local-preloaded-ivy: tried
[warn]   /Users/jast/.sbt/preloaded/org.me/sbt-plugin/scala_2.12/sbt_1.0/1.2.3/ivys/ivy.xml
[warn] ==== local-preloaded: tried
[warn]   file:////Users/jast/.sbt/preloaded/org/me/sbt-plugin_2.12_1.0/1.2.3/sbt-plugin-1.2.3.pom
[warn] ==== localtrix: tried
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.me#sbt-plugin;1.2.3: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

The sbt plugin fails to resolve. Of note: it reports localtrix: tried but does not actually report the url it tried.

Relevant code in ivy's reporter: https://github.com/sbt/ivy/blob/2.3.x-sbt/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java#L796-L800

expectation

The sbt plugin resolves

notes

sbt version: insert sbt version

dwijnand commented 6 years ago

perhaps it works if you publish and resolve from a local file ivy repository?

jastice commented 6 years ago

What worked: in plugin: publishMavenstyle := true in project: `resolvers += "localtrix" at "file:///Users/jast/repo/localtrix"

dwijnand commented 6 years ago

(semi-related https://github.com/sbt/librarymanagement/issues/224)

jastice commented 6 years ago

Furthermore, publishing and resolving with explicit Resolver.ivyStylePatterns works:

publishTo := Some(Resolver.file("localtrix", file("/Users/jast/repo/localtrix"))(Resolver.ivyStylePatterns))
resolvers += Resolver.file("localtrix", file("/Users/jast/repo/localtrix"))(Resolver.ivyStylePatterns)
dwijnand commented 6 years ago

so this is exactly sbt/librarymanagement#224

if you publish maven style (which is the default) then Resolver.file doesn't work but "localtrix" at "file:///.." (aka MavenRepository) does.

eed3si9n commented 5 years ago

if you publish maven style (which is the default) then Resolver.file doesn't work but "localtrix" at "file:///.." (aka `MavenRepository) does.

ok so I am closing this.