rules_jvm_external
rules_jvm_external copied to clipboard
Is there a way to use a local maven repo
Basically, I'd like to replicate what is possible on Gradle via
repositories {
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
}
So far I've tried
maven_install(
artifacts = [
"com.facebook.react:react-native:0.63.3",
],
repositories = [
"file:///Users/bruno/repo/node_modules/react-native/android",
],
)
and
android_library(
name = "main_application",
srcs = [
"MainActivity.java",
"MainApplication.java",
],
manifest = "AndroidManifest.xml",
resource_files = glob(["res/**"]),
deps = [
"@maven//:com_facebook_react_react_native",
],
)
but it doesn't seem to be working, and I am getting this error
(14:46:46) ERROR: [...] depends on @maven//:com_facebook_react_react_native in repository @maven which failed to fetch. no such package '@maven//': Only artifacts downloaded over http(s) are supported: com.facebook.react:react-native:0.63.3
I'm not sure coursier has a way to add local maven repositories for fetching artifacts. They added a m2local
option with https://github.com/coursier/coursier/issues/667 but that does not allow arbitrary directories to be maven repositories.
I see, thanks for the input. This is what I have so far.
I've copied the local maven repo content under ~/.m2/repository
, so that I have this directory structure:
and then added the dependency as
load("@rules_jvm_external//:specs.bzl", "maven")
maven_install(
artifacts = [
"com.facebook.react:react-native:0.63.3",
],
use_unsafe_shared_cache = True,
repositories = [
maven.repository(
"file:///Users/bruno/.m2/repository",
),
...
],
)
which errors out as
(11:27:18) ERROR: An error occurred during the fetch of repository 'maven':
Traceback (most recent call last):
File "/private/var/tmp/_bazel_bruno/d1d8f433d513598595adb098f4928314/external/rules_jvm_external/coursier.bzl", line 784, column 66, in _coursier_fetch_impl
artifact.update({"file": _relativize_and_symlink_file(repository_ctx, artifact["file"])})
File "/private/var/tmp/_bazel_bruno/d1d8f433d513598595adb098f4928314/external/rules_jvm_external/coursier.bzl", line 114, column 13, in _relativize_and_symlink_file
fail("Error while trying to parse the path of file in the coursier cache: " + absolute_path)
Error in fail: Error while trying to parse the path of file in the coursier cache: /Users/bruno/.m2/repository/com/facebook/react/react-native/0.63.3/react-native-0.63.3.aar
@capezzbr did you manage to find a working solution for this?
See the above PR #532, which fixes the issue. @jin let me know what you think.