Skip to content

Commit

Permalink
Merge pull request #3935 from niloc132:3896-unshaded-jar
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 481201303
  • Loading branch information
Copybara-Service committed Oct 14, 2022
2 parents 7fbe829 + ef68199 commit 1291137
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/ci_support/test_closure-compiler-npm.sh
Expand Up @@ -20,7 +20,7 @@
# - PWD = closure-compiler-npm repo root
#
# Params:
# 1. File name of compiler_unshaded_deploy.jar
# 1. File name of compiler_uberjar_deploy.jar
function main() {
local compiler_jar="$1"

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci.yaml
Expand Up @@ -63,7 +63,7 @@ jobs:
# upload-artifact doesn't support paths with symlinks
run: |
mkdir -p ${{ env.UNSYMLINK_DIR }}
cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/compiler_unshaded_deploy.jar
cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/compiler_uberjar_deploy.jar
cp -t ${{ env.UNSYMLINK_DIR }} bazel-bin/*_bundle.jar
# Share the following files with other jobs in this workflow. They can be grabbed using ID
Expand All @@ -74,7 +74,7 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: unshaded_compiler
path: ${{ env.UNSYMLINK_DIR }}/compiler_unshaded_deploy.jar
path: ${{ env.UNSYMLINK_DIR }}/compiler_uberjar_deploy.jar
if-no-files-found: error

# If this build will be uploadaded as a SNAPSHOT, share the Sonatype bundles with the other
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
path: compiler/bazel-bin

- name: Test closure-compiler-npm
run: compiler/.github/ci_support/test_closure-compiler-npm.sh compiler/bazel-bin/compiler_unshaded_deploy.jar
run: compiler/.github/ci_support/test_closure-compiler-npm.sh compiler/bazel-bin/compiler_uberjar_deploy.jar

deploy-snapshots:
name: Deploy Snapshot Bundles to Sonatype
Expand Down
24 changes: 18 additions & 6 deletions BUILD.bazel
Expand Up @@ -44,9 +44,9 @@ sonatype_artifact_bundle(
sonatype_artifact_bundle(
name = "compiler_unshaded_bundle",
artifact_id = "closure-compiler-unshaded",
jar = ":compiler_unshaded_deploy.jar",
jar = ":compiler_unshaded",
javadoc = ":compiler_lib_no_runtime_libs.javadoc",
pom = "maven/closure-compiler-unshaded.pom.xml",
pom = ":compiler_unshaded-pom",
sources = ":compiler_lib_no_runtime_libs.sources",
)

Expand All @@ -71,16 +71,28 @@ sonatype_artifact_bundle(

jar_jar(
name = "compiler_shaded",
input_jar = ":compiler_unshaded_deploy.jar",
input_jar = ":compiler_uberjar_deploy.jar",
rules = "rules.jarjar",
)

java_binary(
name = "compiler_unshaded",
name = "compiler_uberjar",
main_class = "com.google.javascript.jscomp.CommandLineRunner",
runtime_deps = [":compiler_lib"],
)

# Produce an unshaded export jar based on :compiler_lib
load("@rules_jvm_external//:defs.bzl", "java_export")
version = "$(COMPILER_VERSION)" or "1.0-SNAPSHOT"
java_export(
name = "compiler_unshaded",
maven_coordinates = "com.google.javascript:closure-compiler-unshaded:{0}".format(version),
runtime_deps = [
"//:compiler_lib",
],
pom_template = "maven/closure-compiler-unshaded.pom.xml.tpl"
)

java_binary(
name = "linter",
main_class = "com.google.javascript.jscomp.LinterMain",
Expand Down Expand Up @@ -173,7 +185,7 @@ oss_java_library(
"@com_google_errorprone_error_prone_annotations",
"@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",
"@org_apache_ant_ant",
Expand Down Expand Up @@ -238,7 +250,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
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -232,9 +232,9 @@ you're most comfortable with.
### Building from a terminal

```bash
$ bazelisk build //:compiler_unshaded_deploy.jar
$ bazelisk build //:compiler_uberjar_deploy.jar
# OR to build everything
$ bazelisk build :all
$ bazelisk build //:all
```

### Testing from a terminal
Expand Down Expand Up @@ -265,7 +265,7 @@ directory. You can access it with a call to `java -jar ...` or by using the
package.json script:

```bash
# java -jar bazel-bin/compiler_unshaded_deploy.jar [...args]
# java -jar bazel-bin/compiler_uberjar_deploy.jar [...args]
yarn compile [...args]
```

Expand Down
18 changes: 18 additions & 0 deletions WORKSPACE.bazel
Expand Up @@ -12,6 +12,12 @@ http_archive(
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()

#
# To update google_bazel_common, locate the git commit to depend on and
# use something like the following to determine the sha256
Expand Down Expand Up @@ -164,3 +170,15 @@ http_archive(
load("@com_github_johnynek_bazel_jar_jar//:jar_jar.bzl", "jar_jar_repositories")

jar_jar_repositories()

# Declare protobuf-java from maven central, so the unshaded maven jar can recognize external dependencies
load("@rules_jvm_external//:defs.bzl", "maven_install")
maven_install(
artifacts = [
"com.google.protobuf:protobuf-java:3.19.3",
],
repositories = [
"https://repo1.maven.org/maven2",
],
strict_visibility = True,
)
Expand Up @@ -43,4 +43,7 @@
<version>1.0-SNAPSHOT</version>
<relativePath>closure-compiler-main.pom.xml</relativePath>
</parent>
<dependencies>
{dependencies}
</dependencies>
</project>
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -19,6 +19,6 @@
"jsdom": "^16.3.0"
},
"scripts": {
"compile": "java -jar bazel-bin/compiler_unshaded_deploy.jar"
"compile": "java -jar bazel-bin/compiler_uberjar_deploy.jar"
}
}

0 comments on commit 1291137

Please sign in to comment.