question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fails to resolve pom package dependencies.

See original GitHub issue

bazel-deps fails on dependencies that are pom packages, because it tries to download non-existing jar files to compute the sha1 hash. E.g. org.monodb:casbah_2.12.0-RC1. The following test-case demonstrates this for a direct dependency with the coursier resolver. Indirect dependencies also cause a failure. The aether resolver fails as well.

diff --git a/test/scala/com/github/johnynek/bazel_deps/CoursierTest.scala b/test/scala/com/github/johnynek/bazel_deps/CoursierTest.scala
index 54ce5ec..f05eff2 100644
--- a/test/scala/com/github/johnynek/bazel_deps/CoursierTest.scala
+++ b/test/scala/com/github/johnynek/bazel_deps/CoursierTest.scala
@@ -130,6 +130,40 @@ dependencies:
     assert(nonJarNodes.size == 0)
   }

+  test("test direct pom package dependency example") {
+    val config = """
+options:
+  buildHeader: [ "load(\"@io_bazel_rules_scala//scala:scala_import.bzl\", \"scala_import\")" ]
+  languages: [ "java", "scala:2.11.8" ]
+  resolverType: "coursier"
+  resolvers:
+    - id: "mavencentral"
+      type: "default"
+      url: https://repo.maven.apache.org/maven2/
+  transitivity: runtime_deps
+  versionConflictPolicy: highest
+dependencies:
+  org.mongodb:
+    casbah_2.12.0-RC1:
+      lang: java
+      version: "3.1.1"
+"""
+
+    val model = Decoders.decodeModel(Yaml, config).right.get
+    val (graph, shas, normalized) = MakeDeps.runResolve(model, null).get
+
+    assert(graph.nodes.contains(
+      MavenCoordinate(
+        MavenGroup("org.mongodb"), MavenArtifactId("casbah_2.12.0-RC1"), Version("3.1.1"))))
+
+    // make sure no non-jar packaging shows up, until bazel-deps can handle setting those
+    // as data dependencies
+    val nonJarNodes = graph.nodes
+      .filter { mc => mc.artifact.packaging != "jar" }
+
+    assert(nonJarNodes.size == 0)
+  }
+
   test("test jar packaging w/ classifier exclude example") {
     val config =
       """

The error message reads

- test direct pom package dependency example *** FAILED *** (1 second, 216 milliseconds)
  java.lang.RuntimeException: we could not download the artifact org.mongodb:casbah_2.12.0-RC1:3.1.1 to compute the hash for digest type Sha1 with error com.github.johnynek.bazel_deps.CoursierResolver$FileErrorException: not found: https://repo.maven.apache.org/maven2/org/mongodb/casbah_2.12.0-RC1/3.1.1/casbah_2.12.0-RC1-3.1.1.jar
  at com.github.johnynek.bazel_deps.CoursierResolver$$anonfun$3.apply(CoursierResolver.scala:116)
  at com.github.johnynek.bazel_deps.CoursierResolver$$anonfun$3.apply(CoursierResolver.scala:115)
  at com.github.johnynek.bazel_deps.CoursierResolver$$anon$1$$anonfun$handleErrorWith$1$$anonfun$apply$1.apply(CoursierResolver.scala:60)
  at com.github.johnynek.bazel_deps.CoursierResolver$$anon$1$$anonfun$handleErrorWith$1$$anonfun$apply$1.apply(CoursierResolver.scala:60)
  at cats.instances.FutureInstances$$anon$1$$anonfun$handleErrorWith$1.applyOrElse(future.scala:15)
  at cats.instances.FutureInstances$$anon$1$$anonfun$handleErrorWith$1.applyOrElse(future.scala:15)
  at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
  at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345)
  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)

cc @gdeest

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
aherrmanncommented, Mar 15, 2019

I’ve tested this with https://github.com/johnynek/bazel-deps/pull/229 and the issue is resolved.

1reaction
simonyuncommented, Dec 11, 2018

Hi @aherrmann or @johnynek,

I’m trying to add http://central.maven.org/maven2/ca/uhn/hapi/fhir/hapi-fhir/3.6.0/ as a dependency and I think I’m running into this pom issue.

[main] ERROR MakeDeps - resolution and sha collection failed
java.lang.RuntimeException: we could not download the artifact ca.uhn.hapi.fhir:hapi-fhir:3.6.0 to compute the hash for digest type Sha1 with error com.github.johnynek.bazel_deps.CoursierResolver$FileErrorException: not found: http://central.maven.org/maven2/ca/uhn/hapi/fhir/hapi-fhir/3.6.0/hapi-fhir-3.6.0.jar
	at com.github.johnynek.bazel_deps.CoursierResolver$$anonfun$3.apply(CoursierResolver.scala:112)
	at com.github.johnynek.bazel_deps.CoursierResolver$$anonfun$3.apply(CoursierResolver.scala:111)
	at com.github.johnynek.bazel_deps.CoursierResolver$$anon$1$$anonfun$handleErrorWith$1$$anonfun$apply$1.apply(CoursierResolver.scala:53)
	at com.github.johnynek.bazel_deps.CoursierResolver$$anon$1$$anonfun$handleErrorWith$1$$anonfun$apply$1.apply(CoursierResolver.scala:53)
	at cats.instances.FutureInstances$$anon$1$$anonfun$handleErrorWith$1.applyOrElse(future.scala:15)
	at cats.instances.FutureInstances$$anon$1$$anonfun$handleErrorWith$1.applyOrElse(future.scala:15)
	at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:346)
	at scala.concurrent.Future$$anonfun$recoverWith$1.apply(Future.scala:345)
	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)

What should the replacements rule look like for this pom? I’m not sure if the examples in the README and project would apply here.

Sorry for the dumb q — I’m new to the project and figure someone else might benefit from an example documented here.

Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Maven Could not resolve dependencies, artifacts ...
Doing mvn dependency:tree, dependency:list, or the usual build package, will result in the same error. The error from running the 'package' build from...
Read more >
8 commands that help to resolve maven dependency ...
This command will go over your dependencyMangement and dependencies on the pom.xml and find out the duplicate dependencies used. It is ...
Read more >
Maven Error: Failed to collect dependencies - When trying ...
It's possible your dependencies are corrupted in your local maven cache, you could try forcing an update of the maven dependency cache -...
Read more >
Apache Maven Dependency Plugin – Usage
It will resolve the dependencies (including transitive dependencies) ... is undersirable and the build is failing on dependency resolution.
Read more >
Understanding dependency resolution
Dependency resolution will fail if the required artifacts are not available in any repository specified by the build, even if the local cache...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found