You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My assumption is that kt_jvm_library does not pass -Abazel.repository the way that java_library does. See bazelbuild/bazel#16549
error: The bazel.repository annotation processor option is not set. To use this annotation processor, provide the canonical repository name of the current target as the value of the -Abazel.repository flag.
The text was updated successfully, but these errors were encountered:
genrule(
name = "generate_env",
outs = ["resources_root.env"],
cmd = "echo $(rlocationpath //path/to/test/resources:test_files_root) > \"$@\"",
tools = ["//path/to/test/resources:test_files_root"],
)
kt_jvm_test(
name = "kt-idea-plugins-shared-library-test",
srcs = ["kotlin/JsonAssemblerTest.kt"],
resources = [
# resources_root.env
":generate_env"
],
test_class = "some.package.shared.JsonAssemblerTest",
data = [
":generate_env",
"//path/to/test/resources:test_files" # this is filegroup
],
deps = [
"//:kotlin_serialization",
# some more deps
],
env = {
"REPOSITORY_ROOT_ENVFILE": "path/to/test/resources_root.env"
}
)
and then in kotlin:
fun getRepositoryRootPath(): Path {
// there is file resources_root.env in this jar
val classLoader = this.javaClass.classLoader
// env file name is in env variable REPOSITORY_ROOT_ENVFILE
val resourcesRootEnv = classLoader.getResource(
System.getenv("REPOSITORY_ROOT_ENVFILE")
) ?: throw Exception("resources_root.env not found")
// read it, there is one string that consists repository root path
val repositoryRootPath = resourcesRootEnv.readText()
val runfiles = Runfiles.preload()
val repositoryRootRLocation = runfiles.unmapped().rlocation(repositoryRootPath)
// the path we have is to file `.test_resources_root` in test resources directory,
// so we need to get parent of it
return Path(repositoryRootRLocation).parent
}
Maybe there is better workaround, but at least this one works
My assumption is that
kt_jvm_library
does not pass-Abazel.repository
the way thatjava_library
does. See bazelbuild/bazel#16549The text was updated successfully, but these errors were encountered: