bazeltools / bazel-deps

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

bazel-deps dependency issue #273

Closed gmendonca closed 4 years ago

gmendonca commented 4 years ago

I'm playing with bazel-deps and rules_scala: https://github.com/bazelbuild/rules_scala/commit/7b6360915f5d41a5c591328e2f30417550461486

I'm trying to set up a dependencies.yaml with https://scalameta.org/ and I couldn't just declare:

  org.scalameta:
    scalameta:
      lang: scala
      version: "4.2.3"

For making, for example, this work:

import scala.meta.inputs.Input.VirtualFile

Instead, I had to teh following and now it's working fine:

  org.scalameta:
    inputs:
      lang: scala
      version: "4.1.6"
    scalameta:
      exports:
           - "org.scalameta:inputs"
      lang: scala
      version: "4.2.3"

Otherwise, I would get a:

error: Symbol 'type <none>.inputs.Api' is missing from the classpath.
This symbol is required by 'package scala.meta.package'.
Make sure that type Api is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'package.class' was compiled against an incompatible version of <none>.inputs.
import scala.meta._
       ^
...scala:10: error: object inputs is not a member of package meta
import scala.meta.inputs.Input.VirtualFile

I'm not sure if this is a proper way of fixing my problem, but it worked. However, I was trying to make the same thing with https://github.com/mockito/mockito-scala because of the error:

error: Symbol 'type org.mockito.MockSettings' is missing from the classpath.
This symbol is required by 'value org.mockito.MockitoEnhancer.mockSettings'.
Make sure that type MockSettings is in your classpath and check for conflicting dependencies with `-Ylog-classpath`.
A full rebuild may help if 'MockitoEnhancer.class' was compiled against an incompatible version of org.mockito.

However, when trying to do this:

  org.mockito:
    mockito-core:
      lang: java
      version: "3.2.4"
    mockito-scala:
      exports:
          - "org.mockito:mockito_core"
      lang: scala
      version: "1.10.2"
    mockito-scala:

It wont' work as Mockito Core is a Java Dependecy:

[main] ERROR MakeDeps - Could not find explicit exports named by: org.mockito:mockito-scala_2.11: org.mockito:mockito_core

In both cases, I'd expect to just declare the dependency without the inner dependencies. Am I doing something wrong or is this really a bug?

johnynek commented 4 years ago

This is a difference with bazel (at least the scala rules) and most JVM build: we require explicitly naming all the jars you need and we don’t include transitive classpath at compile time (only runtime).

There is a “deps + 1” mode in the scala rules that add one layer of transitive deps at compile time which solve most instances of this.

About the bazel-deps issue: note you wrote mockitocore but the artifact name is mockito-core. Can you try with a - not an ?

gmendonca commented 4 years ago

Annnnnnnd of course it was a typo. 🤦‍♂

About the bazel-deps issue: note you wrote mockitocore but the artifact name is mockito-core. Can you try with a - not an ?

Ok, at least this was useful for knowing I was in the right direction.

This is a difference with bazel (at least the scala rules) and most JVM build: we require explicitly naming all the jars you need and we don’t include transitive classpath at compile time (only runtime).

Will have a look on this 👍

There is a “deps + 1” mode in the scala rules that add one layer of transitive deps at compile time which solve most instances of this.

Thanks for the answers :)

gmendonca commented 4 years ago

Closing as not really an issue.