bazeltools / bazel-deps

Generate bazel dependencies for maven artifacts
MIT License
250 stars 122 forks source link

bazel run //:parse generate fails with local dependency #279

Closed gmendonca closed 4 years ago

gmendonca commented 4 years ago

I did a simple project with sbt and a build.sbt as follows:

lazy val scala212 = "2.12.10"
lazy val scala211 = "2.11.12"
lazy val supportedScalaVersions = List(scala212, scala211)

organization := "com.some.organization"
name := "some-project"
version := "0.0.1"
scalaVersion := scala211

lazy val root = (project in file("."))
  .settings(crossScalaVersions := supportedScalaVersions)

The sbt version I'm using is 1.3.7

After publishing it locally with sbt +publishLocal, when I run bazel run //:parse generate -- --repo-root "$MY_PROJ_DIR" --sha-file 3rdparty/workspace.bzl --deps dependencies.yaml with dependencies.yaml importing it, I get a:

[ForkJoinPool-1-worker-1] WARN bazel_deps.CoursierResolver - Failed to process Dependency(com.some.organization:some-project_2.11, 0.0.1, Configuration(default(compile)), Set(), Publication(, Type(jar), Extension(), Classifier()), false, true)
[main] ERROR MakeDeps - resolution and sha collection failed
java.lang.RuntimeException: no artifacts for com.some.organization:some-project_2.11:0.0.1 found
    at com.github.johnynek.bazel_deps.CoursierResolver$$anonfun$com$github$johnynek$bazel_deps$CoursierResolver$$lookup$1$1$$anonfun$apply$7$$anonfun$apply$9.apply(CoursierResolver.scala:214)
    at com.github.johnynek.bazel_deps.CoursierResolver$$anonfun$com$github$johnynek$bazel_deps$CoursierResolver$$lookup$1$1$$anonfun$apply$7$$anonfun$apply$9.apply(CoursierResolver.scala:212)
    at coursier.util.Task$$anonfun$flatMap$extension$1$$anonfun$apply$3.apply(Task.scala:14)
    at coursier.util.Task$$anonfun$flatMap$extension$1$$anonfun$apply$3.apply(Task.scala:14)
    at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:253)
    at scala.concurrent.Future$$anonfun$flatMap$1.apply(Future.scala:251)
    at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:36)
    at scala.concurrent.impl.ExecutionContextImpl$AdaptedForkJoinTask.exec(ExecutionContextImpl.scala:121)
    at scala.concurrent.forkjoin.ForkJoinTask.doExec(ForkJoinTask.java:260)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.pollAndExecAll(ForkJoinPool.java:1253)
    at scala.concurrent.forkjoin.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1346)
    at scala.concurrent.forkjoin.ForkJoinPool.runWorker(ForkJoinPool.java:1979)
    at scala.concurrent.forkjoin.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:107)

However, when I check with coursier CLI, works just fine: coursier resolve com.some.organization:some-project_2.11:0.0.1

Maybe I'm missing something, but I decided to report as I couldn't make it work yet.

johnynek commented 4 years ago

This tool does not consult the local ivy or maven cache. Since bazel is focused on reproducibility that is out of scope here.

You can use replacements and a custom scala_import although we don’t have a documentation of that kind of set up. rules_scala has documentation on scala_import and replacements is documented in the readme of this project.

gmendonca commented 4 years ago

This tool does not consult the local ivy or maven cache. Since bazel is focused on reproducibility that is out of scope here.

So, I was indeed missing something. Thanks for the explanation. I'll see if I can still test without the need to publish it.

Closing as not really an issue.