Skip to content

Commit

Permalink
chore: do not include optional dependencies in unmanaged dependency c… (
Browse files Browse the repository at this point in the history
#2410)

* chore: do not include optional dependencies in unmanaged dependency check

* restore gapic bom

* change version in pom

* change pom in tests
  • Loading branch information
JoeWang1127 committed Jan 23, 2024
1 parent 3c61b14 commit 909bdf9
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 56 deletions.
Expand Up @@ -74,7 +74,7 @@ private static Set<String> getManagedDependenciesFromBom(Bom bom)
throws InvalidVersionSpecificationException {
Set<String> res = new HashSet<>();
new ClassPathBuilder()
.resolve(bom.getManagedDependencies(), true, DependencyMediation.MAVEN)
.resolve(bom.getManagedDependencies(), false, DependencyMediation.MAVEN)
.getClassPath()
.forEach(
classPath -> {
Expand Down
Expand Up @@ -13,7 +13,7 @@ public class UnmanagedDependencyCheckTest {
@Test
public void getUnmanagedDependencyFromSamePomTest()
throws MavenRepositoryException, InvalidVersionSpecificationException {
String sharedDependenciesBom = "src/test/resources/shared-dependency-3.18.0-pom.xml";
String sharedDependenciesBom = "src/test/resources/shared-dependency-pom.xml";
List<String> unManagedDependencies =
UnmanagedDependencyCheck.getUnmanagedDependencies(sharedDependenciesBom, sharedDependenciesBom);
assertTrue(unManagedDependencies.isEmpty());
Expand All @@ -24,7 +24,7 @@ public void getUnmanagedDependencyFromGapicAndHandwrittenBomTest()
throws MavenRepositoryException, InvalidVersionSpecificationException {
List<String> unManagedDependencies =
UnmanagedDependencyCheck.getUnmanagedDependencies(
"src/test/resources/shared-dependency-3.18.0-pom.xml",
"src/test/resources/shared-dependency-pom.xml",
"src/test/resources/google-internal-artifact-test-case-pom.xml");
assertTrue(unManagedDependencies.isEmpty());
}
Expand All @@ -34,7 +34,7 @@ public void getUnmanagedDependencyFromNestedPomTest()
throws MavenRepositoryException, InvalidVersionSpecificationException {
List<String> unManagedDependencies =
UnmanagedDependencyCheck.getUnmanagedDependencies(
"src/test/resources/shared-dependency-3.18.0-pom.xml", "src/test/resources/transitive-dependency-pom.xml");
"src/test/resources/shared-dependency-pom.xml", "src/test/resources/transitive-dependency-pom.xml");
assertThat(unManagedDependencies)
.containsAtLeastElementsIn(ImmutableList.of("com.h2database:h2"));
// test dependency should be ignored.
Expand Down
Expand Up @@ -36,29 +36,29 @@
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-datastore-bom</artifactId>
<version>2.17.4</version>
<version>2.18.1</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- this artifact contains com.google.cloud:proto-google-cloud-firestore-bundle-v1 -->
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-firestore-bom</artifactId>
<version>3.15.2</version>
<version>3.16.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable-bom</artifactId>
<version>2.29.0</version>
<version>2.31.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>gapic-libraries-bom</artifactId>
<version>1.23.0</version>
<version>1.27.0</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand Down
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

mvn install -f shared-dependency-3.18.0-pom.xml
mvn install -f shared-dependency-pom.xml
mvn install -f gax-example-pom.xml
mvn install -f nested-dependency-pom.xml
mvn install -f transitive-dependency-pom.xml
Expand Down

This file was deleted.

@@ -0,0 +1,24 @@
<?xml version='1.0' encoding='UTF-8'?>
<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>
<groupId>com.example</groupId>
<artifactId>google-cloud-shared-dependencies-test</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>Google Cloud Shared Dependencies</name>
<description>
Shared build configuration for Google Cloud Java libraries in Tests.
</description>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-shared-dependencies</artifactId>
<version>3.22.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
</project>

0 comments on commit 909bdf9

Please sign in to comment.