diff --git a/.github/workflows/workspace_snippet.sh b/.github/workflows/workspace_snippet.sh index c1dd6062..3becab87 100755 --- a/.github/workflows/workspace_snippet.sh +++ b/.github/workflows/workspace_snippet.sh @@ -1,6 +1,5 @@ #!/usr/bin/env bash - -set -o errexit -o nounset -o pipefail +set -eufo pipefail # Set by GH actions, see # https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables diff --git a/README.md b/README.md index 7bd7b4cb..23f19852 100644 --- a/README.md +++ b/README.md @@ -490,7 +490,7 @@ want to force users to remember to load our own dependencies for us. Instead, to add a new dependency to the project: 1. Update `frozen_deps` in the `WORKSPACE` file -2. Run `./bin/freeze-deps.py` +2. Run `./tools/update-dependencies.sh` 3. Commit the updated files. ### Freezing your dependencies @@ -522,7 +522,7 @@ file you need to do the following: pinned_maven_install() ``` -2. Run `./bin/frozen-deps.py --repo --zip +2. Run `./tools/frozen-deps.py --repo --zip `. The `` matches the name used for the `maven_install()` rule above. This will pin the dependencies then collect them into the zip file. diff --git a/WORKSPACE b/WORKSPACE index 98691b44..6e2a8fdb 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -85,6 +85,8 @@ pinned_maven_install() # These are used for our own tests. maven_install( artifacts = [ + "com.google.googlejavaformat:google-java-format:1.15.0", + # These can be versioned independently of the versions in `repositories.bzl` # so long as the version numbers are higher. "org.junit.jupiter:junit-jupiter-engine:5.8.2", diff --git a/docs/postfix.md b/docs/postfix.md index 5935091a..2974aea7 100644 --- a/docs/postfix.md +++ b/docs/postfix.md @@ -8,7 +8,7 @@ want to force users to remember to load our own dependencies for us. Instead, to add a new dependency to the project: 1. Update `frozen_deps` in the `WORKSPACE` file -2. Run `./bin/freeze-deps.py` +2. Run `./tools/update-dependencies.sh` 3. Commit the updated files. ### Freezing your dependencies @@ -40,7 +40,7 @@ file you need to do the following: pinned_maven_install() ``` -2. Run `./bin/frozen-deps.py --repo --zip +2. Run `./tools/frozen-deps.py --repo --zip `. The `` matches the name used for the `maven_install()` rule above. This will pin the dependencies then collect them into the zip file. diff --git a/java/BUILD.bazel b/java/BUILD.bazel index 1956977e..6ab4e9e8 100644 --- a/java/BUILD.bazel +++ b/java/BUILD.bazel @@ -30,7 +30,7 @@ checkstyle_binary( name = "checkstyle_cli", runtime_deps = [ artifact("com.puppycrawl.tools:checkstyle"), - ] + ], ) pmd_binary( diff --git a/java/private/contrib_rules_jvm_deps.zip b/java/private/contrib_rules_jvm_deps.zip index e1ec1bf1..99206589 100644 Binary files a/java/private/contrib_rules_jvm_deps.zip and b/java/private/contrib_rules_jvm_deps.zip differ diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java index f8bcc295..b4e48f28 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/ActualRunner.java @@ -1,10 +1,9 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.engine.discovery.DiscoverySelectors; -import org.junit.platform.launcher.LauncherConstants; -import org.junit.platform.launcher.core.LauncherConfig; -import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; -import org.junit.platform.launcher.core.LauncherFactory; +import static java.nio.file.StandardOpenOption.DELETE_ON_CLOSE; +import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; +import static java.nio.file.StandardOpenOption.WRITE; +import static org.junit.platform.launcher.EngineFilter.includeEngines; import java.io.File; import java.io.IOException; @@ -14,11 +13,11 @@ import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; - -import static java.nio.file.StandardOpenOption.DELETE_ON_CLOSE; -import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING; -import static java.nio.file.StandardOpenOption.WRITE; -import static org.junit.platform.launcher.EngineFilter.includeEngines; +import org.junit.platform.engine.discovery.DiscoverySelectors; +import org.junit.platform.launcher.LauncherConstants; +import org.junit.platform.launcher.core.LauncherConfig; +import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; +import org.junit.platform.launcher.core.LauncherFactory; public class ActualRunner implements RunsTest { @@ -36,31 +35,30 @@ public boolean run(String testClassName) { try (var bazelJunitXml = new BazelJUnitOutputListener(xmlOut)) { var summary = new CommandLineSummary(); - LauncherConfig config = LauncherConfig.builder() - .addTestExecutionListeners(bazelJunitXml, summary) - .build(); + LauncherConfig config = + LauncherConfig.builder().addTestExecutionListeners(bazelJunitXml, summary).build(); var classSelector = DiscoverySelectors.selectClass(testClassName); - var request = LauncherDiscoveryRequestBuilder.request() - .selectors(List.of(classSelector)) - .filters(includeEngines( - "junit-jupiter", - "junit-vintage")) - .configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME, "true") - .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true"); + var request = + LauncherDiscoveryRequestBuilder.request() + .selectors(List.of(classSelector)) + .filters(includeEngines("junit-jupiter", "junit-vintage")) + .configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME, "true") + .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true"); String filter = System.getenv("TESTBRIDGE_TEST_ONLY"); request.filters(new PatternFilter(filter)); File exitFile = getExitFile(); var originalSecurityManager = System.getSecurityManager(); - TestRunningSecurityManager testSecurityManager = new TestRunningSecurityManager(originalSecurityManager); + TestRunningSecurityManager testSecurityManager = + new TestRunningSecurityManager(originalSecurityManager); try { System.setSecurityManager(testSecurityManager); var launcher = LauncherFactory.create(config); launcher.execute(request.build()); - } finally { + } finally { testSecurityManager.allowRemoval(); System.setSecurityManager(originalSecurityManager); } @@ -97,6 +95,6 @@ private void deleteExitFile(File exitFile) { } catch (Throwable t) { // Ignore. } - } + } } } diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BaseResult.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BaseResult.java index cb5b291d..ef843724 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BaseResult.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BaseResult.java @@ -1,11 +1,5 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.engine.TestExecutionResult; -import org.junit.platform.engine.reporting.ReportEntry; -import org.junit.platform.launcher.TestIdentifier; - -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; import java.time.Duration; import java.time.Instant; import java.util.LinkedList; @@ -13,6 +7,11 @@ import java.util.Objects; import java.util.Optional; import java.util.function.Function; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.engine.reporting.ReportEntry; +import org.junit.platform.launcher.TestIdentifier; abstract class BaseResult { private final TestIdentifier testId; diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BazelJUnitOutputListener.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BazelJUnitOutputListener.java index ffae05fa..5d0ab4da 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BazelJUnitOutputListener.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/BazelJUnitOutputListener.java @@ -1,14 +1,7 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.engine.TestExecutionResult; -import org.junit.platform.engine.reporting.ReportEntry; -import org.junit.platform.launcher.TestExecutionListener; -import org.junit.platform.launcher.TestIdentifier; -import org.junit.platform.launcher.TestPlan; +import static java.nio.charset.StandardCharsets.UTF_8; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; import java.io.BufferedWriter; import java.io.Closeable; import java.io.IOException; @@ -19,8 +12,14 @@ import java.util.logging.Level; import java.util.logging.Logger; import java.util.stream.Collectors; - -import static java.nio.charset.StandardCharsets.UTF_8; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.engine.reporting.ReportEntry; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; public class BazelJUnitOutputListener implements TestExecutionListener, Closeable { @@ -48,9 +47,10 @@ public void testPlanExecutionStarted(TestPlan testPlan) { throw new IllegalStateException("Test plan is currently executing"); } - roots = testPlan.getRoots().stream() - .map(root -> new RootContainer(root, testPlan)) - .collect(Collectors.toCollection(LinkedHashSet::new)); + roots = + testPlan.getRoots().stream() + .map(root -> new RootContainer(root, testPlan)) + .collect(Collectors.toCollection(LinkedHashSet::new)); } @Override @@ -81,7 +81,8 @@ public void executionSkipped(TestIdentifier testIdentifier, String reason) { } @Override - public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { + public void executionFinished( + TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) { roots.forEach(root -> root.markFinished(testIdentifier, testExecutionResult)); } diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/CommandLineSummary.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/CommandLineSummary.java index 14b3234a..d278e2b5 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/CommandLineSummary.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/CommandLineSummary.java @@ -1,22 +1,22 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.engine.TestExecutionResult; -import org.junit.platform.launcher.TestExecutionListener; -import org.junit.platform.launcher.TestIdentifier; -import org.junit.platform.launcher.TestPlan; -import org.junit.platform.reporting.legacy.LegacyReportingUtils; +import static org.junit.platform.engine.TestExecutionResult.Status.SUCCESSFUL; import java.io.PrintWriter; import java.util.Collections; import java.util.LinkedHashMap; import java.util.Map; import java.util.Objects; - -import static org.junit.platform.engine.TestExecutionResult.Status.SUCCESSFUL; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.launcher.TestExecutionListener; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.reporting.legacy.LegacyReportingUtils; public class CommandLineSummary implements TestExecutionListener { - private final Map failures = Collections.synchronizedMap(new LinkedHashMap<>()); + private final Map failures = + Collections.synchronizedMap(new LinkedHashMap<>()); private TestPlan testPlan; @Override @@ -43,11 +43,7 @@ public void writeTo(PrintWriter writer) { String className = LegacyReportingUtils.getClassName(testPlan, entry.getKey()); - writer.printf( - "%d) %s (%s)%n", - count, - entry.getKey().getDisplayName(), - className); + writer.printf("%d) %s (%s)%n", count, entry.getKey().getDisplayName(), className); Throwable cause = failure.getCause(); StackTraceElement[] stackTrace = cause.getStackTrace(); @@ -76,8 +72,7 @@ public int getFailureCount() { private static class Failure { private TestExecutionResult result; - public Failure() { - } + public Failure() {} public void setResult(TestExecutionResult result) { this.result = result; diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/EntryDetails.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/EntryDetails.java index 0fa8804f..d5e9f5b6 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/EntryDetails.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/EntryDetails.java @@ -1,12 +1,11 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.engine.reporting.ReportEntry; - -import java.util.Map; - import static org.junit.platform.launcher.LauncherConstants.STDERR_REPORT_ENTRY_KEY; import static org.junit.platform.launcher.LauncherConstants.STDOUT_REPORT_ENTRY_KEY; +import java.util.Map; +import org.junit.platform.engine.reporting.ReportEntry; + class EntryDetails { private EntryDetails() { @@ -23,10 +22,9 @@ public static String getStdErr(ReportEntry entry) { private static String getReportEntryValue(ReportEntry entry, String key) { return entry.getKeyValuePairs().entrySet().stream() - .filter(e -> key.equals(e.getKey())) - .map(Map.Entry::getValue) - .findFirst() - .orElse(null); + .filter(e -> key.equals(e.getKey())) + .map(Map.Entry::getValue) + .findFirst() + .orElse(null); } - } diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java index 88661da0..a228682d 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit5Runner.java @@ -1,18 +1,17 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; /** - * Test bootstrapper. This class only depends on the JRE (java 11+) and will - * ensure that the required dependencies for a junit5 test are on the - * classpath before creating the actual runner. In this way we can offer a - * useful error message to people, which is always nice, right? - *

- * Most of the configuration information can be found on this page in the - * - * Test Encyclopedia. + * Test bootstrapper. This class only depends on the JRE (java 11+) and will ensure that the + * required dependencies for a junit5 test are on the classpath before creating the actual runner. + * In this way we can offer a useful error message to people, which is always nice, right? + * + *

Most of the configuration information can be found on this page in the Test Encyclopedia. */ public class JUnit5Runner { - private static final String JUNIT5_RUNNER_CLASS = "com.github.bazel_contrib.contrib_rules_jvm.junit5.ActualRunner"; + private static final String JUNIT5_RUNNER_CLASS = + "com.github.bazel_contrib.contrib_rules_jvm.junit5.ActualRunner"; public static void main(String[] args) { var testSuite = System.getProperty("bazel.test_suite"); @@ -25,9 +24,8 @@ public static void main(String[] args) { detectJUnit5Classes(); try { - var constructor = Class.forName(JUNIT5_RUNNER_CLASS) - .asSubclass(RunsTest.class) - .getConstructor(); + var constructor = + Class.forName(JUNIT5_RUNNER_CLASS).asSubclass(RunsTest.class).getConstructor(); var runsTest = constructor.newInstance(); if (!runsTest.run(testSuite)) { System.exit(2); @@ -45,20 +43,16 @@ public static void main(String[] args) { private static void detectJUnit5Classes() { checkClass( - "org.junit.jupiter.engine.JupiterTestEngine", - "org.junit.jupiter:junit-jupiter-engine"); + "org.junit.jupiter.engine.JupiterTestEngine", "org.junit.jupiter:junit-jupiter-engine"); checkClass( - "org.junit.platform.commons.JUnitException", - "org.junit.platform:junit-platform-commons"); + "org.junit.platform.commons.JUnitException", "org.junit.platform:junit-platform-commons"); checkClass( - "org.junit.platform.engine.ExecutionRequest", - "org.junit.platform:junit-platform-engine"); + "org.junit.platform.engine.ExecutionRequest", "org.junit.platform:junit-platform-engine"); checkClass( - "org.junit.platform.launcher.TestPlan", - "org.junit.platform:junit-platform-launcher"); + "org.junit.platform.launcher.TestPlan", "org.junit.platform:junit-platform-launcher"); checkClass( - "org.junit.platform.reporting.legacy.LegacyReportingUtils", - "org.junit.platform:junit-platform-reporting"); + "org.junit.platform.reporting.legacy.LegacyReportingUtils", + "org.junit.platform:junit-platform-reporting"); } private static void checkClass(String className, String containedInDependency) { @@ -66,8 +60,9 @@ private static void checkClass(String className, String containedInDependency) { Class.forName(className); } catch (ReflectiveOperationException e) { throw new IllegalStateException( - String.format("JUnit 5 test runner is missing a dependency on `artifact(\"%s\")`%n", containedInDependency)); + String.format( + "JUnit 5 test runner is missing a dependency on `artifact(\"%s\")`%n", + containedInDependency)); } } - } diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/PatternFilter.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/PatternFilter.java index d626376a..2b73c552 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/PatternFilter.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/PatternFilter.java @@ -1,5 +1,7 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; +import java.util.function.Predicate; +import java.util.regex.Pattern; import org.junit.platform.engine.FilterResult; import org.junit.platform.engine.TestDescriptor; import org.junit.platform.engine.TestSource; @@ -7,13 +9,10 @@ import org.junit.platform.engine.support.descriptor.MethodSource; import org.junit.platform.launcher.PostDiscoveryFilter; -import java.util.function.Predicate; -import java.util.regex.Pattern; - /** * Attempts to mirror the logic from Bazel's own - * com.google.testing.junit.junit4.runner.RegExTestCaseFilter, which forms - * a string of the test class name and the method name. + * com.google.testing.junit.junit4.runner.RegExTestCaseFilter, which forms a string of the test + * class name and the method name. */ public class PatternFilter implements PostDiscoveryFilter { diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/RootContainer.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/RootContainer.java index 3914441a..60cf097f 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/RootContainer.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/RootContainer.java @@ -1,15 +1,14 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; +import java.util.LinkedList; +import java.util.List; +import java.util.Optional; +import javax.xml.stream.XMLStreamWriter; import org.junit.platform.engine.TestExecutionResult; import org.junit.platform.engine.reporting.ReportEntry; import org.junit.platform.launcher.TestIdentifier; import org.junit.platform.launcher.TestPlan; -import javax.xml.stream.XMLStreamWriter; -import java.util.LinkedList; -import java.util.List; -import java.util.Optional; - public class RootContainer extends BaseResult { // Insertion order matters when we come to output the results @@ -43,10 +42,10 @@ protected Optional get(TestIdentifier testIdentifier) { } return suites.stream() - .map(suite -> suite.get(testIdentifier)) - .filter(Optional::isPresent) - .map(Optional::get) - .findFirst(); + .map(suite -> suite.get(testIdentifier)) + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst(); } public void toXml(XMLStreamWriter xml) { diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestResult.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestResult.java index 37971909..df018475 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestResult.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestResult.java @@ -1,16 +1,15 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.engine.TestExecutionResult; -import org.junit.platform.launcher.TestIdentifier; -import org.junit.platform.launcher.TestPlan; -import org.junit.platform.reporting.legacy.LegacyReportingUtils; - -import javax.xml.stream.XMLStreamWriter; import java.io.PrintWriter; import java.io.StringWriter; import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.Optional; +import javax.xml.stream.XMLStreamWriter; +import org.junit.platform.engine.TestExecutionResult; +import org.junit.platform.launcher.TestIdentifier; +import org.junit.platform.launcher.TestPlan; +import org.junit.platform.reporting.legacy.LegacyReportingUtils; class TestResult extends BaseResult { private final TestPlan testPlan; @@ -43,58 +42,59 @@ public void toXml(XMLStreamWriter xml) { DecimalFormat decimalFormat = new DecimalFormat("#.##"); decimalFormat.setRoundingMode(RoundingMode.HALF_UP); - write(() -> { - // Massage the name - String name = getTestId().getLegacyReportingName(); - int index = name.indexOf('('); - if (index != -1) { - name = name.substring(0, index); - } - - xml.writeStartElement("testcase"); - xml.writeAttribute("name", name); - xml.writeAttribute("classname", LegacyReportingUtils.getClassName(testPlan, getTestId())); - xml.writeAttribute("time", decimalFormat.format(getDuration().toMillis() / 1000f)); - - if (isFailure() || isError()) { - Throwable throwable = getResult().getThrowable().orElse(null); - - xml.writeStartElement(isFailure() ? "failure" : "error"); - if (throwable == null) { - // Stub out the values - xml.writeAttribute("message", "unknown cause"); - xml.writeAttribute("type", RuntimeException.class.getName()); - xml.writeEndElement(); - return; - } - - xml.writeAttribute("message", throwable.getMessage()); - xml.writeAttribute("type", throwable.getClass().getName()); - - StringWriter stringWriter = new StringWriter(); - throwable.printStackTrace(new PrintWriter(stringWriter)); - - xml.writeCData(stringWriter.toString()); + write( + () -> { + // Massage the name + String name = getTestId().getLegacyReportingName(); + int index = name.indexOf('('); + if (index != -1) { + name = name.substring(0, index); + } + + xml.writeStartElement("testcase"); + xml.writeAttribute("name", name); + xml.writeAttribute("classname", LegacyReportingUtils.getClassName(testPlan, getTestId())); + xml.writeAttribute("time", decimalFormat.format(getDuration().toMillis() / 1000f)); + + if (isFailure() || isError()) { + Throwable throwable = getResult().getThrowable().orElse(null); + + xml.writeStartElement(isFailure() ? "failure" : "error"); + if (throwable == null) { + // Stub out the values + xml.writeAttribute("message", "unknown cause"); + xml.writeAttribute("type", RuntimeException.class.getName()); + xml.writeEndElement(); + return; + } + + xml.writeAttribute("message", throwable.getMessage()); + xml.writeAttribute("type", throwable.getClass().getName()); + + StringWriter stringWriter = new StringWriter(); + throwable.printStackTrace(new PrintWriter(stringWriter)); + + xml.writeCData(stringWriter.toString()); + + xml.writeEndElement(); + } + + String stdout = getStdOut(); + if (stdout != null) { + xml.writeStartElement("system-out"); + xml.writeCData(stdout); + xml.writeEndElement(); + } + + String stderr = getStdErr(); + if (stderr != null) { + xml.writeStartElement("system-err"); + xml.writeCData(stderr); + xml.writeEndElement(); + } - xml.writeEndElement(); - } - - String stdout = getStdOut(); - if (stdout != null) { - xml.writeStartElement("system-out"); - xml.writeCData(stdout); - xml.writeEndElement(); - } - - String stderr = getStdErr(); - if (stderr != null) { - xml.writeStartElement("system-err"); - xml.writeCData(stderr); - xml.writeEndElement(); - } - - xml.writeEndElement(); - }); + xml.writeEndElement(); + }); } @Override diff --git a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestSuiteResult.java b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestSuiteResult.java index 5655aa5c..06cfcc77 100644 --- a/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestSuiteResult.java +++ b/java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestSuiteResult.java @@ -1,12 +1,11 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.platform.launcher.TestIdentifier; - -import javax.xml.stream.XMLStreamWriter; import java.util.LinkedList; import java.util.List; import java.util.Optional; import java.util.stream.Stream; +import javax.xml.stream.XMLStreamWriter; +import org.junit.platform.launcher.TestIdentifier; class TestSuiteResult extends BaseResult { @@ -19,53 +18,54 @@ public TestSuiteResult(TestIdentifier id) { @Override public void toXml(XMLStreamWriter xml) { - write(() -> { - if (getSkipReason() != null) { - return; - } - - xml.writeStartElement("testsuite"); - - xml.writeAttribute("name", getTestId().getLegacyReportingName()); - xml.writeAttribute("tests", String.valueOf(results.size())); - - int errors = 0; - int failures = 0; - for (TestResult result : results) { - if (result.isError()) { - errors++; - } - if (result.isFailure()) { - failures++; - } - } - xml.writeAttribute("failures", String.valueOf(failures)); - xml.writeAttribute("errors", String.valueOf(errors)); - - // The bazel junit4 test runner seems to leave these values empty. - // Emulating that somewhat strange behaviour here. - xml.writeAttribute("package", ""); - xml.writeEmptyElement("properties"); - - results.forEach(res -> res.toXml(xml)); - nestedSuites.forEach(suite -> suite.toXml(xml)); - - String stdout = getStdOut(); - if (stdout != null) { - xml.writeStartElement("system-out"); - xml.writeCData(stdout); - xml.writeEndElement(); - } - - String stderr = getStdErr(); - if (stderr != null) { - xml.writeStartElement("system-err"); - xml.writeCData(stderr); - xml.writeEndElement(); - } - - xml.writeEndElement(); - }); + write( + () -> { + if (getSkipReason() != null) { + return; + } + + xml.writeStartElement("testsuite"); + + xml.writeAttribute("name", getTestId().getLegacyReportingName()); + xml.writeAttribute("tests", String.valueOf(results.size())); + + int errors = 0; + int failures = 0; + for (TestResult result : results) { + if (result.isError()) { + errors++; + } + if (result.isFailure()) { + failures++; + } + } + xml.writeAttribute("failures", String.valueOf(failures)); + xml.writeAttribute("errors", String.valueOf(errors)); + + // The bazel junit4 test runner seems to leave these values empty. + // Emulating that somewhat strange behaviour here. + xml.writeAttribute("package", ""); + xml.writeEmptyElement("properties"); + + results.forEach(res -> res.toXml(xml)); + nestedSuites.forEach(suite -> suite.toXml(xml)); + + String stdout = getStdOut(); + if (stdout != null) { + xml.writeStartElement("system-out"); + xml.writeCData(stdout); + xml.writeEndElement(); + } + + String stderr = getStdErr(); + if (stderr != null) { + xml.writeStartElement("system-err"); + xml.writeCData(stderr); + xml.writeEndElement(); + } + + xml.writeEndElement(); + }); } public void add(TestResult testResult) { @@ -83,9 +83,9 @@ protected Optional get(TestIdentifier id) { } return Stream.concat(results.stream(), nestedSuites.stream()) - .map(result -> result.get(id)) - .filter(Optional::isPresent) - .map(Optional::get) - .findFirst(); + .map(result -> result.get(id)) + .filter(Optional::isPresent) + .map(Optional::get) + .findFirst(); } } diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/checkstyle/Sample.java b/java/test/com/github/bazel_contrib/contrib_rules_jvm/checkstyle/Sample.java index 89a77b0c..bb28e65f 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/checkstyle/Sample.java +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/checkstyle/Sample.java @@ -1,5 +1,3 @@ package com.github.bazel_contrib.contrib_rules_jvm.checkstyle; -public class Sample { - -} \ No newline at end of file +public class Sample {} diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/BUILD.bazel b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/BUILD.bazel index 5234c024..5f1eea30 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/BUILD.bazel +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/BUILD.bazel @@ -8,7 +8,10 @@ PACKAGE_NAME_TEST = [ java_test_suite( name = "small-tests", size = "small", - srcs = glob(["*.java"], exclude = PACKAGE_NAME_TEST), + srcs = glob( + ["*.java"], + exclude = PACKAGE_NAME_TEST, + ), runner = "junit5", deps = [ "//java/src/com/github/bazel_contrib/contrib_rules_jvm/junit5", @@ -23,10 +26,10 @@ java_test_suite( java_test_suite( name = "custom-tests", size = "small", - package = "com.github.bazel_contrib.contrib_rules_jvm.custom", srcs = PACKAGE_NAME_TEST, + package = "com.github.bazel_contrib.contrib_rules_jvm.custom", runner = "junit5", deps = [ artifact("org.junit.jupiter:junit-jupiter-api"), ] + JUNIT5_DEPS, -) \ No newline at end of file +) diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/CallingSystemExitTest.java b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/CallingSystemExitTest.java index 49df85ef..7ba6930d 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/CallingSystemExitTest.java +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/CallingSystemExitTest.java @@ -1,9 +1,9 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.assertThrows; +import org.junit.jupiter.api.Test; + public class CallingSystemExitTest { @Test diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/FilteringTest.java b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/FilteringTest.java index 44f7e502..5fade7b3 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/FilteringTest.java +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/FilteringTest.java @@ -1,5 +1,10 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.lang.reflect.Method; +import java.util.Optional; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.junit.jupiter.engine.config.DefaultJupiterConfiguration; @@ -11,12 +16,6 @@ import org.junit.platform.engine.FilterResult; import org.junit.platform.engine.UniqueId; -import java.lang.reflect.Method; -import java.util.Optional; - -import static org.junit.jupiter.api.Assertions.assertFalse; -import static org.junit.jupiter.api.Assertions.assertTrue; - public class FilteringTest { private JupiterEngineDescriptor engineDescriptor; @@ -32,7 +31,9 @@ public void setup() throws NoSuchMethodException { UniqueId classId = engine.append("class", "foo"); classTestDescriptor = new ClassTestDescriptor(classId, JUnit5StyleTest.class, config); Method method = JUnit5StyleTest.class.getMethod("alwaysPasses"); - testMethodTestDescriptor = new TestMethodTestDescriptor(classId.append("method", "bar"), JUnit5StyleTest.class, method, config); + testMethodTestDescriptor = + new TestMethodTestDescriptor( + classId.append("method", "bar"), JUnit5StyleTest.class, method, config); } @Test @@ -79,7 +80,8 @@ public void ifFilterIsSetButNoTestsMatchTheContainersAreIncluded() { @Test public void shouldIncludeATestMethodIfTheFilterIsJustTheClassName() { - PatternFilter filter = new PatternFilter(JUnit5StyleTest.class.getName().replace("$", "\\$") + "#"); + PatternFilter filter = + new PatternFilter(JUnit5StyleTest.class.getName().replace("$", "\\$") + "#"); FilterResult testResult = filter.apply(testMethodTestDescriptor); assertTrue(testResult.included()); @@ -120,7 +122,6 @@ public int size() { private static class JUnit5StyleTest { @Test - public void alwaysPasses() { - } + public void alwaysPasses() {} } } diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/HangingThreadTest.java b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/HangingThreadTest.java index 6adc2b86..e4086a35 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/HangingThreadTest.java +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/HangingThreadTest.java @@ -1,33 +1,34 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.jupiter.api.Test; - import java.util.concurrent.atomic.AtomicBoolean; +import org.junit.jupiter.api.Test; public class HangingThreadTest { - // This thread isn't a daemon thread, so after the test is complete - // the JVM will wait for it to exit. However, all the tests are now - // done, so the junit runner should exit cleanly. - private final static AtomicBoolean STARTED = new AtomicBoolean(false); - private final static Thread SNAGGING_THREAD = new Thread(() -> { - STARTED.set(true); - try { - Thread.sleep(Long.MAX_VALUE); - } catch (InterruptedException e) { - // Swallow - } - }); - static { - SNAGGING_THREAD.start(); - } + // This thread isn't a daemon thread, so after the test is complete + // the JVM will wait for it to exit. However, all the tests are now + // done, so the junit runner should exit cleanly. + private static final AtomicBoolean STARTED = new AtomicBoolean(false); + private static final Thread SNAGGING_THREAD = + new Thread( + () -> { + STARTED.set(true); + try { + Thread.sleep(Long.MAX_VALUE); + } catch (InterruptedException e) { + // Swallow + } + }); - // We need this to get the thread to start running. - @Test - public void hangForever() throws InterruptedException { - while (!STARTED.get()) { - Thread.sleep(100); - } - } + static { + SNAGGING_THREAD.start(); + } + // We need this to get the thread to start running. + @Test + public void hangForever() throws InterruptedException { + while (!STARTED.get()) { + Thread.sleep(100); + } + } } diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit4CompatibilityTest.java b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit4CompatibilityTest.java index 65299520..21bb16e3 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit4CompatibilityTest.java +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/JUnit4CompatibilityTest.java @@ -1,5 +1,8 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.platform.launcher.EngineFilter.includeEngines; + import org.junit.jupiter.api.Test; import org.junit.platform.engine.discovery.ClassSelector; import org.junit.platform.engine.discovery.DiscoverySelectors; @@ -9,28 +12,22 @@ import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder; import org.junit.platform.launcher.core.LauncherFactory; -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.platform.launcher.EngineFilter.includeEngines; - public class JUnit4CompatibilityTest { @Test public void shouldDetectJUnit4Tests() { CommandLineSummary summary = new CommandLineSummary(); - LauncherConfig config = LauncherConfig.builder() - .addTestExecutionListeners(summary) - .build(); + LauncherConfig config = LauncherConfig.builder().addTestExecutionListeners(summary).build(); ClassSelector classSelector = DiscoverySelectors.selectClass(Junit4StyleTest.class); - LauncherDiscoveryRequestBuilder request = LauncherDiscoveryRequestBuilder.request() - .selectors(classSelector) - .filters(includeEngines( - "junit-jupiter", - "junit-vintage")) - .configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME, "true") - .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true"); + LauncherDiscoveryRequestBuilder request = + LauncherDiscoveryRequestBuilder.request() + .selectors(classSelector) + .filters(includeEngines("junit-jupiter", "junit-vintage")) + .configurationParameter(LauncherConstants.CAPTURE_STDERR_PROPERTY_NAME, "true") + .configurationParameter(LauncherConstants.CAPTURE_STDOUT_PROPERTY_NAME, "true"); Launcher launcher = LauncherFactory.create(config); launcher.execute(request.build()); @@ -41,8 +38,7 @@ public void shouldDetectJUnit4Tests() { public static class Junit4StyleTest { @org.junit.Test - public void shouldPass() { - } + public void shouldPass() {} @org.junit.Test public void shouldFail() { diff --git a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestRunningSecurityManagerTest.java b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestRunningSecurityManagerTest.java index c21f612e..bb20877d 100644 --- a/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestRunningSecurityManagerTest.java +++ b/java/test/com/github/bazel_contrib/contrib_rules_jvm/junit5/TestRunningSecurityManagerTest.java @@ -1,11 +1,9 @@ package com.github.bazel_contrib.contrib_rules_jvm.junit5; -import org.junit.jupiter.api.Test; - -import java.security.Permission; - import static org.junit.jupiter.api.Assertions.assertThrows; +import java.security.Permission; +import org.junit.jupiter.api.Test; public class TestRunningSecurityManagerTest { @@ -19,15 +17,16 @@ void shouldStifleSystemExitCalls() { void shouldDelegateToExistingSecurityManagerIfPresent() { SecurityManager permissive = new TestRunningSecurityManager(null); Permission permission = new RuntimePermission("example.permission"); - SecurityManager restrictive = new TestRunningSecurityManager( - new SecurityManager() { - @Override - public void checkPermission(Permission perm) { - if (permission == perm) { - throw new SecurityException("Oh noes!"); - } - } - }); + SecurityManager restrictive = + new TestRunningSecurityManager( + new SecurityManager() { + @Override + public void checkPermission(Permission perm) { + if (permission == perm) { + throw new SecurityException("Oh noes!"); + } + } + }); // This should do nothing, but if an exception is thrown, our test fails. permissive.checkPermission(permission); diff --git a/maven_install.json b/maven_install.json index 90c3e907..b78cf06b 100644 --- a/maven_install.json +++ b/maven_install.json @@ -1,10 +1,201 @@ { "dependency_tree": { "__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL", - "__INPUT_ARTIFACTS_HASH": 2063251191, - "__RESOLVED_ARTIFACTS_HASH": -677301807, + "__INPUT_ARTIFACTS_HASH": 1097940676, + "__RESOLVED_ARTIFACTS_HASH": 1720650379, "conflict_resolution": {}, "dependencies": [ + { + "coord": "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar" + ], + "sha256": "1c9e85e272d0708c6a591dc74828c71603053b48cc75ae83cce56912a2aa063b", + "url": "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2-sources.jar" + }, + { + "coord": "com.google.code.findbugs:jsr305:3.0.2", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" + ], + "sha256": "766ad2a0783f2687962c8ad74ceecc38a28b9f72a2d085ee438b7813e928d0c7", + "url": "https://repo1.maven.org/maven2/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" + }, + { + "coord": "com.google.errorprone:error_prone_annotations:jar:sources:2.7.1", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1-sources.jar" + ], + "sha256": "e38921f918b8ad8eabd12bc61de426fa96c72de077054e9147d2f9fe7c648923", + "url": "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1-sources.jar" + }, + { + "coord": "com.google.errorprone:error_prone_annotations:2.7.1", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar" + ], + "sha256": "cd5257c08a246cf8628817ae71cb822be192ef91f6881ca4a3fcff4f1de1cff3", + "url": "https://repo1.maven.org/maven2/com/google/errorprone/error_prone_annotations/2.7.1/error_prone_annotations-2.7.1.jar" + }, + { + "coord": "com.google.googlejavaformat:google-java-format:jar:sources:1.15.0", + "dependencies": [ + "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "com.google.errorprone:error_prone_annotations:jar:sources:2.7.1", + "com.google.guava:failureaccess:jar:sources:1.0.1", + "com.google.guava:guava:jar:sources:31.0.1-jre", + "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "org.checkerframework:checker-qual:jar:sources:3.12.0" + ], + "directDependencies": [ + "com.google.guava:guava:jar:sources:31.0.1-jre" + ], + "file": "v1/https/repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.15.0/google-java-format-1.15.0-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.15.0/google-java-format-1.15.0-sources.jar" + ], + "sha256": "c55f0bd9fa6862a0629bb129ddbf425327f4869cbc9d503fd17c76cf8c2ef30c", + "url": "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.15.0/google-java-format-1.15.0-sources.jar" + }, + { + "coord": "com.google.googlejavaformat:google-java-format:1.15.0", + "dependencies": [ + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.errorprone:error_prone_annotations:2.7.1", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:guava:31.0.1-jre", + "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:1.3", + "org.checkerframework:checker-qual:3.12.0" + ], + "directDependencies": [ + "com.google.guava:guava:31.0.1-jre" + ], + "file": "v1/https/repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.15.0/google-java-format-1.15.0.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.15.0/google-java-format-1.15.0.jar" + ], + "sha256": "4f546cfe159547ac3b9547daa9649e728f6abc254979c975f1cb9971793692c3", + "url": "https://repo1.maven.org/maven2/com/google/googlejavaformat/google-java-format/1.15.0/google-java-format-1.15.0.jar" + }, + { + "coord": "com.google.guava:failureaccess:jar:sources:1.0.1", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar" + ], + "sha256": "092346eebbb1657b51aa7485a246bf602bb464cc0b0e2e1c7e7201fadce1e98f", + "url": "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1-sources.jar" + }, + { + "coord": "com.google.guava:failureaccess:1.0.1", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + ], + "sha256": "a171ee4c734dd2da837e4b16be9df4661afab72a41adaf31eb84dfdaf936ca26", + "url": "https://repo1.maven.org/maven2/com/google/guava/failureaccess/1.0.1/failureaccess-1.0.1.jar" + }, + { + "coord": "com.google.guava:guava:jar:sources:31.0.1-jre", + "dependencies": [ + "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "com.google.errorprone:error_prone_annotations:jar:sources:2.7.1", + "com.google.guava:failureaccess:jar:sources:1.0.1", + "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "org.checkerframework:checker-qual:jar:sources:3.12.0" + ], + "directDependencies": [ + "com.google.code.findbugs:jsr305:jar:sources:3.0.2", + "com.google.errorprone:error_prone_annotations:jar:sources:2.7.1", + "com.google.guava:failureaccess:jar:sources:1.0.1", + "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "org.checkerframework:checker-qual:jar:sources:3.12.0" + ], + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre-sources.jar" + ], + "sha256": "fc0fb66f315f10b8713fc43354936d3649a8ad63f789d42fd7c3e55ecf72e092", + "url": "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre-sources.jar" + }, + { + "coord": "com.google.guava:guava:31.0.1-jre", + "dependencies": [ + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.errorprone:error_prone_annotations:2.7.1", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:1.3", + "org.checkerframework:checker-qual:3.12.0" + ], + "directDependencies": [ + "com.google.code.findbugs:jsr305:3.0.2", + "com.google.errorprone:error_prone_annotations:2.7.1", + "com.google.guava:failureaccess:1.0.1", + "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "com.google.j2objc:j2objc-annotations:1.3", + "org.checkerframework:checker-qual:3.12.0" + ], + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar" + ], + "sha256": "d5be94d65e87bd219fb3193ad1517baa55a3b88fc91d21cf735826ab5af087b9", + "url": "https://repo1.maven.org/maven2/com/google/guava/guava/31.0.1-jre/guava-31.0.1-jre.jar" + }, + { + "coord": "com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + ], + "sha256": "b372a037d4230aa57fbeffdef30fd6123f9c0c2db85d0aced00c91b974f33f99", + "url": "https://repo1.maven.org/maven2/com/google/guava/listenablefuture/9999.0-empty-to-avoid-conflict-with-guava/listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar" + }, + { + "coord": "com.google.j2objc:j2objc-annotations:jar:sources:1.3", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar" + ], + "sha256": "ba4df669fec153fa4cd0ef8d02c6d3ef0702b7ac4cabe080facf3b6e490bb972", + "url": "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3-sources.jar" + }, + { + "coord": "com.google.j2objc:j2objc-annotations:1.3", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" + ], + "sha256": "21af30c92267bd6122c0e0b4d20cccb6641a37eaf956c6540ec471d584e64a7b", + "url": "https://repo1.maven.org/maven2/com/google/j2objc/j2objc-annotations/1.3/j2objc-annotations-1.3.jar" + }, { "coord": "junit:junit:jar:sources:4.13.2", "dependencies": [ @@ -57,6 +248,28 @@ "sha256": "b509448ac506d607319f182537f0b35d71007582ec741832a1f111e5b5b70b38", "url": "https://repo1.maven.org/maven2/org/apiguardian/apiguardian-api/1.1.2/apiguardian-api-1.1.2.jar" }, + { + "coord": "org.checkerframework:checker-qual:jar:sources:3.12.0", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0-sources.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0-sources.jar" + ], + "sha256": "fd99a45195ed893803624d1030387056a96601013f5e61ccabd79abb4ddfa876", + "url": "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0-sources.jar" + }, + { + "coord": "org.checkerframework:checker-qual:3.12.0", + "dependencies": [], + "directDependencies": [], + "file": "v1/https/repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar", + "mirror_urls": [ + "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar" + ], + "sha256": "ff10785ac2a357ec5de9c293cb982a2cbb605c0309ea4cc1cb9b9bc6dbe7f3cb", + "url": "https://repo1.maven.org/maven2/org/checkerframework/checker-qual/3.12.0/checker-qual-3.12.0.jar" + }, { "coord": "org.hamcrest:hamcrest-core:jar:sources:1.3", "dependencies": [], @@ -370,6 +583,12 @@ ], "sha256": "58812de60898d976fb81ef3b62da05c6604c18fd4a249f5044282479fc286af2", "url": "https://repo1.maven.org/maven2/org/opentest4j/opentest4j/1.2.0/opentest4j-1.2.0.jar" + }, + { + "coord": "com.google.guava:listenablefuture:jar:sources:9999.0-empty-to-avoid-conflict-with-guava", + "dependencies": [], + "directDependencies": [], + "file": null } ], "version": "0.1.0" diff --git a/tools/BUILD.bazel b/tools/BUILD.bazel new file mode 100644 index 00000000..c9dbcc4b --- /dev/null +++ b/tools/BUILD.bazel @@ -0,0 +1,14 @@ +load("//java:defs.bzl", "java_binary") + +java_binary( + name = "google-java-format", + jvm_flags = [ + "--add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED", + "--add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED", + ], + main_class = "com.google.googlejavaformat.java.Main", + runtime_deps = ["@maven//:com_google_googlejavaformat_google_java_format"], +) diff --git a/tools/format.sh b/tools/format.sh new file mode 100755 index 00000000..7b4a15d6 --- /dev/null +++ b/tools/format.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +set -eufo pipefail + +GOOGLE_JAVA_FORMAT="$(bazel run --run_under=echo //tools:google-java-format)" + +find "$PWD" -type f -name '*.java' | xargs "$GOOGLE_JAVA_FORMAT" --replace +bazel run //:gazelle diff --git a/bin/freeze-deps.py b/tools/freeze-deps.py similarity index 100% rename from bin/freeze-deps.py rename to tools/freeze-deps.py diff --git a/tools/update-dependencies.sh b/tools/update-dependencies.sh new file mode 100755 index 00000000..45b9239d --- /dev/null +++ b/tools/update-dependencies.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -eufo pipefail + +./tools/freeze-deps.py +REPIN=1 bazel run @unpinned_maven//:pin diff --git a/bin/update-docs b/tools/update-docs.sh similarity index 63% rename from bin/update-docs rename to tools/update-docs.sh index bad1cea1..1d9d4d63 100755 --- a/bin/update-docs +++ b/tools/update-docs.sh @@ -1,6 +1,5 @@ -#!/bin/bash - -set -eu +#!/usr/bin/env bash +set -eufo pipefail bazel build //docs:readme cp -f bazel-bin/docs/README.md README.md