From 71a16d5a7496857a1faf51f9b4098d1f26fe6cd6 Mon Sep 17 00:00:00 2001 From: cpovirk Date: Mon, 31 Jul 2023 11:52:58 -0700 Subject: [PATCH] Declare versions of test-only dependencies inline instead of in our parent pom. Fixes https://github.com/google/guava/issues/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](https://github.com/google/guava/issues/6657#issuecomment-1658713156): We [really need `dependencyManagement` for Gradle purposes, at least until we specify versions for Gradle explicitly](https://github.com/google/guava/issues/6654#issuecomment-1656580773). 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](https://github.com/google/guava/issues/6654). PiperOrigin-RevId: 552549819 --- android/guava-testlib/pom.xml | 15 ++++++++- android/guava-tests/pom.xml | 14 +++++++++ android/pom.xml | 45 +-------------------------- guava-gwt/pom.xml | 14 +++++++++ guava-testlib/pom.xml | 11 ++++++- guava-tests/pom.xml | 12 ++++++++ pom.xml | 58 +---------------------------------- 7 files changed, 66 insertions(+), 103 deletions(-) diff --git a/android/guava-testlib/pom.xml b/android/guava-testlib/pom.xml index b3211af9c71a..33dc15799d00 100644 --- a/android/guava-testlib/pom.xml +++ b/android/guava-testlib/pom.xml @@ -18,6 +18,10 @@ com.google.code.findbugs jsr305 + + org.checkerframework + checker-qual + com.google.errorprone error_prone_annotations @@ -34,7 +38,8 @@ junit junit - compile + + 4.13.2 com.google.truth truth + ${truth.version} test + + + + com.google.guava + guava + + diff --git a/android/guava-tests/pom.xml b/android/guava-tests/pom.xml index 97ebc0838394..045fa6553150 100644 --- a/android/guava-tests/pom.xml +++ b/android/guava-tests/pom.xml @@ -25,6 +25,10 @@ com.google.code.findbugs jsr305 + + org.checkerframework + checker-qual + com.google.errorprone error_prone_annotations @@ -32,22 +36,32 @@ junit junit + 4.13.2 + test org.mockito mockito-core + 4.11.0 + test com.google.truth truth + ${truth.version} + test com.google.jimfs jimfs + 1.2 + test com.google.caliper caliper + 1.0-beta-3 + test diff --git a/android/pom.xml b/android/pom.xml index b9e4cbe09cd0..38aa5ebc899a 100644 --- a/android/pom.xml +++ b/android/pom.xml @@ -319,50 +319,7 @@ j2objc-annotations 2.8 - - junit - junit - 4.13.2 - test - - - org.mockito - mockito-core - 4.11.0 - test - - - com.google.jimfs - jimfs - 1.2 - test - - - com.google.truth - truth - ${truth.version} - test - - - - com.google.guava - guava - - - - - com.google.caliper - caliper - 1.0-beta-3 - test - - - - com.google.guava - guava - - - + diff --git a/guava-gwt/pom.xml b/guava-gwt/pom.xml index f13e0149305d..277f9d471f64 100644 --- a/guava-gwt/pom.xml +++ b/guava-gwt/pom.xml @@ -90,6 +90,13 @@ ${truth.version} gwt test + + + + com.google.guava + guava + + com.google.truth.extensions @@ -97,6 +104,13 @@ ${truth.version} gwt test + + + + com.google.guava + guava + + org.checkerframework diff --git a/guava-testlib/pom.xml b/guava-testlib/pom.xml index 18626fa9362b..f60890e78e7a 100644 --- a/guava-testlib/pom.xml +++ b/guava-testlib/pom.xml @@ -38,7 +38,8 @@ junit junit - compile + + 4.13.2 com.google.truth truth + ${truth.version} test + + + + com.google.guava + guava + + diff --git a/guava-tests/pom.xml b/guava-tests/pom.xml index 84c982039b49..22af5784f493 100644 --- a/guava-tests/pom.xml +++ b/guava-tests/pom.xml @@ -36,26 +36,38 @@ junit junit + 4.13.2 + test org.mockito mockito-core + 4.11.0 + test com.google.truth truth + ${truth.version} + test com.google.truth.extensions truth-java8-extension + ${truth.version} + test com.google.jimfs jimfs + 1.2 + test com.google.caliper caliper + 1.0-beta-3 + test diff --git a/pom.xml b/pom.xml index 3b63419f0683..7e0fc9c54042 100644 --- a/pom.xml +++ b/pom.xml @@ -313,63 +313,7 @@ j2objc-annotations 2.8 - - junit - junit - 4.13.2 - test - - - org.mockito - mockito-core - 4.11.0 - test - - - com.google.jimfs - jimfs - 1.2 - test - - - com.google.truth - truth - ${truth.version} - test - - - - com.google.guava - guava - - - - - com.google.truth.extensions - truth-java8-extension - ${truth.version} - test - - - - com.google.guava - guava - - - - - com.google.caliper - caliper - 1.0-beta-3 - test - - - - com.google.guava - guava - - - +