Skip to content

Commit 71a16d5

Browse files
cpovirkGoogle Java Core Libraries
authored and
Google Java Core Libraries
committedJul 31, 2023
Declare versions of test-only dependencies inline instead of in our parent 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
1 parent 9ed0fa6 commit 71a16d5

File tree

7 files changed

+66
-103
lines changed

7 files changed

+66
-103
lines changed
 

‎android/guava-testlib/pom.xml

+14-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
<groupId>com.google.code.findbugs</groupId>
1919
<artifactId>jsr305</artifactId>
2020
</dependency>
21+
<dependency>
22+
<groupId>org.checkerframework</groupId>
23+
<artifactId>checker-qual</artifactId>
24+
</dependency>
2125
<dependency>
2226
<groupId>com.google.errorprone</groupId>
2327
<artifactId>error_prone_annotations</artifactId>
@@ -34,15 +38,24 @@
3438
<dependency>
3539
<groupId>junit</groupId>
3640
<artifactId>junit</artifactId>
37-
<scope>compile</scope><!-- testlib must carry these transitively -->
41+
<!-- *not* <scope>test</scope>; <scope>compile</scope> is right so that guava-testlib users get junit transitively. -->
42+
<version>4.13.2</version>
3843
</dependency>
3944
<dependency>
4045
<!--
4146
Do not include Truth in non-test scope! Doing so creates a problematic dependency cycle.
4247
-->
4348
<groupId>com.google.truth</groupId>
4449
<artifactId>truth</artifactId>
50+
<version>${truth.version}</version>
4551
<scope>test</scope>
52+
<exclusions>
53+
<exclusion>
54+
<!-- use the guava we're building. -->
55+
<groupId>com.google.guava</groupId>
56+
<artifactId>guava</artifactId>
57+
</exclusion>
58+
</exclusions>
4659
</dependency>
4760
</dependencies>
4861
<build>

‎android/guava-tests/pom.xml

+14
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,43 @@
2525
<groupId>com.google.code.findbugs</groupId>
2626
<artifactId>jsr305</artifactId>
2727
</dependency>
28+
<dependency>
29+
<groupId>org.checkerframework</groupId>
30+
<artifactId>checker-qual</artifactId>
31+
</dependency>
2832
<dependency>
2933
<groupId>com.google.errorprone</groupId>
3034
<artifactId>error_prone_annotations</artifactId>
3135
</dependency>
3236
<dependency>
3337
<groupId>junit</groupId>
3438
<artifactId>junit</artifactId>
39+
<version>4.13.2</version>
40+
<scope>test</scope>
3541
</dependency>
3642
<dependency>
3743
<groupId>org.mockito</groupId>
3844
<artifactId>mockito-core</artifactId>
45+
<version>4.11.0</version>
46+
<scope>test</scope>
3947
</dependency>
4048
<dependency>
4149
<groupId>com.google.truth</groupId>
4250
<artifactId>truth</artifactId>
51+
<version>${truth.version}</version>
52+
<scope>test</scope>
4353
</dependency>
4454
<dependency>
4555
<groupId>com.google.jimfs</groupId>
4656
<artifactId>jimfs</artifactId>
57+
<version>1.2</version>
58+
<scope>test</scope>
4759
</dependency>
4860
<dependency>
4961
<groupId>com.google.caliper</groupId>
5062
<artifactId>caliper</artifactId>
63+
<version>1.0-beta-3</version>
64+
<scope>test</scope>
5165
</dependency>
5266
</dependencies>
5367
<build>

‎android/pom.xml

+1-44
Original file line numberDiff line numberDiff line change
@@ -319,50 +319,7 @@
319319
<artifactId>j2objc-annotations</artifactId>
320320
<version>2.8</version>
321321
</dependency>
322-
<dependency>
323-
<groupId>junit</groupId>
324-
<artifactId>junit</artifactId>
325-
<version>4.13.2</version>
326-
<scope>test</scope>
327-
</dependency>
328-
<dependency>
329-
<groupId>org.mockito</groupId>
330-
<artifactId>mockito-core</artifactId>
331-
<version>4.11.0</version>
332-
<scope>test</scope>
333-
</dependency>
334-
<dependency>
335-
<groupId>com.google.jimfs</groupId>
336-
<artifactId>jimfs</artifactId>
337-
<version>1.2</version>
338-
<scope>test</scope>
339-
</dependency>
340-
<dependency>
341-
<groupId>com.google.truth</groupId>
342-
<artifactId>truth</artifactId>
343-
<version>${truth.version}</version>
344-
<scope>test</scope>
345-
<exclusions>
346-
<exclusion>
347-
<!-- use the guava we're building. -->
348-
<groupId>com.google.guava</groupId>
349-
<artifactId>guava</artifactId>
350-
</exclusion>
351-
</exclusions>
352-
</dependency>
353-
<dependency>
354-
<groupId>com.google.caliper</groupId>
355-
<artifactId>caliper</artifactId>
356-
<version>1.0-beta-3</version>
357-
<scope>test</scope>
358-
<exclusions>
359-
<exclusion>
360-
<!-- use the guava we're building. -->
361-
<groupId>com.google.guava</groupId>
362-
<artifactId>guava</artifactId>
363-
</exclusion>
364-
</exclusions>
365-
</dependency>
322+
<!-- We avoid using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654 -->
366323
</dependencies>
367324
</dependencyManagement>
368325
<profiles>

‎guava-gwt/pom.xml

+14
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,27 @@
9090
<version>${truth.version}</version>
9191
<classifier>gwt</classifier>
9292
<scope>test</scope>
93+
<exclusions>
94+
<exclusion>
95+
<!-- use the guava we're building. -->
96+
<groupId>com.google.guava</groupId>
97+
<artifactId>guava</artifactId>
98+
</exclusion>
99+
</exclusions>
93100
</dependency>
94101
<dependency>
95102
<groupId>com.google.truth.extensions</groupId>
96103
<artifactId>truth-java8-extension</artifactId>
97104
<version>${truth.version}</version>
98105
<classifier>gwt</classifier>
99106
<scope>test</scope>
107+
<exclusions>
108+
<exclusion>
109+
<!-- use the guava we're building. -->
110+
<groupId>com.google.guava</groupId>
111+
<artifactId>guava</artifactId>
112+
</exclusion>
113+
</exclusions>
100114
</dependency>
101115
<dependency>
102116
<groupId>org.checkerframework</groupId>

‎guava-testlib/pom.xml

+10-1
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,24 @@
3838
<dependency>
3939
<groupId>junit</groupId>
4040
<artifactId>junit</artifactId>
41-
<scope>compile</scope><!-- testlib must carry these transitively -->
41+
<!-- *not* <scope>test</scope>; <scope>compile</scope> is right so that guava-testlib users get junit transitively. -->
42+
<version>4.13.2</version>
4243
</dependency>
4344
<dependency>
4445
<!--
4546
Do not include Truth in non-test scope! Doing so creates a problematic dependency cycle.
4647
-->
4748
<groupId>com.google.truth</groupId>
4849
<artifactId>truth</artifactId>
50+
<version>${truth.version}</version>
4951
<scope>test</scope>
52+
<exclusions>
53+
<exclusion>
54+
<!-- use the guava we're building. -->
55+
<groupId>com.google.guava</groupId>
56+
<artifactId>guava</artifactId>
57+
</exclusion>
58+
</exclusions>
5059
</dependency>
5160
</dependencies>
5261
<build>

‎guava-tests/pom.xml

+12
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,38 @@
3636
<dependency>
3737
<groupId>junit</groupId>
3838
<artifactId>junit</artifactId>
39+
<version>4.13.2</version>
40+
<scope>test</scope>
3941
</dependency>
4042
<dependency>
4143
<groupId>org.mockito</groupId>
4244
<artifactId>mockito-core</artifactId>
45+
<version>4.11.0</version>
46+
<scope>test</scope>
4347
</dependency>
4448
<dependency>
4549
<groupId>com.google.truth</groupId>
4650
<artifactId>truth</artifactId>
51+
<version>${truth.version}</version>
52+
<scope>test</scope>
4753
</dependency>
4854
<dependency>
4955
<groupId>com.google.truth.extensions</groupId>
5056
<artifactId>truth-java8-extension</artifactId>
57+
<version>${truth.version}</version>
58+
<scope>test</scope>
5159
</dependency>
5260
<dependency>
5361
<groupId>com.google.jimfs</groupId>
5462
<artifactId>jimfs</artifactId>
63+
<version>1.2</version>
64+
<scope>test</scope>
5565
</dependency>
5666
<dependency>
5767
<groupId>com.google.caliper</groupId>
5868
<artifactId>caliper</artifactId>
69+
<version>1.0-beta-3</version>
70+
<scope>test</scope>
5971
</dependency>
6072
</dependencies>
6173
<build>

‎pom.xml

+1-57
Original file line numberDiff line numberDiff line change
@@ -313,63 +313,7 @@
313313
<artifactId>j2objc-annotations</artifactId>
314314
<version>2.8</version>
315315
</dependency>
316-
<dependency>
317-
<groupId>junit</groupId>
318-
<artifactId>junit</artifactId>
319-
<version>4.13.2</version>
320-
<scope>test</scope>
321-
</dependency>
322-
<dependency>
323-
<groupId>org.mockito</groupId>
324-
<artifactId>mockito-core</artifactId>
325-
<version>4.11.0</version>
326-
<scope>test</scope>
327-
</dependency>
328-
<dependency>
329-
<groupId>com.google.jimfs</groupId>
330-
<artifactId>jimfs</artifactId>
331-
<version>1.2</version>
332-
<scope>test</scope>
333-
</dependency>
334-
<dependency>
335-
<groupId>com.google.truth</groupId>
336-
<artifactId>truth</artifactId>
337-
<version>${truth.version}</version>
338-
<scope>test</scope>
339-
<exclusions>
340-
<exclusion>
341-
<!-- use the guava we're building. -->
342-
<groupId>com.google.guava</groupId>
343-
<artifactId>guava</artifactId>
344-
</exclusion>
345-
</exclusions>
346-
</dependency>
347-
<dependency>
348-
<groupId>com.google.truth.extensions</groupId>
349-
<artifactId>truth-java8-extension</artifactId>
350-
<version>${truth.version}</version>
351-
<scope>test</scope>
352-
<exclusions>
353-
<exclusion>
354-
<!-- use the guava we're building. -->
355-
<groupId>com.google.guava</groupId>
356-
<artifactId>guava</artifactId>
357-
</exclusion>
358-
</exclusions>
359-
</dependency>
360-
<dependency>
361-
<groupId>com.google.caliper</groupId>
362-
<artifactId>caliper</artifactId>
363-
<version>1.0-beta-3</version>
364-
<scope>test</scope>
365-
<exclusions>
366-
<exclusion>
367-
<!-- use the guava we're building. -->
368-
<groupId>com.google.guava</groupId>
369-
<artifactId>guava</artifactId>
370-
</exclusion>
371-
</exclusions>
372-
</dependency>
316+
<!-- We avoid using dependencyManagement for test-only deps because of https://github.com/google/guava/issues/6654 -->
373317
</dependencies>
374318
</dependencyManagement>
375319
<profiles>

0 commit comments

Comments
 (0)
Please sign in to comment.