Skip to content

Commit bc1fbca

Browse files
committed
WIP commit of the three attempts so far
This latest attempt nearly works except I still can't get protobuf to stop being counted as a non-maven jar.
1 parent 43ddc24 commit bc1fbca

File tree

3 files changed

+107
-3
lines changed

3 files changed

+107
-3
lines changed

BUILD.bazel

+40-3
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,44 @@ filegroup(
126126
),
127127
)
128128

129-
java_binary(
129+
#attempt 3
130+
load("@rules_jvm_external//:defs.bzl", "java_export")
131+
java_export(
132+
name = "exported_compiler_unshaded",
133+
maven_coordinates = "com.google.javascript:closure-compiler-unshaded:v20220401",
134+
runtime_deps = [
135+
"//:compiler_lib",
136+
],
137+
)
138+
139+
#attempt 2
140+
#load("@vaticle_bazel_distribution//maven:rules.bzl","assemble_maven")
141+
#assemble_maven(
142+
# name = "compiler_unshaded_maven",
143+
# target = '//:compiler_lib'
144+
#)
145+
146+
#attempt 1
147+
#load("@google_bazel_common//tools/maven:pom_file.bzl", "pom_file")
148+
#pom_file(
149+
# name = 'compiler_unshaded_pom',
150+
# template_file = 'maven/closure-compiler-unshaded.pom.xml',
151+
# targets = [
152+
# '//:compiler_lib'
153+
# ],
154+
#)
155+
156+
157+
# need a magic bazel rule that combines the following into a single jar for deployment to maven central
158+
# //:compiler_lib for the "runtime libs", apparently js and typedast contents
159+
# //:compiler_lib_no_runtime_libs for most of the sources
160+
# then, from compiler_lib_no_runtime_libs, we need these deps (but no others, as they are external):
161+
# "//src/com/google/debugging/sourcemap/proto:mapping_java_proto",
162+
# "//src/com/google/javascript/jscomp/conformance:conformance_java_proto",
163+
# "//src/com/google/javascript/jscomp/instrumentation/reporter/proto:profile_java_proto",
164+
# "//src/com/google/javascript/rhino/typed_ast:typed_ast_java_proto",
165+
166+
java_binary(# also a lie, as this is a java_binary, the _deploy.jar contains all deps
130167
name = "compiler_unshaded_no_runtime_libs",
131168
main_class = "com.google.javascript.jscomp.CommandLineRunner",
132169
runtime_deps = [":compiler_lib_no_runtime_libs"],
@@ -171,7 +208,7 @@ oss_java_library(
171208
"@com_google_code_gson_gson",
172209
"@com_google_guava_failureaccess//jar",
173210
"@com_google_guava_guava//jar",
174-
"@com_google_protobuf//:protobuf_java",
211+
"@maven//:com_google_protobuf_protobuf_java",
175212
"@com_google_re2j_re2j",
176213
"@google_bazel_common//third_party/java/auto:value",
177214
"@google_bazel_common//third_party/java/error_prone:annotations",
@@ -236,7 +273,7 @@ gen_java_tests(
236273
"@com_google_guava_guava//jar",
237274
"@com_google_guava_guava_testlib//jar",
238275
"@com_google_jimfs_jimfs",
239-
"@com_google_protobuf//:protobuf_java",
276+
"@maven//:com_google_protobuf_protobuf_java",
240277
"@com_google_re2j_re2j",
241278
"@com_google_truth_extensions_truth_liteproto_extension",
242279
"@com_google_truth_extensions_truth_proto_extension",

WORKSPACE.bazel

+64
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,55 @@ load("@google_bazel_common//:workspace_defs.bzl", "google_common_workspace_rules
3333

3434
google_common_workspace_rules()
3535

36+
# attempt 3
37+
RULES_JVM_EXTERNAL_TAG = "4.2"
38+
RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"
39+
40+
http_archive(
41+
name = "rules_jvm_external",
42+
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
43+
sha256 = RULES_JVM_EXTERNAL_SHA,
44+
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
45+
)
46+
47+
load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")
48+
49+
rules_jvm_external_deps()
50+
51+
load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")
52+
53+
rules_jvm_external_setup()
54+
55+
# attempt 2
56+
#http_archive(
57+
# name = "vaticle_bazel_distribution",
58+
# sha256 = "aa9da4875d679b4fda680d13845d505b3033ec746b238fee5868c52f69929cba",
59+
# strip_prefix = "bazel-distribution-8eb8a0e920d43bf2d3100e22e7e36dc29009bac5",
60+
# urls = [
61+
# "https://github.com/vaticle/bazel-distribution/archive/8eb8a0e920d43bf2d3100e22e7e36dc29009bac5.zip",
62+
# ],
63+
#)
64+
#
65+
#load("@vaticle_bazel_distribution//common:deps.bzl","rules_kotlin", "rules_jvm_external")
66+
#rules_kotlin()
67+
#rules_jvm_external()
68+
#
69+
#load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
70+
#kotlin_repositories()
71+
#kt_register_toolchains()
72+
#
73+
#load("@vaticle_bazel_distribution//maven:deps.bzl", "maven_artifacts_with_versions")
74+
#load("@rules_jvm_external//:defs.bzl", "maven_install")
75+
#maven_install(
76+
# artifacts = maven_artifacts_with_versions,
77+
# repositories = [
78+
# "https://repo1.maven.org/maven2",
79+
# ],
80+
# strict_visibility = True,
81+
# version_conflict_policy = "pinned",
82+
# fetch_sources = True,
83+
#)
84+
3685
maven_import(
3786
# http://args4j.kohsuke.org/index.html
3887
group_id = "args4j",
@@ -147,3 +196,18 @@ http_archive(
147196
load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories")
148197

149198
jar_jar_repositories()
199+
200+
load("@rules_jvm_external//:defs.bzl", "maven_install")
201+
maven_install(
202+
artifacts = [
203+
"com.google.protobuf:protobuf-java:3.19.2",
204+
"com.google.protobuf:protobuf-java-util:3.19.2",
205+
],
206+
override_targets = {
207+
"com.google.protobuf:protobuf-java": "@com_google_protobuf//:protobuf_java",
208+
},
209+
repositories = [
210+
"https://repo1.maven.org/maven2",
211+
],
212+
strict_visibility = True,
213+
)

maven/closure-compiler-unshaded.pom.xml

+3
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,7 @@
4343
<version>1.0-SNAPSHOT</version>
4444
<relativePath>closure-compiler-main.pom.xml</relativePath>
4545
</parent>
46+
<dependencies>
47+
{generated_bzl_deps}
48+
</dependencies>
4649
</project>

0 commit comments

Comments
 (0)