Skip to content

Commit

Permalink
WIP commit of the three attempts so far
Browse files Browse the repository at this point in the history
This latest attempt nearly works except I still can't get protobuf to
stop being counted as a non-maven jar.
  • Loading branch information
niloc132 committed Apr 14, 2022
1 parent 43ddc24 commit bc1fbca
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 3 deletions.
43 changes: 40 additions & 3 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,44 @@ filegroup(
),
)

java_binary(
#attempt 3
load("@rules_jvm_external//:defs.bzl", "java_export")
java_export(
name = "exported_compiler_unshaded",
maven_coordinates = "com.google.javascript:closure-compiler-unshaded:v20220401",
runtime_deps = [
"//:compiler_lib",
],
)

#attempt 2
#load("@vaticle_bazel_distribution//maven:rules.bzl","assemble_maven")
#assemble_maven(
# name = "compiler_unshaded_maven",
# target = '//:compiler_lib'
#)

#attempt 1
#load("@google_bazel_common//tools/maven:pom_file.bzl", "pom_file")
#pom_file(
# name = 'compiler_unshaded_pom',
# template_file = 'maven/closure-compiler-unshaded.pom.xml',
# targets = [
# '//:compiler_lib'
# ],
#)


# need a magic bazel rule that combines the following into a single jar for deployment to maven central
# //:compiler_lib for the "runtime libs", apparently js and typedast contents
# //:compiler_lib_no_runtime_libs for most of the sources
# then, from compiler_lib_no_runtime_libs, we need these deps (but no others, as they are external):
# "//src/com/google/debugging/sourcemap/proto:mapping_java_proto",
# "//src/com/google/javascript/jscomp/conformance:conformance_java_proto",
# "//src/com/google/javascript/jscomp/instrumentation/reporter/proto:profile_java_proto",
# "//src/com/google/javascript/rhino/typed_ast:typed_ast_java_proto",

java_binary(# also a lie, as this is a java_binary, the _deploy.jar contains all deps
name = "compiler_unshaded_no_runtime_libs",
main_class = "com.google.javascript.jscomp.CommandLineRunner",
runtime_deps = [":compiler_lib_no_runtime_libs"],
Expand Down Expand Up @@ -171,7 +208,7 @@ oss_java_library(
"@com_google_code_gson_gson",
"@com_google_guava_failureaccess//jar",
"@com_google_guava_guava//jar",
"@com_google_protobuf//:protobuf_java",
"@maven//:com_google_protobuf_protobuf_java",
"@com_google_re2j_re2j",
"@google_bazel_common//third_party/java/auto:value",
"@google_bazel_common//third_party/java/error_prone:annotations",
Expand Down Expand Up @@ -236,7 +273,7 @@ gen_java_tests(
"@com_google_guava_guava//jar",
"@com_google_guava_guava_testlib//jar",
"@com_google_jimfs_jimfs",
"@com_google_protobuf//:protobuf_java",
"@maven//:com_google_protobuf_protobuf_java",
"@com_google_re2j_re2j",
"@com_google_truth_extensions_truth_liteproto_extension",
"@com_google_truth_extensions_truth_proto_extension",
Expand Down
64 changes: 64 additions & 0 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,55 @@ load("@google_bazel_common//:workspace_defs.bzl", "google_common_workspace_rules

google_common_workspace_rules()

# attempt 3
RULES_JVM_EXTERNAL_TAG = "4.2"
RULES_JVM_EXTERNAL_SHA = "cd1a77b7b02e8e008439ca76fd34f5b07aecb8c752961f9640dea15e9e5ba1ca"

http_archive(
name = "rules_jvm_external",
strip_prefix = "rules_jvm_external-%s" % RULES_JVM_EXTERNAL_TAG,
sha256 = RULES_JVM_EXTERNAL_SHA,
url = "https://github.com/bazelbuild/rules_jvm_external/archive/%s.zip" % RULES_JVM_EXTERNAL_TAG,
)

load("@rules_jvm_external//:repositories.bzl", "rules_jvm_external_deps")

rules_jvm_external_deps()

load("@rules_jvm_external//:setup.bzl", "rules_jvm_external_setup")

rules_jvm_external_setup()

# attempt 2
#http_archive(
# name = "vaticle_bazel_distribution",
# sha256 = "aa9da4875d679b4fda680d13845d505b3033ec746b238fee5868c52f69929cba",
# strip_prefix = "bazel-distribution-8eb8a0e920d43bf2d3100e22e7e36dc29009bac5",
# urls = [
# "https://github.com/vaticle/bazel-distribution/archive/8eb8a0e920d43bf2d3100e22e7e36dc29009bac5.zip",
# ],
#)
#
#load("@vaticle_bazel_distribution//common:deps.bzl","rules_kotlin", "rules_jvm_external")
#rules_kotlin()
#rules_jvm_external()
#
#load("@io_bazel_rules_kotlin//kotlin:kotlin.bzl", "kotlin_repositories", "kt_register_toolchains")
#kotlin_repositories()
#kt_register_toolchains()
#
#load("@vaticle_bazel_distribution//maven:deps.bzl", "maven_artifacts_with_versions")
#load("@rules_jvm_external//:defs.bzl", "maven_install")
#maven_install(
# artifacts = maven_artifacts_with_versions,
# repositories = [
# "https://repo1.maven.org/maven2",
# ],
# strict_visibility = True,
# version_conflict_policy = "pinned",
# fetch_sources = True,
#)

maven_import(
# http://args4j.kohsuke.org/index.html
group_id = "args4j",
Expand Down Expand Up @@ -147,3 +196,18 @@ http_archive(
load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories")

jar_jar_repositories()

load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"com.google.protobuf:protobuf-java:3.19.2",
"com.google.protobuf:protobuf-java-util:3.19.2",
],
override_targets = {
"com.google.protobuf:protobuf-java": "@com_google_protobuf//:protobuf_java",
},
repositories = [
"https://repo1.maven.org/maven2",
],
strict_visibility = True,
)
3 changes: 3 additions & 0 deletions maven/closure-compiler-unshaded.pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@
<version>1.0-SNAPSHOT</version>
<relativePath>closure-compiler-main.pom.xml</relativePath>
</parent>
<dependencies>
{generated_bzl_deps}
</dependencies>
</project>

0 comments on commit bc1fbca

Please sign in to comment.