bazel_maven_repository icon indicating copy to clipboard operation
bazel_maven_repository copied to clipboard

Make a redirect system to allow non-snippet interdiction of generated targets

Open cgruber opened this issue 4 years ago • 0 comments

Right now, to configure an annotation processor or kt_compiler_plugin you need to use a build snippet, voiding the warranty (so to speak) on the other features of BMR, such as deps computation. You also have to fiddle with group-level substitutions, etc.

A more powerful approach would be to allow a redirection, in the following sense. If you, say, put in:

   "com.google.dagger:dagger.2.16": { "redirect": "//third_party/dagger" }

The following would happen:

  • the regular artifact raw_jvm_import would be generated under an alternate name iwth a standard convention
    • e.g. "dagger__original"
    • Unless modified, the visibility of the target would be the present package and the redirect target.
  • All local (in same generated package build file) references to that target would point at "dagger_original"
  • In place of the normal target location (e.g. @maven//com/google/dagger:dagger) would be an alias to the redirection target.

Thus, one could define in //third_party/dagger:

java_library(
    name = "dagger",
    exported_plugins = [":compiler_plugin"],
    exports = [ "@maven//com/google/dagger:dagger__original" ],
    visibility = ["//visibility:public"],
)

java_plugin(
    name = "compiler_plugin",
    processor_name = "a.b.c.whatever",
    deps = [ "@maven//com/google/dagger:dagger_compiler" ],
)

And any uses outside of the external workspace "maven"'s com/google/dagger package could reference @maven//com/google/dagger and the alias would point them at //third_party/dagger.

A subtask of #52

cgruber avatar Jul 07 '20 17:07 cgruber