Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump actions/checkout from 3 to 4 #2

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
version: 2
jobs:
build:
working_directory: ~/repo
docker:
- image: circleci/openjdk:8-jdk-stretch
environment:
MAVEN_OPTS: -Xmx3200m
_JAVA_OPTIONS: "-Xms1g -Xmx1g"
steps:
- checkout
- run:
name: environment check
command: |
java -XX:+PrintFlagsFinal -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
env MAVEN_OPTS="-XX:+PrintFlagsFinal" mvn -version | grep -iE 'HeapSize|PermSize|ThreadStackSize'
mvn -version

# Download and cache dependencies
- restore_cache:
keys:
- v1-dependencies-{{ checksum "pom.xml" }}
# fallback to using the latest cache if no exact match is found
- v1-dependencies-

- run: mvn deploy -s .circleci/settings.xml -Dartifactory.username=$ARTIFACTORY_USER -Dartifactory.password=$ARTIFACTORY_APIKEY

- save_cache:
paths:
- ~/.m2
key: v1-dependencies-{{ checksum "pom.xml" }}



workflows:
version: 2
ci_build:
jobs:
- build:
context: deploy-keys
13 changes: 13 additions & 0 deletions .circleci/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<servers>
<server>
<id>vertispan-snapshots</id>
<username>${artifactory.username}</username>
<password>${artifactory.password}</password>
</server>
</servers>
</settings>

2 changes: 1 addition & 1 deletion .github/ci_support/test_closure-compiler-npm.sh
Original file line number Diff line number Diff line change
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
14 changes: 7 additions & 7 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ jobs:
# Clone closure-compiler repo from the commit under test into current directory.
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

# https://github.com/bazelbuild/setup-bazelisk
- uses: bazelbuild/setup-bazelisk@v2
Expand All @@ -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 @@ -104,7 +104,7 @@ jobs:
# Clone closure-compiler-npm repo from master into the current directory.
- name: Checkout Current closure-compiler-npm Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: google/closure-compiler-npm
ref: master
Expand All @@ -113,7 +113,7 @@ jobs:
# submodule
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: compiler

Expand All @@ -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 All @@ -152,7 +152,7 @@ jobs:
# Clone closure-compiler repo from the commit under test into current directory.
- name: Checkout Current closure-compiler Commit
# https://github.com/marketplace/actions/checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
Expand Down
24 changes: 18 additions & 6 deletions BUILD.bazel
Original file line number Diff line number Diff line change
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
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,33 @@ analyzes it, removes dead code and rewrites and minimizes what's left. It also
checks syntax, variable references, and types, and warns about common JavaScript
pitfalls.

---

This is Vertispan LLC's fork of the Closure Compiler targeted to support J2CL,
which includes a few changes from Google's original repository, including:

* Externs that specifically match various stable versions of Elemental2.
* Sourcemap support for BUNDLE optimization levels.
* Include defines in BUNDLE output.
* Restore the `PersistentInputStore` API - note that with the introduction of
the (experimental) `TypedAst` feature, we may drop this soon.

As the upstream project undergoes regular tagged releases, the Vertispan
releases in turn will be versioned and tagged to match them, following a pattern
of `<upstream-tag>-<release-count>`, where the `<upstream-tag>` is the tag that
Google released, followed by `<release-count>`, an integer to increment for each
tagged release - when a new Closure Compiler release is released, the release
count will reset to `1`. Note that not all upstream tags will necessarily get an
associated Vertispan release. Later releases off of the same upstream tag will
then increment that count, should they be needed.

The release process is to rebase this set of commits, then update the version in
the poms appropriately. When a release is pushed to Maven Central, a tag will
be pushed to our git repository with a matching version. Snapshot releases will
use a `-SNAPSHOT` suffix after the release count.

---

## Getting Started

The easiest way to install the compiler is with [NPM](https://npmjs.com) or
Expand Down Expand Up @@ -232,7 +259,7 @@ 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
```
Expand Down Expand Up @@ -265,7 +292,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
Original file line number Diff line number Diff line change
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,
)
6 changes: 3 additions & 3 deletions bazel/sonatype_artifact_bundle.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,18 @@ Returns:
<artifact_id>_bundle.jar: The bundle JAR
"""

_SNAPSHOT = "1.0-SNAPSHOT"
_SNAPSHOT = "0.3-SNAPSHOT"

def _sonatype_artifact_bundle(ctx):
version = ctx.var.get("COMPILER_VERSION", _SNAPSHOT)
password = None
generate_signatures = True

if version == _SNAPSHOT:
if version.endswith("-SNAPSHOT"):
# A SNAPSHOT version can't be uploaded as a release
# and thus doesn't need to be signed
generate_signatures = False
elif not version.startswith("v") or not version[1:].isdigit():
elif not version.startswith("v"):
fail("--define=COMPILER_VERSION was malformed; got '{0}'".format(version))
else:
password = _fail_missing_define(ctx, "CLEARTEXT_GPG_PASSPHRASE")
Expand Down
53 changes: 53 additions & 0 deletions deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/bin/bash

# Deployment script modeled roughly after upstream's js deployment wiring,
# this file runs the bazel command to produce bundles, then immediately
# unbundles the zip and deploys each artifact. This script differs slightly
# in that it uses gpg:sign-and-deploy-file to handle attaching signatures,
# and only uploads the artifacts that Vertispan is presently interested in.

set -e

DEFAULT_DEPLOY_URL=https://repo.vertispan.com/j2cl/
DEFAULT_DEPLOY_REPO_ID=vertispan-snapshots

VERSION=${1:-HEAD-SNAPSHOT}
DEPLOY_URL=${2:-$DEFAULT_DEPLOY_URL}
DEPLOY_REPO_ID=${3:-$DEFAULT_DEPLOY_REPO_ID}

#TODO Find another way to pass in gpg passphrase - apparently
# this is the only way bazel can work with parameters passed
# in? Also, it is unnecessary, since we have to call sign-and-deploy-file
# anyway to let maven upload without manually pushing a
# bundle, so it is unnecessary.
# It might be easier to modify the .bzl instead of supporting
# this, and just have bazel produce the jars+poms.
bazel build //:sonatype_bundles --define=COMPILER_VERSION=$VERSION --define=CLEARTEXT_GPG_PASSPHRASE=$CLEARTEXT_GPG_PASSPHRASE


if [ -z "$CLEARTEXT_GPG_PASSPHRASE" ]; then
GOAL="deploy:deploy-file"
else
GOAL="gpg:sign-and-deploy-file"
fi

mkdir tmp
cd tmp

mkdir parent
unzip -n ../bazel-bin/closure-compiler-parent_bundle.jar -d parent
mvn $GOAL -Dfile=parent/pom.xml -DpomFile=parent/pom.xml -Durl=$DEPLOY_URL -DrepositoryId=$DEPLOY_REPO_ID


mkdir main
unzip -n ../bazel-bin/closure-compiler-main_bundle.jar -d main
mvn $GOAL -Dfile=main/pom.xml -DpomFile=main/pom.xml -Durl=$DEPLOY_URL -DrepositoryId=$DEPLOY_REPO_ID


mkdir unshaded
unzip -n ../bazel-bin/closure-compiler-unshaded_bundle.jar -d unshaded
mvn $GOAL -Dfile=unshaded/closure-compiler-unshaded-${VERSION}.jar -Djavadoc=unshaded/closure-compiler-unshaded-${VERSION}-javadoc.jar -Dsources=unshaded/closure-compiler-unshaded-${VERSION}-sources.jar -DpomFile=unshaded/pom.xml -Durl=$DEPLOY_URL -DrepositoryId=$DEPLOY_REPO_ID


cd -
rm -rf tmp
Loading