Skip to content

using maven_jar extension in windows and having ubuntu shell installed seems to be broken #7781

Closed as not planned

Description

@MarkaRagnos0815

Description of the problem / feature request:

using maven_jar extension in windows and having ubuntu shell installed seems to be broken

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

  • install ubuntu 18.04 bash in windows (you can get it from MS store)
  • load maven_jar plugin -> load("@bazel_tools//tools/build_defs/repo:maven_rules.bzl", "maven_jar"")
  • add any external maven dependency (like apache commons lang 3) via maven_jar rule to workspace
  • setup a java library having the maven jar as dep
  • build the project
  • see errors (see additional information)

What operating system are you running Bazel on?

Windows 10

What's the output of bazel info release?

release 0.23.2

Have you found anything relevant by searching the web?

No.

Any other information, logs, or outputs that you want to share?

there seems to be a lot of different errors

  1. on my system, it complains about missing maven dependency plugin. I need to use mvn and download it manually and inside ubuntu shell (or point the to the same local repository).
  2. after downloading the dependency plugin it downloads all maven artifacts but fails to open any jar because the created link seems to be broken
  3. inside the external jar directory the creates a folder structure starting with drive letter and an unprintable character like (because ":" is forbidden in windows).
  4. removing the ubuntu shell leads to some other issue because it seems to ignore BAZEL_SH variable (which points in my case to msys2 bash)
    either usage BAZEL_SH variable is broken or BAZEL_SH isn't used anymore.

Activity

  1. jin commented on Mar 20, 2019

    @jin
    Member

    We have just released a new approach to resolve Maven deps that doesn't depend on any system dependencies. It also works on Windows, please try it out: https://github.com/bazelbuild/rules_jvm_external/

    cc @dkelmer

  2. added
    team-ExternalDeps
    untriaged
    on Mar 21, 2019
  3. added
    P3
    and removed
    untriaged
    on Mar 21, 2019
  4. MarkaRagnos0815 commented on Mar 25, 2019

    @MarkaRagnos0815
    Author

    thanks for your reply, but the extension needs to have plain user/password which is unacceptable to me. the maven jar rule uses .m2 settings and security settings

  5. jin commented on Mar 25, 2019

    @jin
    Member
  6. MarkaRagnos0815 commented on Mar 25, 2019

    @MarkaRagnos0815
    Author

    thanks, seems to be a temporary solution. i don't like the idea of resolving maven transitive dependencies. My question is: will someone from bazel dev group fix the issue with maven extension?

    btw. the original maven_jar rule works so far until I need to access our internal repository because it seems not to support authentication.

  7. dkelmer commented on Mar 26, 2019

    @dkelmer
    Contributor

    hey @MarkaRagnos0815! If you don't like the idea of resolving transitive maven dependencies then the recommendation is to use the jvm_import_external family of repository rules, in particular, the maven specific variant. These will eventually become the only option, as the native maven_jar rule is being deprecated. Right now the jvm_import_external rules do not support authentication and so the native rule will not be deprecated until they do. The jvm_import_external rules use Bazel's http downloader to download the jars, and adding authentication support to the downloader is tracked in this bug. The solution will be a more generic authentication mechanism (i.e. not reading the .m2 settings file), but if you have any specific requirements or requests, please comment on that bug! Or if you have any questions about the jvm_maven_import_external rule

  8. dkelmer commented on Mar 26, 2019

    @dkelmer
    Contributor

    I just reread your report and noticed you're not using the native maven_jar rule, but rather the other starlark maven_jar rule. However, everything I said above applies to that rule as well. It will no longer be supported once jvm_maven_import_external reaches feature parity

  9. MarkaRagnos0815 commented on Mar 27, 2019

    @MarkaRagnos0815
    Author

    @dkelmer thanks for your answer:

    • yes i am using starlark maven_jar, native maven_jar rule works as expected unless you need authentication
    • ok, using jvm_import_external may help, but I need authentication without having a user/password pair somewhere plain (not sure how they will implement this)
    • I am not sure, but my issue seems to have an second issue which I am not sure about. it seems bazel is not using the BAZEL_SH env variable und using just "bash" as command. As long as I have an ubuntu shell in my windows it will use this shell and not the one provided in the BAZEL_SH var.
  10. dkelmer commented on Mar 27, 2019

    @dkelmer
    Contributor

    If the native maven_jar rule is working for you, then you could use it in conjunction with the maven_server rule to get the authentication.

    Of course you would eventually need to migrate to the jvm_import_external rules, and I apologize for the churn, but we are actively trying to get these rules into a robust and user friendly state asap :)

  11. MarkaRagnos0815 commented on Mar 29, 2019

    @MarkaRagnos0815
    Author

    maven_server rule does not work with native maven_jar rule or at least in the way I am using maven. I have an settings.xml and settings_security.xml according to http://maven.apache.org/guides/mini/guide-encryption.html. It fails and maven server log shows a authentication error in log

    Edit:
    to be a bit more clear:
    maven_server( name = "server", url = "http://<ip>/nexus/content/repositories/shared", );
    produces:
    Could not transfer artifact <> from/to <> (http://<ip>/nexus/content/repositories/shared): NullPointerException
    server side produces error is 401

    changing the url, like removing "shared", produces a not found error

  12. added
    team-OSS
    on Jun 15, 2020
  13. removed
    team-OSS
    on Nov 29, 2021
  14. added
    stale
    on Feb 16, 2023
  15. sgowroji commented on Feb 16, 2023

    @sgowroji
    Member

    Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3staleteam-ExternalDepstype: bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions