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

Tool to run build libraries using LTS BOM #1982

Closed
wants to merge 103 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
0f01568
example repositories and LtsRuntimeCompatibilityTest
suztomo Mar 15, 2021
4fd8971
xom to replace XML
suztomo Mar 15, 2021
c388b00
problem: Gradle's configuration name?
suztomo Mar 16, 2021
f926c88
grpc-java's protobuf module passes tests
suztomo Mar 16, 2021
adf1085
modifyPomFile to edit surefire configuration
suztomo Mar 22, 2021
f637b90
excluding dependencies with classifiers
suztomo Mar 22, 2021
bb917bf
Adding more libraries in the YAML file
suztomo Mar 24, 2021
5b50624
Adding more repositories
suztomo Mar 24, 2021
66c6b3c
Adding more repositories
suztomo Mar 25, 2021
ef040b5
LTS Test as GitHub Actions
suztomo Mar 30, 2021
97046e4
Not to print network transfer
suztomo Mar 30, 2021
4152bc1
print the property
suztomo Mar 30, 2021
b9a8f21
Fixed test name LtsBomCompatibilityTest
suztomo Mar 30, 2021
023392c
removing irrelevant changes
suztomo Mar 30, 2021
408f2ec
remove empty change
suztomo Mar 30, 2021
ccac387
Removed public modifier
suztomo Mar 30, 2021
55f158b
Skip javadoc for lts test
suztomo Mar 30, 2021
8e05714
Skipping javadoc for lts-test module
suztomo Mar 30, 2021
891930d
alphabetical order in the repositories.yaml
suztomo Mar 30, 2021
a446102
Trying to write ext directory of GitHub Actions
suztomo Mar 31, 2021
dbb21b3
trigger pull request on specific paths
suztomo Mar 31, 2021
25cfcdb
multiple commands
suztomo Mar 31, 2021
01c9d12
ProcessBuilder
suztomo Mar 31, 2021
55d00eb
fail-fast: false to know the all results
suztomo Mar 31, 2021
d3fdb3b
redirectErrorStream(true)
suztomo Mar 31, 2021
bf2fe97
Output the error
suztomo Mar 31, 2021
4173c41
stacktrace for Gradle
suztomo Mar 31, 2021
f300c8a
Fixing errors
suztomo Apr 1, 2021
8fe135c
Removing irrelevant line
suztomo Apr 1, 2021
916f17e
Formatting output
suztomo Apr 1, 2021
e5d892b
Upgrading versions
suztomo Apr 1, 2021
c30c907
Adding info to gradle
suztomo Apr 1, 2021
575e41d
JRE's ext directory
suztomo Apr 1, 2021
567ffa8
Reverting jre/lib/ext approach
suztomo Apr 1, 2021
a9d5114
Adding dependencies too.
suztomo Apr 2, 2021
01b7ad7
Show stacktrace on errors
suztomo Apr 2, 2021
44320c0
Trying no modification to Beam
suztomo Apr 2, 2021
bfe382f
Not modifying build.gradle for Beam
suztomo Apr 2, 2021
f10b629
Excluding misclassified ITs
suztomo Apr 5, 2021
bc72b7e
Use GradleDependencyMediation
suztomo Apr 9, 2021
037acc8
Not skipping Beam
suztomo Apr 9, 2021
4d39033
Format
suztomo Apr 9, 2021
41fa787
format
suztomo Apr 9, 2021
fd4ce88
Trying pubsub bom to set grpc-google-cloud-pubsub-v1
suztomo Apr 9, 2021
a905528
Build parameters
suztomo Apr 9, 2021
5d3284d
Run tests in other components in Beam
suztomo Apr 12, 2021
0b171ca
Beam-specific build.gradle handling
suztomo Apr 12, 2021
38924c6
No need to run analyzeClassesDependencies
suztomo Apr 12, 2021
cd7ad9f
Declare junit and hamcrest as testRuntime
suztomo Apr 12, 2021
ea32bfd
Trying explicit Guava dependency declaration
suztomo Apr 12, 2021
629030b
Continue upon a test failure to see all test failures
suztomo Apr 12, 2021
9bf8fcd
Continue and scan for Gradle projects
suztomo Apr 12, 2021
9b4e013
Special handling for com.google.cloud:google-cloud-core:jar:tests
suztomo Apr 12, 2021
352e86b
Removing pubsub BOM
suztomo Apr 13, 2021
0f71e00
Updating versions to test
suztomo Apr 29, 2021
e2dba2c
Remove gRPC test that fails (fixed in HEAD)
suztomo Apr 29, 2021
06417ab
Trying Beam 2.30 SNAPSHOT
suztomo Apr 29, 2021
412eaf8
Trying Beam 2.30.0-SNAPSHOT in the test
suztomo Apr 29, 2021
aec92bf
The test runner to exclude android.jar
suztomo May 3, 2021
c3b676f
Running bigtable-hbase project only in java-bigtable-hbase
suztomo May 4, 2021
3d78d6c
google-api-client 1.31.4
suztomo May 4, 2021
d660806
Specifying working directory
suztomo May 5, 2021
f3b7525
Debug output
suztomo May 5, 2021
97bb4fb
One-level above
suztomo May 5, 2021
4f0d76b
Fixed path
suztomo May 5, 2021
3b818ee
Version override in the BOM
suztomo May 5, 2021
93f6108
Modifying BOM by xmllint
suztomo May 6, 2021
ad4fac7
if statement in shell script
suztomo May 6, 2021
ec175bc
Investigating Beam's case; why doesn't it fail?
suztomo May 6, 2021
a5b4d58
Added description for inputs
suztomo May 7, 2021
ea1a55b
Removing snapshot repository definition
suztomo May 11, 2021
3477efc
Fixed parent pom version
suztomo May 11, 2021
ac7289d
google-api-java-client v1.31.5
suztomo May 11, 2021
82dcbf7
splitting responsibilities to BuildFileModifier classes
suztomo May 11, 2021
30b6651
format
suztomo May 11, 2021
d501d68
Added tests
suztomo May 11, 2021
69f7212
Reverting unnecessary change to LTS BOM
suztomo May 11, 2021
ce9a5bf
Applied review
suztomo May 12, 2021
f1c87ea
Reverted unnecessary changes
suztomo May 12, 2021
65fd97b
Added comment for excluding snapshot availability
suztomo May 12, 2021
bf4de4c
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo May 12, 2021
3e974e8
Avoid using Guava's Charsets
suztomo May 12, 2021
3ab0661
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo May 13, 2021
e799d49
Merge branch 'master' into lts_tests
suztomo May 14, 2021
3d95172
Merge branch 'master' into lts_tests
suztomo May 19, 2021
f59e90a
Applying sp releases to repositories.yaml
suztomo May 19, 2021
5de080e
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo May 19, 2021
5e8e245
Merge branch 'lts_tests' of https://github.com/GoogleCloudPlatform/cl…
suztomo May 19, 2021
c4239ab
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo May 21, 2021
0a2aefd
Special handling for testlib classifier
suztomo May 21, 2021
1b2101c
Fixing guava test
suztomo May 24, 2021
bebee2e
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo May 26, 2021
55a40f3
Adding java-datastore repository
suztomo May 26, 2021
9bd1968
java-datastore in checks
suztomo May 26, 2021
0278f1c
Updated assertion
suztomo May 26, 2021
9c802e2
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo May 27, 2021
d3c9dd6
bigtable-hbase-beam version in repositories.yml
suztomo May 27, 2021
30d6b22
grpc 1.36.2 in repositories.yml
suztomo May 27, 2021
0057f53
Merge branch 'master' into lts_tests
suztomo Jun 8, 2021
3e15562
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo Jun 15, 2021
53878e1
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo Jun 15, 2021
1d1cc19
Merge remote-tracking branch 'origin/master' into lts_tests
suztomo Jun 24, 2021
c622483
lts-bom: trying appengine-api-1.0-sdk 1.9.89
suztomo Jun 24, 2021
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
38 changes: 38 additions & 0 deletions .github/workflows/lts-test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
on:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When does this run?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It runs when a pull request of cloud-opensource-java repository touches files matching the paths below (line 3)

pull_request:
paths:
- '.github/workflows/lts-test.yaml'
- 'boms/cloud-lts-bom/pom.xml'
- 'lts-test/**'
- 'src/test/resources/repositories.yaml'
name: LTS Library Test
jobs:
lts-library-test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
repository:
- beam
- google-api-java-client
- google-auth-library-java
- google-http-java-client
- google-maps-services-java
- google-oauth-java-client
- grpc-java
- java-bigquery
- java-bigtable-hbase
- java-datastore
- java-monitoring
- java-pubsub
- java-spanner
- java-storage
- java-trace
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: 8
- uses: ./lts-test
with:
repository: ${{ matrix.repository }}
2 changes: 1 addition & 1 deletion boms/cloud-lts-bom/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<bigtable-hbase-beam.version>1.20.0-sp.1</bigtable-hbase-beam.version>
<google.cloud.storage.version>1.113.14-sp.1</google.cloud.storage.version>
<datastore.v1.proto.client.version>1.6.4-sp.1</datastore.v1.proto.client.version>
<appengine.api.1.0.sdk.version>1.9.86</appengine.api.1.0.sdk.version>
<appengine.api.1.0.sdk.version>1.9.89</appengine.api.1.0.sdk.version>
<androidpublisher.version>v3-rev20210429-1.31.0</androidpublisher.version>
</properties>

Expand Down
1 change: 0 additions & 1 deletion dashboard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
<version>1.3.7</version>
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The version is now set at root pom.xml

<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ public void testLibrariesBom()
private void checkBom(Path bomPath) throws MavenRepositoryException, IOException {
List<Artifact> artifacts = Bom.readBom(bomPath).getManagedDependencies();
for (Artifact artifact : artifacts) {
if (artifact.getVersion().contains("SNAPSHOT")) {
// LTS BOM draft may have artifacts that haven't been published to Maven Central yet.
continue;
}
assertReachable(buildMavenCentralUrl(artifact));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static String toCoordinates(Artifact artifact) {
return (artifact.getGroupId() + ":" + artifact.getArtifactId() + ":" + artifact.getVersion());
}

/** Returns the versionless coordinates of the {@code artifact}. */
public static String makeKey(Artifact artifact) {
return (artifact.getGroupId() + ":" + artifact.getArtifactId());
}
Expand Down
14 changes: 14 additions & 0 deletions lts-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
This tool is an automated test to check the compatibility of the libraries in
`boms/cloud-lts-bom/pom.xml`.

# How to execute tests in a repository

When you want to execute the unit tests, use `lts.test.repository` property.
The value corresponds to the "name" field in `lts-test/src/test/resources/repositories.yaml`.
For example, to run the tests for beam repository, run the following command:

```
$ mvn -pl dependencies,lts-test test -Dlts.test.repository=beam \
-Dtest=com.google.cloud.tools.opensource.lts.LtsBomCompatibilityTest \
-DfailIfNoTests=false
```
52 changes: 52 additions & 0 deletions lts-test/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: 'LTS Library Test'
description: 'Checks the compatibility of the libraries in the LTS BOM'
inputs:
repository:
description: 'The repository to test in this run. Use matrix to specify the values'
required: true
version_override_key:
description: >
The property name in the LTS BOM to test a certain version of a library. Use this input
when you check the compatibility of a library against other libraries in the LTS BOM.
required: false
default: 'unspecified'
version_override_value:
description: >
The version to test its compatibility with other libraries in the LTS BOM. The value must be
unavailable in Maven Central because Gradle might not read local Maven repository first.
required: false
default: '0.1.0-SNAPSHOT'
Comment on lines +7 to +18
Copy link
Contributor Author

@suztomo suztomo May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the input parameters for a library repository to override the version in the BOM.

https://github.com/googleapis/google-http-java-client/pull/1364/files#diff-a87cbbb4d5466c9d5b78b54ef875851d961bbbeed15a052016fb1d389b9c11cdR50

I added this configuration to emphasize that the LTS BOM test in this repository is a special case of the library compatibility test that will run in libraries' repository. If you prefer, I can remove the line 7-18, and 22-37.

runs:
using: "composite"
steps:
- name: Modify a version of a library in the LTS BOM if version override is specified
run: |
if [[ "${{ inputs.version_override_key }}" == "unspecified" ]]; then
echo "inputs.version_override_key is unspecified. Skipping this step."
exit
fi
cd ..
sudo apt-get install libxml2-utils
xmllint --shell boms/cloud-lts-bom/pom.xml << EOF
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised this isn't already in the image.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hoped it's there. But it requires the installation.
#2056 (comment)

setns x=http://maven.apache.org/POM/4.0.0
cd x:project/x:properties/x:${{ inputs.version_override_key }}
set ${{ inputs.version_override_value }}
save
EOF
shell: bash
working-directory: ${{ github.action_path }}
Comment on lines +22 to +37
Copy link
Contributor Author

@suztomo suztomo May 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This step modifies the local LTS BOM to use a certain version of a library when specified. For example, this PR for POC https://github.com/googleapis/google-http-java-client/pull/1364/files#diff-a87cbbb4d5466c9d5b78b54ef875851d961bbbeed15a052016fb1d389b9c11cdR50 overrides http.version to use locally-installed 1.39.2-sp.2.

- name: Install the snapshot LTS BOM (${{ github.action_path }}) to local Maven repository
run: |
cd ..
mvn -B -ntp -pl boms/cloud-lts-bom install
shell: bash
working-directory: ${{ github.action_path }}
- name: Run the unit tests for ${{ inputs.repository }} using repositories.yaml
run: |
cd ..
mvn -B -ntp -pl dependencies,lts-test test \
-Dtest=com.google.cloud.tools.opensource.lts.LtsBomCompatibilityTest \
-Dlts.test.repository=${{ inputs.repository }} \
-DfailIfNoTests=false
shell: bash
working-directory: ${{ github.action_path }}
129 changes: 129 additions & 0 deletions lts-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2021 Google LLC.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.google.cloud.tools</groupId>
<artifactId>dependencies-parent</artifactId>
<version>1.5.10-SNAPSHOT</version>
</parent>

<artifactId>lts-test</artifactId>

<name>LTS Test</name>
<description>GitHub Actions to check the compatibility among the libraries in the LTS BOM</description>
<url>https://github.com/GoogleCloudPlatform/cloud-opensource-java</url>
<organization>
<name>Google LLC.</name>
<url>https://www.google.com</url>
</organization>
<inceptionYear>2021</inceptionYear>
<developers>
<developer>
<name>Elliotte Rusty Harold</name>
</developer>
<developer>
<name>Tomo Suzuki</name>
</developer>
</developers>

<!-- Environment Settings -->
<issueManagement>
<url>https://github.com/GoogleCloudPlatform/cloud-opensource-java/issues</url>
</issueManagement>
<scm>
<connection>scm:git:[email protected]:GoogleCloudPlatform/cloud-opensource-java.git</connection>
<developerConnection>scm:git:[email protected]:GoogleCloudPlatform/cloud-opensource-java.git
</developerConnection>
<url>https://github.com/GoogleCloudPlatform/cloud-opensource-java/tree/master/linkage-monitor</url>
<tag>HEAD</tag>
</scm>

<licenses>
<license>
<name>The Apache License, Version 2.0</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
</license>
</licenses>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>dependencies</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.21</version>
</dependency>
<dependency>
<groupId>xom</groupId>
<artifactId>xom</artifactId>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava-testlib</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<configuration>
<!-- Skip; otherwise it fails due to no public class in this module -->
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
/*
* Copyright 2021 Google LLC.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.cloud.tools.opensource.lts;

import com.google.cloud.tools.opensource.dependencies.Bom;
import com.google.common.base.Verify;
import com.google.common.collect.ImmutableList;
import com.google.common.io.Files;
import com.google.common.io.MoreFiles;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;

/**
* Modifies Apache Beam's build files to use the libraries in the BOM when running the unit tests.
* Due to its complex build configuration Apache Beam requires special handling.
*/
class BeamProjectModifier implements BuildFileModifier {
@Override
public void modifyFiles(String name, Path projectDirectory, Bom bom)
throws TestSetupFailureException {
Iterable<Path> paths = MoreFiles.fileTraverser().breadthFirst(projectDirectory);
try {
for (Path path : paths) {
if (path.endsWith("build.gradle")) {
modifyBeamGradleFile(path, bom);
} else if (path.endsWith("BeamModulePlugin.groovy")) {
modifyBeamModulePlugin(path);
}
}
} catch (IOException ex) {
throw new TestSetupFailureException("Unable to modify the build file", ex);
}
}

// build.gradle files that run as part of the test in the beam section of repositories.yaml
private static final ImmutableList<Path> beamTestSubprojects =
ImmutableList.of(
Paths.get("sdks", "java", "core", "build.gradle"),
Paths.get("sdks", "java", "io", "google-cloud-platform", "build.gradle"),
Paths.get("sdks", "java", "extensions", "google-cloud-platform-core", "build.gradle"),
Paths.get("runners", "google-cloud-dataflow-java", "build.gradle"));

private static void modifyBeamGradleFile(Path gradleFile, Bom bom) throws IOException {

// Beam already uses enforcedPlatform(google_cloud_platform_libraries_bom), which prevents
// gcp-lts-bom's setting gRPC library version.
if (beamTestSubprojects.stream().anyMatch(gradleFile::endsWith)) {
String buildGradleContent =
Files.asCharSource(gradleFile.toFile(), StandardCharsets.UTF_8).read();

String bomCoordinates = bom.getCoordinates();
buildGradleContent =
buildGradleContent.replaceAll(
"\ndependencies \\{",
"\ndependencies {\n compile enforcedPlatform('"
+ bomCoordinates
+ "')\n"
+ " testRuntime enforcedPlatform('"
+ bomCoordinates
+ "')\n"
+ " testRuntime library.java.junit\n"
+ " testRuntime library.java.hamcrest_core\n"
// This shouldn't be needed. But without this, GcsUtilTest fails
// with NoSuchMethodError on CacheBuilder.expireAfterWrite(Ljava/time/Duration;)
+ " testRuntime \"com.google.guava:guava:30.1-jre\"\n"
+ " testRuntime library.java.hamcrest_library\n");

// Tried compileOnly but analyzeTestClassesDependencies's configuratin cannot resolve
// the dependencies.
// https://github.com/GoogleCloudPlatform/cloud-opensource-java/pull/1982#discussion_r610878573
// buildGradleContent =
// buildGradleContent.replaceAll(
// "compile enforcedPlatform\\(library.java.google_cloud_platform_libraries_bom\\)",
// "compileOnly enforcedPlatform(library.java.google_cloud_platform_libraries_bom)");
Files.asCharSink(gradleFile.toFile(), StandardCharsets.UTF_8).write(buildGradleContent);
}
}

private static void modifyBeamModulePlugin(Path beamModulePluginFile) throws IOException {
// We don't want Beam to `force` dependencies when we run tests, because the `force` overrides
// library versions set in the gcp-lts-bom.
// https://github.com/GoogleCloudPlatform/cloud-opensource-java/pull/1982#discussion_r611911325
String buildGradleContent =
Files.asCharSource(beamModulePluginFile.toFile(), StandardCharsets.UTF_8).read();

String buildGradleContentTestRuntimeClassPathModified =
buildGradleContent.replaceAll(
"config.getName\\(\\) != \"errorprone\"",
"![\"errorprone\", \"testRuntimeClasspath\"].contains(config.getName())");

Verify.verify(
!buildGradleContentTestRuntimeClassPathModified.equals(buildGradleContent),
"The step should modify BeamModulePlugin.groovy");

Files.asCharSink(beamModulePluginFile.toFile(), StandardCharsets.UTF_8)
.write(buildGradleContentTestRuntimeClassPathModified);
}
}
Loading