File tree Expand file tree Collapse file tree
java/jsinterop/annotations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33#
44
55load ("@com_google_j2cl//build_defs:rules.bzl" , "j2cl_import" )
6+ load (":import_annotations_jar.bzl" , "import_annotations_jar" )
67load ("@bazel_common_javadoc//:javadoc.bzl" , "javadoc_library" )
78
89package (
@@ -17,6 +18,17 @@ java_library(
1718 srcs = glob (["*.java" ]),
1819)
1920
21+ # Re-import only the output jar, dropping all transitive dependencies in the
22+ # process. This is important for JsInterop Annotations as these are used by
23+ # the J2CL-emulated JRE itself and thus cannot have any dependencies outside of
24+ # toolchain's bootclasspath.
25+ import_annotations_jar (
26+ name = "annotations_jar" ,
27+ jar = ":libannotations.jar" ,
28+ # No one outside of this package should _ever_ depend upon this target.
29+ visibility = ["//visibility:private" ],
30+ )
31+
2032javadoc_library (
2133 name = "annotations-javadoc" ,
2234 srcs = glob (["*.java" ]),
@@ -28,5 +40,5 @@ javadoc_library(
2840
2941j2cl_import (
3042 name = "annotations-j2cl" ,
31- jar = ":annotations " ,
43+ jar = ":annotations_jar " ,
3244)
Original file line number Diff line number Diff line change 1+ """import_annotations_jar build macro
2+
3+ This macro is intended for internal-use only to re-import the annotations JAR
4+ into a JavaInfo provider without keeping dependency information.
5+ """
6+
7+ def _impl_import_annotations_jar (ctx ):
8+ if ctx .file .jar .extension != "jar" :
9+ fail ("jar must be a file with extension .jar" )
10+ return JavaInfo (output_jar = ctx .file .jar , compile_jar = ctx .file .jar )
11+
12+ import_annotations_jar = rule (
13+ implementation = _impl_import_annotations_jar ,
14+ attrs = {
15+ "jar" : attr .label (
16+ allow_single_file = True ,
17+ ),
18+ },
19+ fragments = ["java" ],
20+ )
You can’t perform that action at this time.
0 commit comments