Skip to content

Commit

Permalink
Declare versions of test-only dependencies inline instead of in our p…
Browse files Browse the repository at this point in the history
…arent pom.

Fixes #6654, I hope? If `guava` and its parent pom don't refer to `mockito-core`, then `guava` should no longer affect which version of `mockito-core` is selected by Gradle. (Really, it "shouldn't" even now, but there's a mismatch between Maven's model and Gradle's that causes it to do so.)

I had initially attempted (in cl/552479838) to declare versions of _all_ our dependencies inline, but that [didn't work](#6657 (comment)): We [really need `dependencyManagement` for Gradle purposes, at least until we specify versions for Gradle explicitly](#6654 (comment)).

It would be nice if we could still declare our dependency versions only once, now by using `properties`. (In fact, my attempt to use `properties` made me notice that our version of the Error Prone _plugin_ is older than our version of the Error Prone _annotations_.) However, if we were to make that change, then we'd lose the ability to update dependencies with `versions-maven-plugin` (`update-properties` + `use-latest-releases`), I assume because the properties are declared in one `pom.xml` and used in another. (It's possible that Dependabot is better about this, but we've had trouble getting it to work with our unusual 2-flavor, Google-repo-source-of-truth setup.) I notice that we have this problem even today with `truth.version`....

Tested:
  ```
  $ mvn dependency:tree -Dverbose -X -U &> /tmp/pre

  # made changes

  $ mvn dependency:tree -Dverbose -X -U &> /tmp/post

  $ strip() { cat "$@" | grep -v -e 'Dependency collection stats' -e 'Downloading from' -e 'Progress' -e 'Using connector' -e 'Using transporter' -e 'Using mirror' -e maven-dependency-plugin -e SUCCESS -e 'Total time' -e 'Finished at' | sed -e 's/ (.*managed from.*)//'; }; vimdiff <(strip /tmp/pre) <(strip /tmp/post)
  ```

RELNOTES=Changed our Maven project to avoid [affecting which version of Mockito our Gradle users see](#6654).
PiperOrigin-RevId: 552549819
  • Loading branch information
cpovirk authored and Google Java Core Libraries committed Jul 31, 2023
1 parent 9ed0fa6 commit 71a16d5
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 103 deletions.
15 changes: 14 additions & 1 deletion android/guava-testlib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
Expand All @@ -34,15 +38,24 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope><!-- testlib must carry these transitively -->
<!-- *not* <scope>test</scope>; <scope>compile</scope> is right so that guava-testlib users get junit transitively. -->
<version>4.13.2</version>
</dependency>
<dependency>
<!--
Do not include Truth in non-test scope! Doing so creates a problematic dependency cycle.
-->
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down
14 changes: 14 additions & 0 deletions android/guava-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,29 +25,43 @@
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
<artifactId>checker-qual</artifactId>
</dependency>
<dependency>
<groupId>com.google.errorprone</groupId>
<artifactId>error_prone_annotations</artifactId>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.caliper</groupId>
<artifactId>caliper</artifactId>
<version>1.0-beta-3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
45 changes: 1 addition & 44 deletions android/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -319,50 +319,7 @@
<artifactId>j2objc-annotations</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.caliper</groupId>
<artifactId>caliper</artifactId>
<version>1.0-beta-3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- We avoid using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654 -->
</dependencies>
</dependencyManagement>
<profiles>
Expand Down
14 changes: 14 additions & 0 deletions guava-gwt/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,13 +90,27 @@
<version>${truth.version}</version>
<classifier>gwt</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-java8-extension</artifactId>
<version>${truth.version}</version>
<classifier>gwt</classifier>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.checkerframework</groupId>
Expand Down
11 changes: 10 additions & 1 deletion guava-testlib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,24 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>compile</scope><!-- testlib must carry these transitively -->
<!-- *not* <scope>test</scope>; <scope>compile</scope> is right so that guava-testlib users get junit transitively. -->
<version>4.13.2</version>
</dependency>
<dependency>
<!--
Do not include Truth in non-test scope! Doing so creates a problematic dependency cycle.
-->
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down
12 changes: 12 additions & 0 deletions guava-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,38 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-java8-extension</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.caliper</groupId>
<artifactId>caliper</artifactId>
<version>1.0-beta-3</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
Expand Down
58 changes: 1 addition & 57 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -313,63 +313,7 @@
<artifactId>j2objc-annotations</artifactId>
<version>2.8</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<version>1.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.truth.extensions</groupId>
<artifactId>truth-java8-extension</artifactId>
<version>${truth.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.google.caliper</groupId>
<artifactId>caliper</artifactId>
<version>1.0-beta-3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<!-- use the guava we're building. -->
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- We avoid using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654 -->
</dependencies>
</dependencyManagement>
<profiles>
Expand Down

0 comments on commit 71a16d5

Please sign in to comment.