From 2f1a50b3e4f2068ec1bc95a534567a8278e2af45 Mon Sep 17 00:00:00 2001 From: Thomas Tresansky Date: Wed, 17 Aug 2022 08:18:29 -0400 Subject: [PATCH 01/71] Add deprecations expectations for Gradle 9.0 Signed-off-by: Paul Merlin --- .../DeprecationMessageBuilder.java | 32 +++++++++++++++++++ .../smoketests/WithAndroidDeprecations.groovy | 2 +- .../smoketests/WithKotlinDeprecations.groovy | 2 +- .../smoketests/WithReportDeprecations.groovy | 32 +++++++++++++++++++ 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithReportDeprecations.groovy diff --git a/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java b/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java index 5acf5ce4aabf..2897fb05a42c 100644 --- a/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java +++ b/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java @@ -26,6 +26,7 @@ public class DeprecationMessageBuilder> { private static final GradleVersion GRADLE8 = GradleVersion.version("8.0"); + private static final GradleVersion GRADLE9 = GradleVersion.version("9.0"); private String summary; private DeprecationTimeline deprecationTimeline; @@ -73,6 +74,31 @@ public WithDeprecationTimeline willChangeInGradle8() { return new WithDeprecationTimeline(this); } + /** + * Output: This is scheduled to be removed in Gradle 9.0. + */ + public WithDeprecationTimeline willBeRemovedInGradle9() { + this.deprecationTimeline = DeprecationTimeline.willBeRemovedInVersion(GRADLE9); + return new WithDeprecationTimeline(this); + } + + /** + * Output: This will fail with an error in Gradle 9.0. + */ + public WithDeprecationTimeline willBecomeAnErrorInGradle9() { + this.deprecationTimeline = DeprecationTimeline.willBecomeAnErrorInVersion(GRADLE9); + return new WithDeprecationTimeline(this); + } + + /** + * Output: This will change in Gradle 9.0. + */ + public WithDeprecationTimeline willChangeInGradle9() { + this.deprecationTimeline = DeprecationTimeline.willChangeInVersion(GRADLE9); + return new WithDeprecationTimeline(this); + } + + void setIndirectUsage() { this.usageType = DeprecatedFeatureUsage.Type.USER_CODE_INDIRECT; } @@ -240,6 +266,12 @@ public WithDeprecationTimeline willBeRemovedInGradle8() { return new WithDeprecationTimeline(this); } + @Override + public WithDeprecationTimeline willBeRemovedInGradle9() { + setDeprecationTimeline(DeprecationTimeline.willBeRemovedInVersion(GRADLE9)); + return new WithDeprecationTimeline(this); + } + public class WithDeprecationTimeline extends DeprecationMessageBuilder.WithDeprecationTimeline { private final DeprecateProperty builder; diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithAndroidDeprecations.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithAndroidDeprecations.groovy index 2fc157120241..78ff71cd3bc7 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithAndroidDeprecations.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithAndroidDeprecations.groovy @@ -20,7 +20,7 @@ import groovy.transform.SelfType import org.gradle.util.internal.VersionNumber @SelfType(BaseDeprecations) -trait WithAndroidDeprecations { +trait WithAndroidDeprecations implements WithReportDeprecations { private static final VersionNumber AGP_VERSION_WITH_FIXED_SKIP_WHEN_EMPTY = VersionNumber.parse('7.1.1') private static final VersionNumber AGP_VERSION_WITH_FIXED_NEW_WORKERS_API = VersionNumber.parse('4.2') diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithKotlinDeprecations.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithKotlinDeprecations.groovy index 31aaf455d001..31677ea00170 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithKotlinDeprecations.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithKotlinDeprecations.groovy @@ -21,7 +21,7 @@ import org.gradle.util.GradleVersion import org.gradle.util.internal.VersionNumber @SelfType(BaseDeprecations) -trait WithKotlinDeprecations { +trait WithKotlinDeprecations implements WithReportDeprecations{ private static final VersionNumber KOTLIN_VERSION_USING_NEW_WORKERS_API = VersionNumber.parse('1.5.0') private static final VersionNumber KOTLIN_VERSION_USING_INPUT_CHANGES_API = VersionNumber.parse('1.6.0') diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithReportDeprecations.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithReportDeprecations.groovy new file mode 100644 index 000000000000..c66199200182 --- /dev/null +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/WithReportDeprecations.groovy @@ -0,0 +1,32 @@ +/* + * Copyright 2022 the original author or authors. + * + * 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 org.gradle.smoketests + +import groovy.transform.SelfType +import org.gradle.util.GradleVersion + +@SelfType(BaseDeprecations) +trait WithReportDeprecations { + private static final String REPORT_DESTINATION_DEPRECATION = "The Report.destination property has been deprecated. " + + "This is scheduled to be removed in Gradle 9.0. " + + "Please use the outputLocation property instead. " + + "See https://docs.gradle.org/${GradleVersion.current().version}/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:destination for more details." + + void expectReportDestinationPropertyDeprecation() { + runner.expectDeprecationWarning(REPORT_DESTINATION_DEPRECATION, "https://github.com/gradle/gradle/issues/21533") + } +} From f7402979bfcdcaed1371c6192da216ec59b90e15 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 15:55:50 +0200 Subject: [PATCH 02/71] Move DocumentationRegistry to :logging It is used for logging purposes only and it requires GradleVersion that needs to be moved there as well in order to be able to nag about deprecations in it. Signed-off-by: Paul Merlin --- .../main/java/org/gradle/api/internal/DocumentationRegistry.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/main/java/org/gradle/api/internal/DocumentationRegistry.java (100%) diff --git a/subprojects/base-services/src/main/java/org/gradle/api/internal/DocumentationRegistry.java b/subprojects/logging/src/main/java/org/gradle/api/internal/DocumentationRegistry.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/api/internal/DocumentationRegistry.java rename to subprojects/logging/src/main/java/org/gradle/api/internal/DocumentationRegistry.java From b43a749dc7188d4a67305f47fc26f125fa25836e Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 16:13:44 +0200 Subject: [PATCH 03/71] Move UnsupportedJavaRuntimeException to :logging It is used for error reporting purposes only and it requires GradleVersion that needs to be moved there as well in order to be able to nag about deprecations in it. Signed-off-by: Paul Merlin --- .../org/gradle/internal/jvm/UnsupportedJavaRuntimeException.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/main/java/org/gradle/internal/jvm/UnsupportedJavaRuntimeException.java (100%) diff --git a/subprojects/base-services/src/main/java/org/gradle/internal/jvm/UnsupportedJavaRuntimeException.java b/subprojects/logging/src/main/java/org/gradle/internal/jvm/UnsupportedJavaRuntimeException.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/internal/jvm/UnsupportedJavaRuntimeException.java rename to subprojects/logging/src/main/java/org/gradle/internal/jvm/UnsupportedJavaRuntimeException.java From 3da36da4a18893d9afdf297f4703a3d4379f585c Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 16:25:47 +0200 Subject: [PATCH 04/71] Move GradleVersion to :logging This is required so that it can use DeprecationLogger in order to nag about deprecations in it. Signed-off-by: Paul Merlin --- subprojects/build-init/build.gradle.kts | 1 + subprojects/build-scan-performance/build.gradle.kts | 1 + subprojects/integ-test/build.gradle.kts | 1 + subprojects/kotlin-dsl-integ-tests/build.gradle.kts | 1 + .../src/main/java/org/gradle/util/GradleVersion.java | 0 .../main/java/org/gradle/util/internal/DefaultGradleVersion.java | 0 subprojects/resources/build.gradle.kts | 1 + subprojects/test-kit/build.gradle.kts | 1 + subprojects/tooling-api/build.gradle.kts | 1 + 9 files changed, 7 insertions(+) rename subprojects/{base-services => logging}/src/main/java/org/gradle/util/GradleVersion.java (100%) rename subprojects/{base-services => logging}/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java (100%) diff --git a/subprojects/build-init/build.gradle.kts b/subprojects/build-init/build.gradle.kts index 91d6f1f7e890..d0d1921c2543 100644 --- a/subprojects/build-init/build.gradle.kts +++ b/subprojects/build-init/build.gradle.kts @@ -47,6 +47,7 @@ dependencies { testFixturesImplementation(project(":base-services")) testFixturesImplementation(project(":platform-base")) testFixturesImplementation(project(":core-api")) + testFixturesImplementation(project(":logging")) testFixturesImplementation(project(":plugins")) testFixturesImplementation(project(":testing-base")) diff --git a/subprojects/build-scan-performance/build.gradle.kts b/subprojects/build-scan-performance/build.gradle.kts index df71afd97f90..58359af5d579 100644 --- a/subprojects/build-scan-performance/build.gradle.kts +++ b/subprojects/build-scan-performance/build.gradle.kts @@ -13,6 +13,7 @@ dependencies { testFixturesApi(project(":base-services")) testFixturesImplementation(project(":internal-testing")) testFixturesImplementation(project(":internal-integ-testing")) + testFixturesImplementation(project(":logging")) testFixturesImplementation(libs.groovyJson) performanceTestDistributionRuntimeOnly(project(":distributions-full")) { diff --git a/subprojects/integ-test/build.gradle.kts b/subprojects/integ-test/build.gradle.kts index 3bcc5fbcf62e..bafa5e429b93 100644 --- a/subprojects/integ-test/build.gradle.kts +++ b/subprojects/integ-test/build.gradle.kts @@ -34,6 +34,7 @@ dependencies { crossVersionTestImplementation(project(":platform-jvm")) crossVersionTestImplementation(project(":language-java")) crossVersionTestImplementation(project(":language-groovy")) + crossVersionTestImplementation(project(":logging")) crossVersionTestImplementation(project(":scala")) crossVersionTestImplementation(project(":ear")) crossVersionTestImplementation(project(":testing-jvm")) diff --git a/subprojects/kotlin-dsl-integ-tests/build.gradle.kts b/subprojects/kotlin-dsl-integ-tests/build.gradle.kts index bd8757151f36..0c9b86118f1f 100644 --- a/subprojects/kotlin-dsl-integ-tests/build.gradle.kts +++ b/subprojects/kotlin-dsl-integ-tests/build.gradle.kts @@ -11,6 +11,7 @@ dependencies { integTestImplementation(project(":core-api")) integTestImplementation(project(":core")) integTestImplementation(project(":internal-testing")) + integTestImplementation(project(":logging")) integTestImplementation("com.squareup.okhttp3:mockwebserver:3.9.1") integTestRuntimeOnly(project(":kotlin-dsl-plugins")) { diff --git a/subprojects/base-services/src/main/java/org/gradle/util/GradleVersion.java b/subprojects/logging/src/main/java/org/gradle/util/GradleVersion.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/util/GradleVersion.java rename to subprojects/logging/src/main/java/org/gradle/util/GradleVersion.java diff --git a/subprojects/base-services/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java rename to subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java diff --git a/subprojects/resources/build.gradle.kts b/subprojects/resources/build.gradle.kts index b83a5745228d..6df415b1249a 100644 --- a/subprojects/resources/build.gradle.kts +++ b/subprojects/resources/build.gradle.kts @@ -8,6 +8,7 @@ dependencies { implementation(project(":base-services")) implementation(project(":enterprise-operations")) implementation(project(":files")) + implementation(project(":logging")) implementation(project(":messaging")) implementation(project(":native")) diff --git a/subprojects/test-kit/build.gradle.kts b/subprojects/test-kit/build.gradle.kts index 12af5cc98a75..442d20590636 100644 --- a/subprojects/test-kit/build.gradle.kts +++ b/subprojects/test-kit/build.gradle.kts @@ -11,6 +11,7 @@ dependencies { implementation(project(":core-api")) implementation(project(":core")) implementation(project(":build-option")) + implementation(project(":logging")) implementation(project(":wrapper-shared")) implementation(project(":tooling-api")) implementation(project(":file-temp")) diff --git a/subprojects/tooling-api/build.gradle.kts b/subprojects/tooling-api/build.gradle.kts index fbf62295e34b..4ace1f739dbf 100644 --- a/subprojects/tooling-api/build.gradle.kts +++ b/subprojects/tooling-api/build.gradle.kts @@ -36,6 +36,7 @@ dependencies { testFixturesImplementation(project(":core-api")) testFixturesImplementation(project(":core")) + testFixturesImplementation(project(":logging")) testFixturesImplementation(project(":model-core")) testFixturesImplementation(project(":base-services")) testFixturesImplementation(project(":base-services-groovy")) From 411f0cb408782cb88b115dc1e8711620b3bd43c7 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 16:29:02 +0200 Subject: [PATCH 05/71] Move deprecated GUtil to :logging So it can use DeprecationLogger in order to nag about its deprecation. This type will be removed later. Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/GUtil.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/main/java/org/gradle/util/GUtil.java (100%) diff --git a/subprojects/base-services/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/util/GUtil.java rename to subprojects/logging/src/main/java/org/gradle/util/GUtil.java From 7f202ffbf79c6a09f352d71f7f71233dfefc573e Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 16:29:12 +0200 Subject: [PATCH 06/71] Move deprecated GFileUtils to :logging So it can use DeprecationLogger in order to nag about its deprecation. This type will be removed later. Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/GFileUtils.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/main/java/org/gradle/util/GFileUtils.java (100%) diff --git a/subprojects/base-services/src/main/java/org/gradle/util/GFileUtils.java b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/util/GFileUtils.java rename to subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java From 47f9b03413a2fc8cbcb068119f14f918e7701432 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 16:29:21 +0200 Subject: [PATCH 07/71] Move deprecated CollectionUtils to :logging So it can use DeprecationLogger in order to nag about its deprecation. This type will be removed later. Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/CollectionUtils.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/main/java/org/gradle/util/CollectionUtils.java (100%) diff --git a/subprojects/base-services/src/main/java/org/gradle/util/CollectionUtils.java b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/util/CollectionUtils.java rename to subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java From a08e8e5ea6cc42ea392ec319fde979d249b198a1 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:03:23 +0200 Subject: [PATCH 08/71] Add section for org.gradle.util nagging in migration guide Signed-off-by: Paul Merlin --- .../src/docs/userguide/migration/upgrading_version_7.adoc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index facb4cb7bbac..05addb1d31b3 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -75,6 +75,11 @@ Invalid specifications are deprecated and will become build errors in Gradle 8.0 See more details about toolchain configuration in the <>. +[[org_gradle_util_reports_deprecations]] +=== Deprecated members of the `org.gradle.util` package now report their deprecation + +These members will be removed in Gradle 9.0. + === Potential breaking changes [[kotlin_1_7_10]] From 7bfca89be0dc5ce511a2450bad15691e77b82205 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:06:56 +0200 Subject: [PATCH 09/71] Nag deprecations for GradleVersion members Signed-off-by: Paul Merlin --- .../migration/upgrading_version_7.adoc | 5 +++++ .../java/org/gradle/util/GradleVersion.java | 16 ++++++++-------- .../util/internal/DefaultGradleVersion.java | 17 +++++++++++++++++ 3 files changed, 30 insertions(+), 8 deletions(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 05addb1d31b3..d745bb1defb5 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -80,6 +80,11 @@ See more details about toolchain configuration in the < { /** * This field only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public static final String URL = "https://www.gradle.org"; @@ -34,7 +34,7 @@ public abstract class GradleVersion implements Comparable { /** * This field only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public static final String RESOURCE_NAME = "/org/gradle/build-receipt.properties"; @@ -42,7 +42,7 @@ public abstract class GradleVersion implements Comparable { /** * This field only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public static final String VERSION_OVERRIDE_VAR = "GRADLE_VERSION_OVERRIDE"; @@ -50,7 +50,7 @@ public abstract class GradleVersion implements Comparable { /** * This field only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public static final String VERSION_NUMBER_PROPERTY = "versionNumber"; @@ -83,7 +83,7 @@ public static GradleVersion version(String version) throws IllegalArgumentExcept /** * This method only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public abstract String getBuildTime(); @@ -91,7 +91,7 @@ public static GradleVersion version(String version) throws IllegalArgumentExcept /** * This method only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public abstract String getRevision(); @@ -115,7 +115,7 @@ public static GradleVersion version(String version) throws IllegalArgumentExcept /** * This method only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public abstract GradleVersion getNextMajor(); @@ -123,7 +123,7 @@ public static GradleVersion version(String version) throws IllegalArgumentExcept /** * This method only kept here to maintain binary compatibility. * - * @deprecated will be removed in Gradle 8. + * @deprecated will be removed in Gradle 9. */ @Deprecated public abstract boolean isValid(); diff --git a/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java index 4b6c92e12e2a..61b3782f7871 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java +++ b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java @@ -19,6 +19,7 @@ import org.gradle.api.GradleException; import org.gradle.internal.UncheckedException; +import org.gradle.internal.deprecation.DeprecationLogger; import org.gradle.util.GradleVersion; import java.io.InputStream; @@ -186,6 +187,10 @@ public String getVersion() { @Override @Deprecated public String getBuildTime() { + DeprecationLogger.deprecateMethod(GradleVersion.class, "getBuildTime()") + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); return getBuildTimestamp(); } @@ -196,6 +201,10 @@ public String getBuildTimestamp() { @Override @Deprecated public String getRevision() { + DeprecationLogger.deprecateMethod(GradleVersion.class, "getRevision()") + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); return getGitRevision(); } @@ -218,6 +227,10 @@ public GradleVersion getBaseVersion() { @Override @Deprecated public GradleVersion getNextMajor() { + DeprecationLogger.deprecateMethod(GradleVersion.class, "getNextMajor()") + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); return getNextMajorVersion(); } @@ -297,6 +310,10 @@ public int hashCode() { @Override @Deprecated public boolean isValid() { + DeprecationLogger.deprecateMethod(GradleVersion.class, "isValid()") + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); return versionPart != null; } From a0b8a5f46d70f6454a2b320580f668110f0d059e Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:07:40 +0200 Subject: [PATCH 10/71] Add capability to nag deprecation of types to DeprecationLogger Signed-off-by: Paul Merlin --- .../internal/deprecation/DeprecationLogger.java | 5 +++++ .../deprecation/DeprecationMessageBuilder.java | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationLogger.java b/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationLogger.java index 9b658f957ccb..01f123a1aca7 100755 --- a/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationLogger.java +++ b/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationLogger.java @@ -197,6 +197,11 @@ public static DeprecationMessageBuilder.DeprecateInvocation deprecateInvocation( return new DeprecationMessageBuilder.DeprecateInvocation(methodWithParams); } + @CheckReturnValue + public static DeprecationMessageBuilder.DeprecateType deprecateType(Class type) { + return new DeprecationMessageBuilder.DeprecateType(type.getCanonicalName()); + } + /** * Output: The ${task} task has been deprecated. */ diff --git a/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java b/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java index 2897fb05a42c..2eaab3a4d817 100644 --- a/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java +++ b/subprojects/logging/src/main/java/org/gradle/internal/deprecation/DeprecationMessageBuilder.java @@ -425,6 +425,23 @@ String formatAdvice(String replacement) { } } + public static class DeprecateType extends WithReplacement { + + DeprecateType(String type) { + super(type); + } + + @Override + String formatSummary(String type) { + return String.format("The %s type has been deprecated.", type); + } + + @Override + String formatAdvice(String replacement) { + return String.format("Please use the %s type instead.", replacement); + } + } + public static class DeprecateTask extends WithReplacement { DeprecateTask(String task) { super(task); From cb116536d4151e32ffe196c8d59dca30969a20ae Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:08:09 +0200 Subject: [PATCH 11/71] Nag deprecation of org.gradle.util.CollectionUtils type Signed-off-by: Paul Merlin --- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + .../src/main/java/org/gradle/util/CollectionUtils.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index d745bb1defb5..02649af5dd5f 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -80,6 +80,7 @@ See more details about toolchain configuration in the < Date: Fri, 2 Sep 2022 17:08:31 +0200 Subject: [PATCH 12/71] Nag deprecation of org.gradle.util.GFileUtils type Signed-off-by: Paul Merlin --- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + .../src/main/java/org/gradle/util/GFileUtils.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 02649af5dd5f..42e0230ab337 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -81,6 +81,7 @@ See more details about toolchain configuration in the < * Plugins should prefer java.io, java.nio or external packages over this class. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class GFileUtils { + static { + DeprecationLogger.deprecateType(GFileUtils.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + public static FileInputStream openInputStream(File file) { try { return FileUtils.openInputStream(file); From 249ecaec706fe7692aa253912c9e1d293a13fb73 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:08:51 +0200 Subject: [PATCH 13/71] Nag deprecation of org.gradle.util.GUtil type Signed-off-by: Paul Merlin --- .../userguide/migration/upgrading_version_7.adoc | 1 + .../logging/src/main/java/org/gradle/util/GUtil.java | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 42e0230ab337..45f0f8e173bf 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -86,6 +86,7 @@ These members will be removed in Gradle 9.0. * `GradleVersion.getNextMajor()` * `GradleVersion.getRevision()` * `GradleVersion.isValid()` +* `GUtil` === Potential breaking changes diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index d73c32c822e8..8e791ad58585 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -24,6 +24,7 @@ import org.gradle.internal.Factory; import org.gradle.internal.IoActions; import org.gradle.internal.UncheckedException; +import org.gradle.internal.deprecation.DeprecationLogger; import org.gradle.internal.io.StreamByteBuffer; import javax.annotation.Nullable; @@ -63,10 +64,18 @@ * Plugins should prefer external collection frameworks over this class. * Internally, all code should use {@link org.gradle.util.internal.GUtil}. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class GUtil { + + static { + DeprecationLogger.deprecateType(GUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private static final Pattern WORD_SEPARATOR = Pattern.compile("\\W+"); private static final Pattern UPPER_LOWER = Pattern.compile("(?m)([A-Z]*)([a-z0-9]*)"); @@ -162,6 +171,7 @@ public static boolean isTrue(@Nullable Object object) { } return true; } + /** * Prefer {@link #getOrDefault(Object, Factory)} if the value is expensive to compute or * would trigger early configuration. From 50856c8033c70b25b6007a7eadc4965cc76e1490 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:09:08 +0200 Subject: [PATCH 14/71] Nag deprecation of org.gradle.util.SingleMessageLogger type Signed-off-by: Paul Merlin --- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + .../java/org/gradle/util/SingleMessageLogger.java | 11 ++++++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 45f0f8e173bf..62ea9fe14fec 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -87,6 +87,7 @@ These members will be removed in Gradle 9.0. * `GradleVersion.getRevision()` * `GradleVersion.isValid()` * `GUtil` +* `SingleMessageLogger` === Potential breaking changes diff --git a/subprojects/logging/src/main/java/org/gradle/util/SingleMessageLogger.java b/subprojects/logging/src/main/java/org/gradle/util/SingleMessageLogger.java index 8a85c8acec43..88698817db2e 100755 --- a/subprojects/logging/src/main/java/org/gradle/util/SingleMessageLogger.java +++ b/subprojects/logging/src/main/java/org/gradle/util/SingleMessageLogger.java @@ -18,11 +18,20 @@ // Used by https://plugins.gradle.org/plugin/nebula.dependency-recommender 9.0.1 // https://github.com/nebula-plugins/nebula-project-plugin/commit/5f56397384328e24c506b0e2b395d1634dbf600f + +import org.gradle.internal.deprecation.DeprecationLogger; + /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class SingleMessageLogger extends org.gradle.internal.deprecation.DeprecationLogger { + static { + DeprecationLogger.deprecateType(SingleMessageLogger.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } } From e09c4224ad8c75118da2bf976829e9a185bc7cca Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:33:17 +0200 Subject: [PATCH 15/71] Nag deprecation of org.gradle.util.ClosureBackedAction type Signed-off-by: Paul Merlin --- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + .../main/java/org/gradle/util/ClosureBackedAction.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 62ea9fe14fec..fd4350ebf4a1 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -80,6 +80,7 @@ See more details about toolchain configuration in the < * To apply a configuration (represented by a Groovy closure) on an object, use {@link org.gradle.api.Project#configure(Object, Closure)}. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. * @param The action type. */ @Deprecated public class ClosureBackedAction implements Action { + static { + DeprecationLogger.deprecateType(ClosureBackedAction.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private final Closure closure; private final int resolveStrategy; private final boolean configurableAware; From 95a9ee7acea7daf731864c5c8f68f47c3213796f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:33:40 +0200 Subject: [PATCH 16/71] Nag deprecation of org.gradle.util.ConfigureUtil type Signed-off-by: Paul Merlin --- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + .../src/main/java/org/gradle/util/ConfigureUtil.java | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index fd4350ebf4a1..c9da2a01049e 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -82,6 +82,7 @@ These members will be removed in Gradle 9.0. * `ClosureBackedAction` * `CollectionUtils` +* `ConfigureUtil` * `GFileUtils` * `GradleVersion.getBuildTime()` * `GradleVersion.getNextMajor()` diff --git a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java index 8dda45e1fb3c..378271e532dd 100644 --- a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java +++ b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java @@ -19,6 +19,7 @@ import groovy.lang.Closure; import org.codehaus.groovy.runtime.GeneratedClosure; import org.gradle.api.Action; +import org.gradle.internal.deprecation.DeprecationLogger; import org.gradle.internal.metaobject.DynamicObjectUtil; import org.gradle.internal.Actions; import org.gradle.internal.metaobject.ConfigureDelegate; @@ -65,11 +66,18 @@ *

* As a last resort, to apply some configuration represented by a Groovy Closure, a plugin can use {@link org.gradle.api.Project#configure(Object, Closure)}. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class ConfigureUtil { + static { + DeprecationLogger.deprecateType(ConfigureUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + public static T configureByMap(Map properties, T delegate) { if (properties.isEmpty()) { return delegate; From 5cf8bb2303ee4ec40f7dd8e8922f466ba6cfd241 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:34:02 +0200 Subject: [PATCH 17/71] Nag deprecation of org.gradle.util.DistributionLocator type Signed-off-by: Paul Merlin --- .../java/org/gradle/util/DistributionLocator.java | 11 ++++++++++- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java b/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java index 273cf542b860..25c2477a249d 100644 --- a/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java +++ b/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java @@ -16,6 +16,7 @@ package org.gradle.util; import org.gradle.internal.UncheckedException; +import org.gradle.internal.deprecation.DeprecationLogger; import java.net.URI; import java.net.URISyntaxException; @@ -23,10 +24,18 @@ /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class DistributionLocator { + + static { + DeprecationLogger.deprecateType(DistributionLocator.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private static final String RELEASE_REPOSITORY = "https://services.gradle.org/distributions"; private static final String SNAPSHOT_REPOSITORY = "https://services.gradle.org/distributions-snapshots"; diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index c9da2a01049e..a5961ef6ca9c 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -83,6 +83,7 @@ These members will be removed in Gradle 9.0. * `ClosureBackedAction` * `CollectionUtils` * `ConfigureUtil` +* `DistributionLocator` * `GFileUtils` * `GradleVersion.getBuildTime()` * `GradleVersion.getNextMajor()` From eb8e77440145d84a3ab099fdd0df476ad4eed34f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:34:21 +0200 Subject: [PATCH 18/71] Nag deprecation of org.gradle.util.NameMatcher type Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/NameMatcher.java | 11 ++++++++++- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java index b757b1660b47..c7cb10ef78c8 100644 --- a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java +++ b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java @@ -20,14 +20,23 @@ import java.util.regex.Pattern; import org.apache.commons.lang.StringUtils; +import org.gradle.internal.deprecation.DeprecationLogger; /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class NameMatcher { + + static { + DeprecationLogger.deprecateType(NameMatcher.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private final SortedSet matches = new TreeSet<>(); private final Set candidates = new TreeSet<>(); private String pattern; diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index a5961ef6ca9c..5e910c9f161c 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -90,6 +90,7 @@ These members will be removed in Gradle 9.0. * `GradleVersion.getRevision()` * `GradleVersion.isValid()` * `GUtil` +* `NameMatcher` * `SingleMessageLogger` === Potential breaking changes From 8b4ce004b4da3fab6d9c276ec1ed1a2249ed63b0 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:34:39 +0200 Subject: [PATCH 19/71] Nag deprecation of org.gradle.util.NameValidator type Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/NameValidator.java | 10 +++++++++- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/NameValidator.java b/subprojects/core/src/main/java/org/gradle/util/NameValidator.java index dd58f2b7e73e..490d75d80d83 100644 --- a/subprojects/core/src/main/java/org/gradle/util/NameValidator.java +++ b/subprojects/core/src/main/java/org/gradle/util/NameValidator.java @@ -18,17 +18,25 @@ import org.apache.commons.lang.StringUtils; import org.gradle.api.InvalidUserDataException; +import org.gradle.internal.deprecation.DeprecationLogger; import java.util.Arrays; /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public final class NameValidator { + static { + DeprecationLogger.deprecateType(NameValidator.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private static final char[] FORBIDDEN_CHARACTERS = new char[] {'/', '\\', ':', '<', '>', '"', '?', '*', '|'}; private static final char FORBIDDEN_LEADING_AND_TRAILING_CHARACTER = '.'; diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 5e910c9f161c..df0021b3f81c 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -91,6 +91,7 @@ These members will be removed in Gradle 9.0. * `GradleVersion.isValid()` * `GUtil` * `NameMatcher` +* `NameValidator` * `SingleMessageLogger` === Potential breaking changes From 326761289c32a281a075e01c9c4f98d966ca1428 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:34:56 +0200 Subject: [PATCH 20/71] Nag deprecation of org.gradle.util.RelativePathUtil type Signed-off-by: Paul Merlin --- .../main/java/org/gradle/util/RelativePathUtil.java | 11 ++++++++++- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java index aad6132e361c..195147d30f4c 100644 --- a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java @@ -17,16 +17,25 @@ package org.gradle.util; import org.gradle.internal.UncheckedException; +import org.gradle.internal.deprecation.DeprecationLogger; import java.io.File; /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class RelativePathUtil { + + static { + DeprecationLogger.deprecateType(RelativePathUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + /** * Returns a relative path from 'from' to 'to' * diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index df0021b3f81c..ff98d58c043d 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -92,6 +92,7 @@ These members will be removed in Gradle 9.0. * `GUtil` * `NameMatcher` * `NameValidator` +* `RelativePathUtil` * `SingleMessageLogger` === Potential breaking changes From ebc9689a29500b90d3080649fe99b5d1c9511bff Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:35:08 +0200 Subject: [PATCH 21/71] Nag deprecation of org.gradle.util.VersionNumber type Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/VersionNumber.java | 11 ++++++++++- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java b/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java index f9e98ff582b6..684e2a822779 100644 --- a/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java +++ b/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java @@ -18,16 +18,25 @@ import com.google.common.base.Objects; import com.google.common.collect.Ordering; +import org.gradle.internal.deprecation.DeprecationLogger; import javax.annotation.Nullable; /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class VersionNumber implements Comparable { + + static { + DeprecationLogger.deprecateType(VersionNumber.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private static final DefaultScheme DEFAULT_SCHEME = new DefaultScheme(); private static final SchemeWithPatchVersion PATCH_SCHEME = new SchemeWithPatchVersion(); public static final VersionNumber UNKNOWN = version(0); diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index ff98d58c043d..02d92cd1bbbb 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -94,6 +94,7 @@ These members will be removed in Gradle 9.0. * `NameValidator` * `RelativePathUtil` * `SingleMessageLogger` +* `VersionNumber` === Potential breaking changes From 5c3f290d8a82a5a3cbdd10dd31fb8e540fc9d594 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 2 Sep 2022 17:35:21 +0200 Subject: [PATCH 22/71] Nag deprecation of org.gradle.util.WrapUtil type Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/WrapUtil.java | 11 ++++++++++- .../docs/userguide/migration/upgrading_version_7.adoc | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java b/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java index 8576d9fec4bf..be7a43444d9f 100644 --- a/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java @@ -18,6 +18,7 @@ import org.gradle.api.DomainObjectSet; import org.gradle.api.internal.CollectionCallbackActionDecorator; import org.gradle.api.internal.DefaultDomainObjectSet; +import org.gradle.internal.deprecation.DeprecationLogger; import java.util.ArrayList; import java.util.Arrays; @@ -35,10 +36,18 @@ /** * This class is only here to maintain binary compatibility with existing plugins. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public class WrapUtil { + + static { + DeprecationLogger.deprecateType(WrapUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + /** * Wraps the given items in a mutable unordered set. */ diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 02d92cd1bbbb..4acdea9b25aa 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -95,6 +95,7 @@ These members will be removed in Gradle 9.0. * `RelativePathUtil` * `SingleMessageLogger` * `VersionNumber` +* `WrapUtil` === Potential breaking changes From 0c88698eec985f4ebe7656dcef47ea209380a49e Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 08:30:25 +0200 Subject: [PATCH 23/71] Temporarily let smoke tests output full deprecation traces Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/AbstractSmokeTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy index 1d4c2f3abbd3..5bb52e55728b 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy @@ -289,7 +289,7 @@ abstract class AbstractSmokeTest extends Specification { private static List outputParameters() { return [ '--warning-mode=all', - "-D${LoggingDeprecatedFeatureHandler.ORG_GRADLE_DEPRECATION_TRACE_PROPERTY_NAME}=false" as String, + "-D${LoggingDeprecatedFeatureHandler.ORG_GRADLE_DEPRECATION_TRACE_PROPERTY_NAME}=true" as String, ] } From 49c798b118821286d6d2efc047a1c97086c8c27f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 08:30:40 +0200 Subject: [PATCH 24/71] Upgrade smoke tested spring dependency management plugin Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/AbstractSmokeTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy index 5bb52e55728b..4e5bd32ae51a 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy @@ -93,7 +93,7 @@ abstract class AbstractSmokeTest extends Specification { static tomcat = "2.7.0" // https://plugins.gradle.org/plugin/io.spring.dependency-management - static springDependencyManagement = "1.0.11.RELEASE" + static springDependencyManagement = "1.0.13.RELEASE" // https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-gradle-plugin static springBoot = "2.5.5" From 097a1215e67f160cff01cc7aa4b1b39d1298be6e Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 08:31:15 +0200 Subject: [PATCH 25/71] Do not nag for GradleVersion.getNextMajor() because the spring dependency management plugin still uses it Signed-off-by: Paul Merlin --- .../java/org/gradle/util/internal/DefaultGradleVersion.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java index 61b3782f7871..2266baf30c73 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java +++ b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java @@ -227,10 +227,13 @@ public GradleVersion getBaseVersion() { @Override @Deprecated public GradleVersion getNextMajor() { + // TODO add nagging once Spring dependency management plugin is fixed + /* DeprecationLogger.deprecateMethod(GradleVersion.class, "getNextMajor()") .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") .nagUser(); + */ return getNextMajorVersion(); } From ab0fa0c6bfc85fe0604ce1a3db89bedafd46d575 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 09:34:58 +0200 Subject: [PATCH 26/71] Upgrade protobuf smoke test to use 0.8.19 Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/AbstractSmokeTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy index 4e5bd32ae51a..3d6ad3c6a90d 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy @@ -128,8 +128,8 @@ abstract class AbstractSmokeTest extends Specification { static errorProne = "2.0.2" // https://plugins.gradle.org/plugin/com.google.protobuf - static protobufPlugin = "0.8.18" - static protobufTools = "3.17.1" + static protobufPlugin = "0.8.19" + static protobufTools = "3.21.5" // https://plugins.gradle.org/plugin/org.gradle.test-retry static testRetryPlugin = "1.3.1" From 25df141e299e05600bf8f46f9f47ffcec82ceb13 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 09:35:38 +0200 Subject: [PATCH 27/71] Do not nag for GUtil.toLowerCase(str) because the protobuf plugin still uses it Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/GUtil.java | 33 ++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index 8e791ad58585..81d26ae33555 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -26,6 +26,7 @@ import org.gradle.internal.UncheckedException; import org.gradle.internal.deprecation.DeprecationLogger; import org.gradle.internal.io.StreamByteBuffer; +import org.gradle.util.internal.CollectionUtils; import javax.annotation.Nullable; import java.io.File; @@ -69,7 +70,7 @@ @Deprecated public class GUtil { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(GUtil.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -102,6 +103,7 @@ public static > T flatten(Collection elements, T addT } public static > T flatten(Collection elements, T addTo, boolean flattenMaps, boolean flattenArrays) { + logDeprecation(); Iterator iter = elements.iterator(); while (iter.hasNext()) { Object element = iter.next(); @@ -149,10 +151,12 @@ public static List flatten(Collection elements) { } public static String asPath(Iterable collection) { + logDeprecation(); return CollectionUtils.join(File.pathSeparator, collection); } public static List prefix(String prefix, Collection strings) { + logDeprecation(); List prefixed = new ArrayList(); for (String string : strings) { prefixed.add(prefix + string); @@ -161,6 +165,7 @@ public static List prefix(String prefix, Collection strings) { } public static boolean isTrue(@Nullable Object object) { + logDeprecation(); if (object == null) { return false; } @@ -187,6 +192,7 @@ public static T getOrDefault(@Nullable T object, Factory defaultValueSupp } public static > T addToCollection(T dest, boolean failOnNull, Iterable src) { + logDeprecation(); for (V v : src) { if (failOnNull && v == null) { throw new IllegalArgumentException("Illegal null value provided in this collection: " + src); @@ -202,6 +208,7 @@ public static > T addToCollection(T dest, Ite @Deprecated public static > T addToCollection(T dest, boolean failOnNull, Iterable... srcs) { + logDeprecation(); for (Iterable src : srcs) { for (V v : src) { if (failOnNull && v == null) { @@ -219,6 +226,7 @@ public static > T addToCollection(T dest, Ite } public static Comparator caseInsensitive() { + logDeprecation(); return new Comparator() { @Override public int compare(String o1, String o2) { @@ -232,6 +240,7 @@ public int compare(String o1, String o2) { } public static Map addMaps(Map map1, Map map2) { + logDeprecation(); HashMap map = new HashMap(); map.putAll(map1); map.putAll(map2); @@ -239,6 +248,7 @@ public static Map addMaps(Map map1, Map map2) { } public static void addToMap(Map dest, Map src) { + logDeprecation(); for (Map.Entry entry : src.entrySet()) { dest.put(entry.getKey().toString(), entry.getValue().toString()); } @@ -268,6 +278,7 @@ public static Properties loadProperties(URL url) { } public static Properties loadProperties(InputStream inputStream) { + logDeprecation(); Properties properties = new Properties(); try { properties.load(inputStream); @@ -280,6 +291,7 @@ public static Properties loadProperties(InputStream inputStream) { } public static void saveProperties(Properties properties, File propertyFile) { + logDeprecation(); try { FileOutputStream propertiesFileOutputStream = new FileOutputStream(propertyFile); try { @@ -293,6 +305,7 @@ public static void saveProperties(Properties properties, File propertyFile) { } public static void saveProperties(Properties properties, OutputStream outputStream) { + logDeprecation(); try { try { properties.store(outputStream, null); @@ -305,6 +318,7 @@ public static void saveProperties(Properties properties, OutputStream outputStre } public static Map map(Object... objects) { + logDeprecation(); Map map = new HashMap(); assert objects.length % 2 == 0; for (int i = 0; i < objects.length; i += 2) { @@ -314,6 +328,7 @@ public static Map map(Object... objects) { } public static String toString(Iterable names) { + logDeprecation(); Formatter formatter = new Formatter(); boolean first = true; for (Object name : names) { @@ -339,6 +354,11 @@ public static String toLowerCamelCase(CharSequence string) { } private static String toCamelCase(CharSequence string, boolean lower) { + if (lower) { + logDeprecation(); + } else { + // TODO log deprecation once protobuf plugin is fixed + } if (string == null) { return null; } @@ -375,6 +395,7 @@ private static String toCamelCase(CharSequence string, boolean lower) { */ public static String toConstant(CharSequence string) { if (string == null) { + logDeprecation(); return null; } return toWords(string, '_').toUpperCase(); @@ -388,6 +409,7 @@ public static String toWords(CharSequence string) { } public static String toWords(CharSequence string, char separator) { + logDeprecation(); if (string == null) { return null; } @@ -425,12 +447,14 @@ public static String toWords(CharSequence string, char separator) { } public static byte[] serialize(Object object) { + logDeprecation(); StreamByteBuffer buffer = new StreamByteBuffer(); serialize(object, buffer.getOutputStream()); return buffer.readAsByteArray(); } public static void serialize(Object object, OutputStream outputStream) { + logDeprecation(); try { ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream); objectOutputStream.writeObject(object); @@ -441,6 +465,7 @@ public static void serialize(Object object, OutputStream outputStream) { } public static Comparator last(final Comparator comparator, final T lastValue) { + logDeprecation(); return new Comparator() { @Override public int compare(T o1, T o2) { @@ -469,6 +494,7 @@ public int compare(T o1, T o2) { */ @Nullable public static T uncheckedCall(Callable callable) { + logDeprecation(); try { return callable.call(); } catch (Exception e) { @@ -477,6 +503,7 @@ public static T uncheckedCall(Callable callable) { } public static > T toEnum(Class enumType, Object value) { + logDeprecation(); if (enumType.isInstance(value)) { return enumType.cast(value); } @@ -524,6 +551,7 @@ public static > EnumSet toEnumSet(Class enumType, Object } public static > EnumSet toEnumSet(Class enumType, Iterable values) { + logDeprecation(); EnumSet result = EnumSet.noneOf(enumType); for (Object value : values) { result.add(toEnum(enumType, value)); @@ -538,6 +566,7 @@ public static > EnumSet toEnumSet(Class enumType, Iterab * this check is faster than converting them to Strings and using {@link String#endsWith(String)}. */ public static boolean endsWith(CharSequence longer, CharSequence shorter) { + logDeprecation(); if (longer instanceof String && shorter instanceof String) { return ((String) longer).endsWith((String) shorter); } @@ -555,6 +584,7 @@ public static boolean endsWith(CharSequence longer, CharSequence shorter) { } public static URI toSecureUrl(URI scriptUri) { + logDeprecation(); try { return new URI("https", null, scriptUri.getHost(), scriptUri.getPort(), scriptUri.getPath(), scriptUri.getQuery(), scriptUri.getFragment()); } catch (URISyntaxException e) { @@ -563,6 +593,7 @@ public static URI toSecureUrl(URI scriptUri) { } public static boolean isSecureUrl(URI url) { + logDeprecation(); /* * TL;DR: http://127.0.0.1 will bypass this validation, http://localhost will fail this validation. * From 143bcbf7a3b266d44a2d0e54dbaf1a427814b7ea Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 09:36:04 +0200 Subject: [PATCH 28/71] Do not nag for ConfigureUtil.configure(closure) because the protobuf plugin still uses it Signed-off-by: Paul Merlin --- .../java/org/gradle/util/ConfigureUtil.java | 23 ++++++++++++------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java index 378271e532dd..1770ca2cb7ea 100644 --- a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java +++ b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java @@ -25,6 +25,7 @@ import org.gradle.internal.metaobject.ConfigureDelegate; import org.gradle.internal.metaobject.DynamicInvokeResult; import org.gradle.internal.metaobject.DynamicObject; +import org.gradle.util.internal.ClosureBackedAction; import javax.annotation.Nullable; import java.util.Collection; @@ -71,14 +72,8 @@ @Deprecated public class ConfigureUtil { - static { - DeprecationLogger.deprecateType(ConfigureUtil.class) - .willBeRemovedInGradle9() - .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") - .nagUser(); - } - public static T configureByMap(Map properties, T delegate) { + logDeprecation(); if (properties.isEmpty()) { return delegate; } @@ -120,7 +115,7 @@ public static T configureByMap(Map properties, T delegate, Collection< public static class IncompleteInputException extends RuntimeException { private final Collection missingKeys; - public IncompleteInputException(String message, Collection missingKeys) { + private IncompleteInputException(String message, Collection missingKeys) { super(message); this.missingKeys = missingKeys; } @@ -144,6 +139,8 @@ public Collection getMissingKeys() { * @return The delegate param */ public static T configure(@Nullable Closure configureClosure, T target) { + // TODO log deprecation once the protobuf plugin is fixed + // logDeprecation(); if (configureClosure == null) { return target; } @@ -161,6 +158,7 @@ public static T configure(@Nullable Closure configureClosure, T target) { * Creates an action that uses the given closure to configure objects of type T. */ public static Action configureUsing(@Nullable final Closure configureClosure) { + logDeprecation(); if (configureClosure == null) { return Actions.doNothing(); } @@ -172,6 +170,7 @@ public static Action configureUsing(@Nullable final Closure configureClos * Called from an object's {@link Configurable#configure} method. */ public static T configureSelf(@Nullable Closure configureClosure, T target) { + logDeprecation(); if (configureClosure == null) { return target; } @@ -184,6 +183,7 @@ public static T configureSelf(@Nullable Closure configureClosure, T target) * Called from an object's {@link Configurable#configure} method. */ public static T configureSelf(@Nullable Closure configureClosure, T target, ConfigureDelegate closureDelegate) { + logDeprecation(); if (configureClosure == null) { return target; } @@ -203,6 +203,13 @@ private static void configureTarget(Closure configureClosure, T target, Conf new ClosureBackedAction(withNewOwner, Closure.OWNER_ONLY, false).execute(target); } + private static void logDeprecation() { + DeprecationLogger.deprecateType(ConfigureUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + /** * Wrapper configure action. * From 2f97bcc19e2fbe02b304fa34260363f6dc9393a4 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 09:36:37 +0200 Subject: [PATCH 29/71] Do not nag for VersionNumber.parse & compareTo because the protobuf/osdetector plugin still uses it Signed-off-by: Paul Merlin --- .../java/org/gradle/util/VersionNumber.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java b/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java index 684e2a822779..0fd6e5d86ac1 100644 --- a/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java +++ b/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java @@ -30,7 +30,7 @@ @Deprecated public class VersionNumber implements Comparable { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(VersionNumber.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -49,49 +49,60 @@ public class VersionNumber implements Comparable { private final AbstractScheme scheme; public VersionNumber(int major, int minor, int micro, @Nullable String qualifier) { - this(major, minor, micro, 0, qualifier, DEFAULT_SCHEME); + this(major, minor, micro, 0, qualifier, DEFAULT_SCHEME, true); } public VersionNumber(int major, int minor, int micro, int patch, @Nullable String qualifier) { - this(major, minor, micro, patch, qualifier, PATCH_SCHEME); + this(major, minor, micro, patch, qualifier, PATCH_SCHEME, true); } - private VersionNumber(int major, int minor, int micro, int patch, @Nullable String qualifier, AbstractScheme scheme) { + private VersionNumber(int major, int minor, int micro, int patch, @Nullable String qualifier, AbstractScheme scheme, boolean logDeprecation) { this.major = major; this.minor = minor; this.micro = micro; this.patch = patch; this.qualifier = qualifier; this.scheme = scheme; + if (logDeprecation) { + logDeprecation(); + } else { + // TODO log deprecation once protobuf/osdetector plugin is fixed + } } public int getMajor() { + logDeprecation(); return major; } public int getMinor() { + logDeprecation(); return minor; } public int getMicro() { + logDeprecation(); return micro; } public int getPatch() { + logDeprecation(); return patch; } @Nullable public String getQualifier() { + logDeprecation(); return qualifier; } public VersionNumber getBaseVersion() { - return new VersionNumber(major, minor, micro, patch, null, scheme); + return new VersionNumber(major, minor, micro, patch, null, scheme, true); } @Override public int compareTo(VersionNumber other) { + // TODO log deprecation once protobuf/osdetector plugin is fixed if (major != other.major) { return major - other.major; } @@ -124,6 +135,7 @@ public int hashCode() { @Override public String toString() { + logDeprecation(); return scheme.format(this); } @@ -132,13 +144,14 @@ public static VersionNumber version(int major) { } public static VersionNumber version(int major, int minor) { - return new VersionNumber(major, minor, 0, 0, null, DEFAULT_SCHEME); + return new VersionNumber(major, minor, 0, 0, null, DEFAULT_SCHEME, false); } /** * Returns the default MAJOR.MINOR.MICRO-QUALIFIER scheme. */ public static Scheme scheme() { + logDeprecation(); return DEFAULT_SCHEME; } @@ -146,10 +159,12 @@ public static Scheme scheme() { * Returns the MAJOR.MINOR.MICRO.PATCH-QUALIFIER scheme. */ public static Scheme withPatchNumber() { + logDeprecation(); return PATCH_SCHEME; } public static VersionNumber parse(String versionString) { + // TODO log deprecation once protobuf/osdetector plugin is fixed return DEFAULT_SCHEME.parse(versionString); } @@ -205,12 +220,12 @@ public VersionNumber parse(@Nullable String versionString) { } if (scanner.isEnd()) { - return new VersionNumber(major, minor, micro, patch, null, this); + return new VersionNumber(major, minor, micro, patch, null, this, false); } if (scanner.isQualifier()) { scanner.skipSeparator(); - return new VersionNumber(major, minor, micro, patch, scanner.remainder(), this); + return new VersionNumber(major, minor, micro, patch, scanner.remainder(), this, false); } return UNKNOWN; From 0ef522a3a8479f35419b972cb48ec1e0385bbc88 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 11:30:51 +0200 Subject: [PATCH 30/71] Do not nag for WrapUtil.toDomainObjectSet() because the kotlin gradle plugin still uses it Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/WrapUtil.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java b/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java index be7a43444d9f..8e0754306459 100644 --- a/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java @@ -41,7 +41,7 @@ @Deprecated public class WrapUtil { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(WrapUtil.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -54,6 +54,7 @@ public class WrapUtil { @SafeVarargs @SuppressWarnings("varargs") public static Set toSet(T... items) { + logDeprecation(); Set coll = new HashSet(); Collections.addAll(coll, items); return coll; @@ -65,6 +66,7 @@ public static Set toSet(T... items) { @SafeVarargs @SuppressWarnings("varargs") public static DomainObjectSet toDomainObjectSet(Class type, T... items) { + // TODO log deprecation when Kotlin plugin is fixed DefaultDomainObjectSet set = new DefaultDomainObjectSet(type, CollectionCallbackActionDecorator.NOOP); set.addAll(Arrays.asList(items)); return set; @@ -76,6 +78,7 @@ public static DomainObjectSet toDomainObjectSet(Class type, T... items @SafeVarargs @SuppressWarnings("varargs") public static Set toLinkedSet(T... items) { + logDeprecation(); Set coll = new LinkedHashSet(); Collections.addAll(coll, items); return coll; @@ -87,6 +90,7 @@ public static Set toLinkedSet(T... items) { @SafeVarargs @SuppressWarnings("varargs") public static SortedSet toSortedSet(T... items) { + logDeprecation(); SortedSet coll = new TreeSet(); Collections.addAll(coll, items); return coll; @@ -98,6 +102,7 @@ public static SortedSet toSortedSet(T... items) { @SafeVarargs @SuppressWarnings("varargs") public static SortedSet toSortedSet(Comparator comp, T... items) { + logDeprecation(); SortedSet coll = new TreeSet(comp); Collections.addAll(coll, items); return coll; @@ -109,6 +114,7 @@ public static SortedSet toSortedSet(Comparator comp, T... items) { @SafeVarargs @SuppressWarnings("varargs") public static List toList(T... items) { + logDeprecation(); ArrayList coll = new ArrayList(); Collections.addAll(coll, items); return coll; @@ -118,6 +124,7 @@ public static List toList(T... items) { * Wraps the given items in a mutable list. */ public static List toList(Iterable items) { + logDeprecation(); ArrayList coll = new ArrayList(); for (T item : items) { coll.add(item); @@ -129,6 +136,7 @@ public static List toList(Iterable items) { * Wraps the given key and value in a mutable unordered map. */ public static Map toMap(K key, V value) { + logDeprecation(); Map map = new HashMap(); map.put(key, value); return map; @@ -137,6 +145,7 @@ public static Map toMap(K key, V value) { @SafeVarargs @SuppressWarnings("varargs") public static T[] toArray(T... items) { + logDeprecation(); return items; } From ba4f67048ad9dbae72b69fe37b97aabe1110a9d6 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 11:43:58 +0200 Subject: [PATCH 31/71] Do not nag for GUtil.toWords() because the android plugin still uses it Signed-off-by: Paul Merlin --- subprojects/logging/src/main/java/org/gradle/util/GUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index 81d26ae33555..e98acb3ab320 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -409,7 +409,7 @@ public static String toWords(CharSequence string) { } public static String toWords(CharSequence string, char separator) { - logDeprecation(); + // TODO log deprecation once android plugin is fixed if (string == null) { return null; } From 6945370a75238c7e29fc1d8e9a976115fd31bc8f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 12:24:43 +0200 Subject: [PATCH 32/71] Restore binary compatibility Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/ConfigureUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java index 1770ca2cb7ea..8bbebcb26a44 100644 --- a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java +++ b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java @@ -115,9 +115,10 @@ public static T configureByMap(Map properties, T delegate, Collection< public static class IncompleteInputException extends RuntimeException { private final Collection missingKeys; - private IncompleteInputException(String message, Collection missingKeys) { + public IncompleteInputException(String message, Collection missingKeys) { super(message); this.missingKeys = missingKeys; + logDeprecation(); } public Collection getMissingKeys() { From 8b4c032fdf291b817a534dd9731c7acb84a58aee Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 12:25:07 +0200 Subject: [PATCH 33/71] Let deprecated GFileUtils use non-deprecated CollectionUtils to simplify deprecation reports Signed-off-by: Paul Merlin --- .../logging/src/main/java/org/gradle/util/GFileUtils.java | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java index 6a96bedb1998..fa13d0a10700 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java @@ -21,6 +21,7 @@ import org.gradle.api.UncheckedIOException; import org.gradle.internal.IoActions; import org.gradle.internal.deprecation.DeprecationLogger; +import org.gradle.util.internal.CollectionUtils; import org.gradle.util.internal.LimitedDescription; import javax.annotation.Nullable; From d449450fd4f6ef4d38b96b2bee4f30dc42649ccd Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 12:25:15 +0200 Subject: [PATCH 34/71] Bump TAPI jar size Signed-off-by: Paul Merlin --- .../tooling/ToolingApiClasspathIntegrationTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/tooling-api/src/integTest/groovy/org/gradle/integtests/tooling/ToolingApiClasspathIntegrationTest.groovy b/subprojects/tooling-api/src/integTest/groovy/org/gradle/integtests/tooling/ToolingApiClasspathIntegrationTest.groovy index d4f8e8e35dc6..14f123e03e0e 100644 --- a/subprojects/tooling-api/src/integTest/groovy/org/gradle/integtests/tooling/ToolingApiClasspathIntegrationTest.groovy +++ b/subprojects/tooling-api/src/integTest/groovy/org/gradle/integtests/tooling/ToolingApiClasspathIntegrationTest.groovy @@ -34,6 +34,6 @@ class ToolingApiClasspathIntegrationTest extends AbstractIntegrationSpec { resolve.classpath.any {it.name ==~ /slf4j-api-.*\.jar/} // If this suddenly fails without an obvious reason, you likely have added some code // that references types that were previously eliminated from gradle-tooling-api.jar. - resolve.classpath.find { it.name ==~ /gradle-tooling-api.*\.jar/ }.size() < 2_500_000 + resolve.classpath.find { it.name ==~ /gradle-tooling-api.*\.jar/ }.size() < 2_600_000 } } From 82b9db41ac4211a571bd01436bb47a329e10ec54 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 13:16:18 +0200 Subject: [PATCH 35/71] Revert "Temporarily let smoke tests output full deprecation traces" This reverts commit f7a3003edda4bfc56c09c1aaeb621002394b356a. Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/AbstractSmokeTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy index 3d6ad3c6a90d..0b19d435e327 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy @@ -289,7 +289,7 @@ abstract class AbstractSmokeTest extends Specification { private static List outputParameters() { return [ '--warning-mode=all', - "-D${LoggingDeprecatedFeatureHandler.ORG_GRADLE_DEPRECATION_TRACE_PROPERTY_NAME}=true" as String, + "-D${LoggingDeprecatedFeatureHandler.ORG_GRADLE_DEPRECATION_TRACE_PROPERTY_NAME}=false" as String, ] } From b66902adecab9a7b4f7123acaf1a173bb03f2009 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 13:51:44 +0200 Subject: [PATCH 36/71] Do not nag for CollectionUtils.stringize(collection) because the asciidoctor plugin still uses it Signed-off-by: Paul Merlin --- .../java/org/gradle/util/CollectionUtils.java | 81 +++++++++++++++++-- 1 file changed, 75 insertions(+), 6 deletions(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java index af097e322d2d..675576313dde 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java @@ -64,7 +64,7 @@ @Deprecated public abstract class CollectionUtils { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(CollectionUtils.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -76,13 +76,20 @@ public abstract class CollectionUtils { */ @Nullable public static T findSingle(Iterable source) { - return Iterables.isEmpty(source) ? null : single(source); + logDeprecation(); + return Iterables.isEmpty(source) ? null : singleInternal(source); } /** * Returns the single element in the collection or throws. */ public static T single(Iterable source) { + logDeprecation(); + return singleInternal(source); + } + + private static T singleInternal(Iterable source) { + logDeprecation(); Iterator iterator = source.iterator(); if (!iterator.hasNext()) { throw new NoSuchElementException("Expecting collection with single element, got none."); @@ -95,6 +102,7 @@ public static T single(Iterable source) { } public static Collection checkedCast(Class type, Collection input) { + logDeprecation(); for (Object o : input) { castNullable(type, o); } @@ -103,6 +111,7 @@ public static Collection checkedCast(Class type, Collection< @Nullable public static T findFirst(Iterable source, Spec filter) { + logDeprecation(); for (T item : source) { if (filter.isSatisfiedBy(item)) { return item; @@ -114,6 +123,7 @@ public static T findFirst(Iterable source, Spec filt @Nullable public static T findFirst(T[] source, Spec filter) { + logDeprecation(); for (T thing : source) { if (filter.isSatisfiedBy(thing)) { return thing; @@ -124,6 +134,7 @@ public static T findFirst(T[] source, Spec filter) { } public static T first(Iterable source) { + logDeprecation(); return source.iterator().next(); } @@ -167,6 +178,7 @@ public static > List sort(Iterable things) { } public static > C filter(Iterable source, C destination, Spec filter) { + logDeprecation(); for (T item : source) { if (filter.isSatisfiedBy(item)) { destination.add(item); @@ -180,6 +192,7 @@ public static Map filter(Map map, Spec> filte } public static Map filter(Map map, Map destination, Spec> filter) { + logDeprecation(); for (Map.Entry entry : map.entrySet()) { if (filter.isSatisfiedBy(entry)) { destination.put(entry.getKey(), entry.getValue()); @@ -195,6 +208,7 @@ public static R[] collectArray(I[] list, Class newType, Transformer R[] collectArray(I[] list, R[] destination, Transformer transformer) { + logDeprecation(); assert list.length <= destination.length; for (int i = 0; i < list.length; ++i) { destination[i] = transformer.transform(list[i]); @@ -220,6 +234,11 @@ public static List collect(Iterable source, Transformer> C collect(Iterable source, C destination, Transformer transformer) { + logDeprecation(); + return collectInternal(source, destination, transformer); + } + + private static > C collectInternal(Iterable source, C destination, Transformer transformer) { for (I item : source) { destination.add(transformer.transform(item)); } @@ -254,6 +273,11 @@ public static List flattenCollections(Object... things) { * @return A flattened list of the given things */ public static List flattenCollections(Class type, Object... things) { + logDeprecation(); + return flattenCollectionsInternal(type, things); + } + + private static List flattenCollectionsInternal(Class type, Object... things) { if (things == null) { return Collections.singletonList(null); } else if (things.length == 0) { @@ -298,6 +322,7 @@ public static List flattenCollections(Class type, Object... things) { public static List toList(Iterable things) { if (things instanceof List) { + logDeprecation(); @SuppressWarnings("unchecked") List castThings = (List) things; return castThings; } @@ -305,6 +330,7 @@ public static List toList(Iterable things) { } public static List toList(Enumeration things) { + logDeprecation(); AbstractList list = new ArrayList(); while (things.hasMoreElements()) { list.add(things.nextElement()); @@ -313,6 +339,7 @@ public static List toList(Enumeration things) { } private static List toMutableList(Iterable things) { + logDeprecation(); if (things == null) { return new ArrayList(0); } @@ -325,6 +352,7 @@ private static List toMutableList(Iterable things) { public static List intersection(Collection> availableValuesByDescriptor) { + logDeprecation(); List result = new ArrayList(); Iterator> iterator = availableValuesByDescriptor.iterator(); if (iterator.hasNext()) { @@ -340,6 +368,7 @@ public static List intersection(Collection> avail } public static List toList(T[] things) { + logDeprecation(); if (things == null || things.length == 0) { return new ArrayList(0); } @@ -350,6 +379,7 @@ public static List toList(T[] things) { } public static Set toSet(Iterable things) { + logDeprecation(); if (things == null) { return new HashSet(0); } @@ -366,6 +396,7 @@ public static Set toSet(Iterable things) { } public static List compact(List list) { + logDeprecation(); boolean foundAtLeastOneNull = false; List compacted = null; int i = 0; @@ -389,14 +420,21 @@ public static List compact(List list) { } public static > C stringize(Iterable source, C destination) { - return collect(source, destination, Transformers.asString()); + logDeprecation(); + return stringizeInternal(source, destination); } public static List stringize(Collection source) { - return stringize(source, new ArrayList(source.size())); + // TODO log deprecation once asciidoctor/grolifant is fixed + return stringizeInternal(source, new ArrayList(source.size())); + } + + private static > C stringizeInternal(Iterable source, C destination) { + return collectInternal(source, destination, Transformers.asString()); } public static boolean replace(List list, Spec filter, Transformer transformer) { + logDeprecation(); boolean replaced = false; int i = 0; for (E it : list) { @@ -410,6 +448,7 @@ public static boolean replace(List list, Spec filter, Transfor } public static void collectMap(Map destination, Iterable items, Transformer keyGenerator) { + logDeprecation(); for (V item : items) { destination.put(keyGenerator.transform(item), item); } @@ -425,6 +464,7 @@ public static Map collectMap(Iterable items, Transform } public static void collectMapValues(Map destination, Iterable keys, Transformer keyGenerator) { + logDeprecation(); for (K item : keys) { destination.put(item, keyGenerator.transform(item)); } @@ -440,6 +480,7 @@ public static Map collectMapValues(Iterable keys, Tran } public static boolean every(Iterable things, Spec predicate) { + logDeprecation(); for (T thing : things) { if (!predicate.isSatisfiedBy(thing)) { return false; @@ -458,6 +499,7 @@ public static boolean every(Iterable things, Spec pr * @return t1 */ public static > C addAll(C t1, Iterable t2) { + logDeprecation(); for (T t : t2) { t1.add(t); } @@ -473,6 +515,7 @@ public static > C addAll(C t1, Iterable> C addAll(C t1, T... t2) { + logDeprecation(); Collections.addAll(t1, t2); return t1; } @@ -487,6 +530,16 @@ public static class SetDiff { public Set leftOnly = new HashSet(); public Set> common = new HashSet>(); public Set rightOnly = new HashSet(); + + public SetDiff() { + this(true); + } + + private SetDiff(boolean logDeprecation) { + if (logDeprecation) { + logDeprecation(); + } + } } /** @@ -503,6 +556,7 @@ public static class SetDiff { * @return A representation of the difference */ public static SetDiff diffSetsBy(Set left, Set right, Transformer compareBy) { + logDeprecation(); if (left == null) { throw new NullPointerException("'left' set is null"); } @@ -510,7 +564,7 @@ public static SetDiff diffSetsBy(Set left, Set throw new NullPointerException("'right' set is null"); } - SetDiff setDiff = new SetDiff(); + SetDiff setDiff = new SetDiff(false); Map indexedLeft = collectMap(left, compareBy); Map indexedRight = collectMap(right, compareBy); @@ -569,6 +623,7 @@ public static String join(String separator, Object[] objects) { * @return The joined string */ public static String join(String separator, Iterable objects) { + logDeprecation(); if (separator == null) { throw new NullPointerException("The 'separator' cannot be null"); } @@ -595,6 +650,7 @@ public static String join(String separator, Iterable objects) { *
Right
Collection containing entries that do NOT satisfy the given predicate */ public static Pair, Collection> partition(Iterable items, Spec predicate) { + logDeprecation(); Preconditions.checkNotNull(items, "Cannot partition null Collection"); Preconditions.checkNotNull(predicate, "Cannot apply null Spec when partitioning"); @@ -614,6 +670,7 @@ public static Pair, Collection> partition(Iterable items /** * Injection step. + * * @param target type. * @param item type. */ @@ -623,8 +680,15 @@ public static class InjectionStep { private final I item; public InjectionStep(T target, I item) { + this(target, item, true); + } + + private InjectionStep(T target, I item, boolean logDeprecation) { this.target = target; this.item = item; + if (logDeprecation) { + logDeprecation(); + } } public T getTarget() { @@ -637,6 +701,7 @@ public I getItem() { } public static T inject(T target, Iterable items, Action> action) { + logDeprecation(); if (target == null) { throw new NullPointerException("The 'target' cannot be null"); } @@ -648,12 +713,13 @@ public static T inject(T target, Iterable items, Action(target, item)); + action.execute(new InjectionStep(target, item, false)); } return target; } public static Map> groupBy(Iterable iterable, Transformer grouper) { + logDeprecation(); ImmutableListMultimap.Builder builder = ImmutableListMultimap.builder(); for (V element : iterable) { @@ -665,6 +731,7 @@ public static Map> groupBy(Iterable iterabl } public static Iterable unpack(final Iterable> factories) { + logDeprecation(); return new Iterable() { private final Iterator> delegate = factories.iterator(); @@ -692,11 +759,13 @@ public void remove() { @Nullable public static List nonEmptyOrNull(Iterable iterable) { + logDeprecation(); ImmutableList list = ImmutableList.copyOf(iterable); return list.isEmpty() ? null : list; } public static String asCommandLine(Iterable arguments) { + logDeprecation(); return Joiner.on(" ").join(collect(arguments, Transformers.asSafeCommandLineArgument())); } } From 8b015f6c80296c1d066997f97dec2842e24ac46f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 13:58:28 +0200 Subject: [PATCH 37/71] Move GFileUtils deprecation logging from static to members in order to make deprecation logging more predictible now that the discovery phase is done Signed-off-by: Paul Merlin --- .../main/java/org/gradle/util/GFileUtils.java | 49 +++++++++++++++++-- 1 file changed, 45 insertions(+), 4 deletions(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java index fa13d0a10700..d2b594e00d02 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java @@ -53,7 +53,7 @@ @Deprecated public class GFileUtils { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(GFileUtils.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -61,6 +61,7 @@ public class GFileUtils { } public static FileInputStream openInputStream(File file) { + logDeprecation(); try { return FileUtils.openInputStream(file); } catch (IOException e) { @@ -73,9 +74,10 @@ public static FileInputStream openInputStream(File file) { * (or directory) does not exist, a new file is created. */ public static void touch(File file) { + logDeprecation(); try { if (!file.createNewFile()) { - touchExisting(file); + touchExistingInternal(file); } } catch (IOException e) { throw new UncheckedIOException(e); @@ -87,6 +89,11 @@ public static void touch(File file) { * (or directory) must exist. */ public static void touchExisting(File file) { + logDeprecation(); + touchExistingInternal(file); + } + + private static void touchExistingInternal(File file) { try { Files.setLastModifiedTime(file.toPath(), FileTime.fromMillis(System.currentTimeMillis())); } catch (IOException e) { @@ -114,6 +121,11 @@ private static void touchFileByWritingEmptyByteArray(File file) { } public static void moveFile(File source, File destination) { + logDeprecation(); + moveFileInternal(source, destination); + } + + private static void moveFileInternal(File source, File destination) { try { FileUtils.moveFile(source, destination); } catch (IOException e) { @@ -122,9 +134,10 @@ public static void moveFile(File source, File destination) { } public static void moveExistingFile(File source, File destination) { + logDeprecation(); boolean rename = source.renameTo(destination); if (!rename) { - moveFile(source, destination); + moveFileInternal(source, destination); } } @@ -134,6 +147,7 @@ public static void moveExistingFile(File source, File destination) { * @see FileUtils#copyFile(File, File) */ public static void copyFile(File source, File destination) { + logDeprecation(); try { FileUtils.copyFile(source, destination); } catch (IOException e) { @@ -142,6 +156,7 @@ public static void copyFile(File source, File destination) { } public static void copyDirectory(File source, File destination) { + logDeprecation(); try { FileUtils.copyDirectory(source, destination); } catch (IOException e) { @@ -150,6 +165,11 @@ public static void copyDirectory(File source, File destination) { } public static void moveDirectory(File source, File destination) { + logDeprecation(); + moveDirectoryInternal(source, destination); + } + + public static void moveDirectoryInternal(File source, File destination) { try { FileUtils.moveDirectory(source, destination); } catch (IOException e) { @@ -158,6 +178,7 @@ public static void moveDirectory(File source, File destination) { } public static void moveExistingDirectory(File source, File destination) { + logDeprecation(); boolean rename = source.renameTo(destination); if (!rename) { moveDirectory(source, destination); @@ -169,6 +190,7 @@ public static String readFile(File file) { } public static String readFile(File file, String encoding) { + logDeprecation(); try { return FileUtils.readFileToString(file, encoding); } catch (IOException e) { @@ -196,6 +218,7 @@ public static void writeFile(String content, File destination) { } public static void writeFile(String content, File destination, String encoding) { + logDeprecation(); try { FileUtils.writeStringToFile(destination, content, encoding); } catch (IOException e) { @@ -204,10 +227,12 @@ public static void writeFile(String content, File destination, String encoding) } public static Collection listFiles(File directory, String[] extensions, boolean recursive) { + logDeprecation(); return FileUtils.listFiles(directory, extensions, recursive); } public static List toPaths(Collection files) { + logDeprecation(); List paths = new ArrayList(); for (File file : files) { paths.add(file.getAbsolutePath()); @@ -216,6 +241,7 @@ public static List toPaths(Collection files) { } public static void copyURLToFile(URL source, File destination) { + logDeprecation(); try { FileUtils.copyURLToFile(source, destination); } catch (IOException e) { @@ -224,6 +250,7 @@ public static void copyURLToFile(URL source, File destination) { } public static void deleteDirectory(File directory) { + logDeprecation(); try { FileUtils.deleteDirectory(directory); } catch (IOException e) { @@ -232,6 +259,7 @@ public static void deleteDirectory(File directory) { } public static boolean deleteQuietly(@Nullable File file) { + logDeprecation(); return FileUtils.deleteQuietly(file); } @@ -240,8 +268,16 @@ public static boolean deleteQuietly(@Nullable File file) { */ @Deprecated public static class TailReadingException extends RuntimeException { + public TailReadingException(Throwable throwable) { + this(throwable, true); + } + + private TailReadingException(Throwable throwable, boolean logDeprecation) { super(throwable); + if (logDeprecation) { + logDeprecation(); + } } } @@ -254,6 +290,7 @@ public TailReadingException(Throwable throwable) { * @throws org.gradle.util.GFileUtils.TailReadingException when reading failed */ public static String tail(File file, int maxLines) throws TailReadingException { + logDeprecation(); BufferedReader reader = null; FileReader fileReader = null; try { @@ -268,7 +305,7 @@ public static String tail(File file, int maxLines) throws TailReadingException { } return description.toString(); } catch (Exception e) { - throw new TailReadingException(e); + throw new TailReadingException(e, false); } finally { IoActions.closeQuietly(fileReader); IoActions.closeQuietly(reader); @@ -276,6 +313,7 @@ public static String tail(File file, int maxLines) throws TailReadingException { } public static void forceDelete(File file) { + logDeprecation(); try { FileUtils.forceDelete(file); } catch (IOException e) { @@ -284,6 +322,7 @@ public static void forceDelete(File file) { } public static Checksum checksum(File file, Checksum checksum) { + logDeprecation(); try { return FileUtils.checksum(file, checksum); } catch (IOException e) { @@ -310,6 +349,7 @@ public static File parentMkdirs(File child) { * @param dir The dir to create, including any non existent parent dirs. */ public static void mkdirs(File dir) { + logDeprecation(); dir = dir.getAbsoluteFile(); if (dir.isDirectory()) { return; @@ -355,6 +395,7 @@ public static void mkdirs(File dir) { * @return the path of target relative to base. */ public static String relativePathOf(File target, File base) { + logDeprecation(); String separatorChars = "/" + File.separator; List basePath = splitAbsolutePathOf(base, separatorChars); List targetPath = new ArrayList(splitAbsolutePathOf(target, separatorChars)); From c2dbda0aa6a35581ed7617169c035b2673cc1d92 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:07:20 +0200 Subject: [PATCH 38/71] Move RelativePathUtil deprecation logging from static to members in order to make deprecation logging more predictible now that the discovery phase is done Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/RelativePathUtil.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java index 195147d30f4c..36dac3b12ff4 100644 --- a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java @@ -29,7 +29,7 @@ @Deprecated public class RelativePathUtil { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(RelativePathUtil.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -44,6 +44,7 @@ public class RelativePathUtil { * @return The relative path */ public static String relativePath(File from, File to) { + logDeprecation(); try { return TextUtil.normaliseFileSeparators(from.toPath().relativize(to.toPath()).toString()); } catch (Exception e) { From e9efaa9e327480e1909a26dd01019545580317e5 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:07:29 +0200 Subject: [PATCH 39/71] Move NameValidator deprecation logging from static to members in order to make deprecation logging more predictible now that the discovery phase is done Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/NameValidator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/NameValidator.java b/subprojects/core/src/main/java/org/gradle/util/NameValidator.java index 490d75d80d83..5480b391fa42 100644 --- a/subprojects/core/src/main/java/org/gradle/util/NameValidator.java +++ b/subprojects/core/src/main/java/org/gradle/util/NameValidator.java @@ -30,7 +30,7 @@ @Deprecated public final class NameValidator { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(NameValidator.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -46,6 +46,7 @@ private NameValidator() { } * Validates that a given name string does not contain any forbidden characters. */ public static void validate(String name, String nameDescription, String fixSuggestion) throws InvalidUserDataException { + logDeprecation(); if (StringUtils.isEmpty(name)) { throw newInvalidUserDataException("The " + nameDescription + " must not be empty.", fixSuggestion); } else if (StringUtils.containsAny(name, FORBIDDEN_CHARACTERS)) { From 52ba0137c45b2d1468a0eca715099c2b4a389a19 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:07:39 +0200 Subject: [PATCH 40/71] Move NameMatcher deprecation logging from static to members in order to make deprecation logging more predictible now that the discovery phase is done Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/NameMatcher.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java index c7cb10ef78c8..f9233f1b7277 100644 --- a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java +++ b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java @@ -30,7 +30,7 @@ @Deprecated public class NameMatcher { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(NameMatcher.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -41,6 +41,10 @@ public class NameMatcher { private final Set candidates = new TreeSet<>(); private String pattern; + public NameMatcher() { + logDeprecation(); + } + /** * Locates the best match for a camel case pattern in a key set of a map and returns the corresponding value. * From 44bb61df220131c6ec48ef070c19dbcd185afc2c Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:07:49 +0200 Subject: [PATCH 41/71] Move DistributionLocator deprecation logging from static to members in order to make deprecation logging more predictible now that the discovery phase is done Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/DistributionLocator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java b/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java index 25c2477a249d..76b4f4576d7a 100644 --- a/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java +++ b/subprojects/core/src/main/java/org/gradle/util/DistributionLocator.java @@ -29,7 +29,7 @@ @Deprecated public class DistributionLocator { - static { + private static void logDeprecation() { DeprecationLogger.deprecateType(DistributionLocator.class) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") @@ -39,6 +39,10 @@ public class DistributionLocator { private static final String RELEASE_REPOSITORY = "https://services.gradle.org/distributions"; private static final String SNAPSHOT_REPOSITORY = "https://services.gradle.org/distributions-snapshots"; + public DistributionLocator() { + logDeprecation(); + } + public URI getDistributionFor(GradleVersion version) { return getDistributionFor(version, "bin"); } From a7cab66fc852716024112b0bcfe04828a2535400 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:11:25 +0200 Subject: [PATCH 42/71] Add deprecated constructor to GUtil utility class Signed-off-by: Paul Merlin --- subprojects/logging/src/main/java/org/gradle/util/GUtil.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index e98acb3ab320..0cfbfac396d7 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -80,6 +80,10 @@ private static void logDeprecation() { private static final Pattern WORD_SEPARATOR = Pattern.compile("\\W+"); private static final Pattern UPPER_LOWER = Pattern.compile("(?m)([A-Z]*)([a-z0-9]*)"); + public GUtil() { + logDeprecation(); + } + public static > T flatten(Object[] elements, T addTo, boolean flattenMaps) { return flatten(asList(elements), addTo, flattenMaps); } From d8c5b8674b46aae178f370e699b680ebee739256 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:11:46 +0200 Subject: [PATCH 43/71] Add deprecated constructor to GFileUtils utility class Signed-off-by: Paul Merlin --- .../logging/src/main/java/org/gradle/util/GFileUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java index d2b594e00d02..1a7b6da13cf7 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java @@ -60,6 +60,10 @@ private static void logDeprecation() { .nagUser(); } + public GFileUtils() { + logDeprecation(); + } + public static FileInputStream openInputStream(File file) { logDeprecation(); try { From 7339dab748ee278c9cc50908606832de99e2f56b Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:11:58 +0200 Subject: [PATCH 44/71] Add deprecated constructor to CollectionUtils utility class Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/CollectionUtils.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java index 675576313dde..fe390a12fe17 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java @@ -71,6 +71,10 @@ private static void logDeprecation() { .nagUser(); } + public CollectionUtils() { + logDeprecation(); + } + /** * Returns null if the collection is empty otherwise expects a {@link #single(Iterable)} element to be found. */ From e5747cb110be9fdcc9d937f3b7632ee6ce243e14 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:12:06 +0200 Subject: [PATCH 45/71] Add deprecated constructor to WrapUtils utility class Signed-off-by: Paul Merlin --- subprojects/core/src/main/java/org/gradle/util/WrapUtil.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java b/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java index 8e0754306459..87bb040e4e05 100644 --- a/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/WrapUtil.java @@ -48,6 +48,10 @@ private static void logDeprecation() { .nagUser(); } + public WrapUtil() { + logDeprecation(); + } + /** * Wraps the given items in a mutable unordered set. */ From c71204493594221e2cd9622cf0124be2705e709e Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:12:43 +0200 Subject: [PATCH 46/71] Add deprecated constructor to RelativePathUtil utility class Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/RelativePathUtil.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java index 36dac3b12ff4..49f7d1e2e657 100644 --- a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java @@ -36,6 +36,10 @@ private static void logDeprecation() { .nagUser(); } + public RelativePathUtil() { + logDeprecation(); + } + /** * Returns a relative path from 'from' to 'to' * From 69f1cf0f03d997ad19241116e61d7689c6ced4ca Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:12:59 +0200 Subject: [PATCH 47/71] Fix GFileUtils internal method visibility Signed-off-by: Paul Merlin --- .../logging/src/main/java/org/gradle/util/GFileUtils.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java index 1a7b6da13cf7..a3876541b56f 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java @@ -173,7 +173,7 @@ public static void moveDirectory(File source, File destination) { moveDirectoryInternal(source, destination); } - public static void moveDirectoryInternal(File source, File destination) { + private static void moveDirectoryInternal(File source, File destination) { try { FileUtils.moveDirectory(source, destination); } catch (IOException e) { From 7d197128e562edd2e95ff2e55ed281afcfd4f576 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:38:20 +0200 Subject: [PATCH 48/71] Ignore package cycle created by DocumentationRegistry Signed-off-by: Paul Merlin --- subprojects/logging/build.gradle.kts | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/logging/build.gradle.kts b/subprojects/logging/build.gradle.kts index 591af2ee8961..5005cfb73208 100644 --- a/subprojects/logging/build.gradle.kts +++ b/subprojects/logging/build.gradle.kts @@ -44,4 +44,5 @@ dependencies { packageCycles { excludePatterns.add("org/gradle/internal/featurelifecycle/**") + excludePatterns.add("org.gradle.api.internal.DocumentationRegistry") } From 17534d61ed34492da1265c327213c18db4cfff87 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:38:38 +0200 Subject: [PATCH 49/71] Fix GUtil for checkstyle Signed-off-by: Paul Merlin --- subprojects/logging/src/main/java/org/gradle/util/GUtil.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index 0cfbfac396d7..b1cc90182703 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -358,10 +358,9 @@ public static String toLowerCamelCase(CharSequence string) { } private static String toCamelCase(CharSequence string, boolean lower) { + // TODO log deprecation once protobuf plugin is fixed if (lower) { logDeprecation(); - } else { - // TODO log deprecation once protobuf plugin is fixed } if (string == null) { return null; From 843fdcd016e51aadcb46472f079b38985c3bff60 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:39:18 +0200 Subject: [PATCH 50/71] Fix VersionNumber to log deprecation once Signed-off-by: Paul Merlin --- .../java/org/gradle/util/VersionNumber.java | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java b/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java index 0fd6e5d86ac1..46958317aa92 100644 --- a/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java +++ b/subprojects/core/src/main/java/org/gradle/util/VersionNumber.java @@ -47,6 +47,7 @@ private static void logDeprecation() { private final int patch; private final String qualifier; private final AbstractScheme scheme; + private boolean deprecationLogged; public VersionNumber(int major, int minor, int micro, @Nullable String qualifier) { this(major, minor, micro, 0, qualifier, DEFAULT_SCHEME, true); @@ -63,41 +64,48 @@ private VersionNumber(int major, int minor, int micro, int patch, @Nullable Stri this.patch = patch; this.qualifier = qualifier; this.scheme = scheme; + // TODO log deprecation once protobuf/osdetector plugin is fixed if (logDeprecation) { logDeprecation(); - } else { - // TODO log deprecation once protobuf/osdetector plugin is fixed + deprecationLogged = true; + } + } + + private void maybeLogDeprecation() { + if(!deprecationLogged) { + logDeprecation(); } } public int getMajor() { - logDeprecation(); + maybeLogDeprecation(); return major; } public int getMinor() { - logDeprecation(); + maybeLogDeprecation(); return minor; } public int getMicro() { - logDeprecation(); + maybeLogDeprecation(); return micro; } public int getPatch() { - logDeprecation(); + maybeLogDeprecation(); return patch; } @Nullable public String getQualifier() { - logDeprecation(); + maybeLogDeprecation(); return qualifier; } public VersionNumber getBaseVersion() { - return new VersionNumber(major, minor, micro, patch, null, scheme, true); + maybeLogDeprecation(); + return new VersionNumber(major, minor, micro, patch, null, scheme, false); } @Override @@ -135,7 +143,7 @@ public int hashCode() { @Override public String toString() { - logDeprecation(); + maybeLogDeprecation(); return scheme.format(this); } From 5aecca5b589d9536be33ee65ac91f833972b3233 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:48:48 +0200 Subject: [PATCH 51/71] Better fix for the package cycles Signed-off-by: Paul Merlin --- subprojects/logging/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/logging/build.gradle.kts b/subprojects/logging/build.gradle.kts index 5005cfb73208..a0272405e875 100644 --- a/subprojects/logging/build.gradle.kts +++ b/subprojects/logging/build.gradle.kts @@ -44,5 +44,5 @@ dependencies { packageCycles { excludePatterns.add("org/gradle/internal/featurelifecycle/**") - excludePatterns.add("org.gradle.api.internal.DocumentationRegistry") + excludePatterns.add("org/gradle/util/**") } From 09c994ab65c178b491abf44ba63f4223ea05437f Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:49:09 +0200 Subject: [PATCH 52/71] Move GradleVersionTest close to the implementation Signed-off-by: Paul Merlin --- .../src/test/groovy/org/gradle/util/GradleVersionTest.groovy | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/test/groovy/org/gradle/util/GradleVersionTest.groovy (100%) diff --git a/subprojects/base-services/src/test/groovy/org/gradle/util/GradleVersionTest.groovy b/subprojects/logging/src/test/groovy/org/gradle/util/GradleVersionTest.groovy similarity index 100% rename from subprojects/base-services/src/test/groovy/org/gradle/util/GradleVersionTest.groovy rename to subprojects/logging/src/test/groovy/org/gradle/util/GradleVersionTest.groovy From b4bc41d3badba287cdf907d48dfe5724d472cbaf Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:49:19 +0200 Subject: [PATCH 53/71] Move DocumentationRegistryTest close to the implementation Signed-off-by: Paul Merlin --- .../org/gradle/api/internal/DocumentationRegistryTest.groovy | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/test/groovy/org/gradle/api/internal/DocumentationRegistryTest.groovy (100%) diff --git a/subprojects/base-services/src/test/groovy/org/gradle/api/internal/DocumentationRegistryTest.groovy b/subprojects/logging/src/test/groovy/org/gradle/api/internal/DocumentationRegistryTest.groovy similarity index 100% rename from subprojects/base-services/src/test/groovy/org/gradle/api/internal/DocumentationRegistryTest.groovy rename to subprojects/logging/src/test/groovy/org/gradle/api/internal/DocumentationRegistryTest.groovy From 26805c6b1ece73bb991ec350520d021c5cc79d9a Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 14:49:48 +0200 Subject: [PATCH 54/71] Move deprecated TextUtil to :logging So it can use DeprecationLogger in order to nag about its deprecation. This type will be removed later. Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/TextUtil.java | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename subprojects/{base-services => logging}/src/main/java/org/gradle/util/TextUtil.java (100%) diff --git a/subprojects/base-services/src/main/java/org/gradle/util/TextUtil.java b/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java similarity index 100% rename from subprojects/base-services/src/main/java/org/gradle/util/TextUtil.java rename to subprojects/logging/src/main/java/org/gradle/util/TextUtil.java From d187febafc72a06a21a7d214868a0d07b71e7381 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 15:06:04 +0200 Subject: [PATCH 55/71] Let deprecated RelativePathUtil use non-deprecated TextUtil Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/RelativePathUtil.java | 1 + 1 file changed, 1 insertion(+) diff --git a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java index 49f7d1e2e657..6e530ee66756 100644 --- a/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java +++ b/subprojects/core/src/main/java/org/gradle/util/RelativePathUtil.java @@ -18,6 +18,7 @@ import org.gradle.internal.UncheckedException; import org.gradle.internal.deprecation.DeprecationLogger; +import org.gradle.util.internal.TextUtil; import java.io.File; From 14a9038d9431941f860a509d46ff316385e80edf Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 15:06:26 +0200 Subject: [PATCH 56/71] Let CachedLineEndingSensitifityIntegrationSpec use non-deprecated TextUtil Signed-off-by: Paul Merlin --- .../api/tasks/CachedLineEndingSensitivityIntegrationSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/core/src/integTest/groovy/org/gradle/api/tasks/CachedLineEndingSensitivityIntegrationSpec.groovy b/subprojects/core/src/integTest/groovy/org/gradle/api/tasks/CachedLineEndingSensitivityIntegrationSpec.groovy index 8325a915f25c..a620d16ec70f 100644 --- a/subprojects/core/src/integTest/groovy/org/gradle/api/tasks/CachedLineEndingSensitivityIntegrationSpec.groovy +++ b/subprojects/core/src/integTest/groovy/org/gradle/api/tasks/CachedLineEndingSensitivityIntegrationSpec.groovy @@ -16,7 +16,7 @@ package org.gradle.api.tasks -import org.gradle.util.TextUtil +import org.gradle.util.internal.TextUtil class CachedLineEndingSensitivityIntegrationSpec extends AbstractLineEndingSensitivityIntegrationSpec { From 72ed8b58834506b2e406842e9021b9f411c176f9 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 15:06:50 +0200 Subject: [PATCH 57/71] Nag deprecation of org.gradle.util.TextUtil Signed-off-by: Paul Merlin --- .../migration/upgrading_version_7.adoc | 1 + .../main/java/org/gradle/util/TextUtil.java | 58 +++++++++++++++++-- 2 files changed, 55 insertions(+), 4 deletions(-) diff --git a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc index 4acdea9b25aa..e7ad76cda40b 100644 --- a/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc +++ b/subprojects/docs/src/docs/userguide/migration/upgrading_version_7.adoc @@ -93,6 +93,7 @@ These members will be removed in Gradle 9.0. * `NameMatcher` * `NameValidator` * `RelativePathUtil` +* `TextUtil` * `SingleMessageLogger` * `VersionNumber` * `WrapUtil` diff --git a/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java b/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java index 5fb438526c3b..216455dd5b85 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java @@ -21,6 +21,7 @@ import com.google.common.collect.Iterables; import org.apache.commons.lang.StringEscapeUtils; import org.gradle.internal.SystemProperties; +import org.gradle.internal.deprecation.DeprecationLogger; import javax.annotation.Nullable; import java.io.File; @@ -37,6 +38,14 @@ */ @Deprecated public class TextUtil { + + private static void logDeprecation() { + DeprecationLogger.deprecateType(TextUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + private static final Pattern WHITESPACE = Pattern.compile("\\s*"); private static final Pattern UPPER_CASE = Pattern.compile("(?=\\p{Upper})"); private static final Joiner KEBAB_JOINER = Joiner.on("-"); @@ -48,10 +57,15 @@ public String apply(String input) { }; private static final Pattern NON_UNIX_LINE_SEPARATORS = Pattern.compile("\r\n|\r"); + public TextUtil() { + logDeprecation(); + } + /** * Returns the line separator for Windows. */ public static String getWindowsLineSeparator() { + logDeprecation(); return "\r\n"; } @@ -59,6 +73,7 @@ public static String getWindowsLineSeparator() { * Returns the line separator for Unix. */ public static String getUnixLineSeparator() { + logDeprecation(); return "\n"; } @@ -66,6 +81,11 @@ public static String getUnixLineSeparator() { * Returns the line separator for this platform. */ public static String getPlatformLineSeparator() { + logDeprecation(); + return getPlatformLineSeparatorInternal(); + } + + private static String getPlatformLineSeparatorInternal() { return SystemProperties.getInstance().getLineSeparator(); } @@ -74,6 +94,7 @@ public static String getPlatformLineSeparator() { */ @Nullable public static String convertLineSeparators(@Nullable String str, String sep) { + logDeprecation(); return str == null ? null : replaceLineSeparatorsOf(str, sep); } @@ -81,6 +102,11 @@ public static String convertLineSeparators(@Nullable String str, String sep) { * Converts all line separators in the specified non-null string to the Unix line separator {@code \n}. */ public static String convertLineSeparatorsToUnix(String str) { + logDeprecation(); + return convertLineSeparatorsToUnixInternal(str); + } + + private static String convertLineSeparatorsToUnixInternal(String str) { return replaceAll(NON_UNIX_LINE_SEPARATORS, str, "\n"); } @@ -88,6 +114,12 @@ public static String convertLineSeparatorsToUnix(String str) { * Converts all line separators in the specified non-null {@link CharSequence} to the specified line separator. */ public static String replaceLineSeparatorsOf(CharSequence string, String bySeparator) { + logDeprecation(); + return replaceLineSeparatorsInternalOf(string, bySeparator); + } + + public static String replaceLineSeparatorsInternalOf(CharSequence string, String bySeparator) { + logDeprecation(); return replaceAll("\r\n|\r|\n", string, bySeparator); } @@ -103,7 +135,8 @@ private static String replaceAll(Pattern pattern, CharSequence inString, String * Converts all line separators in the specified string to the platform's line separator. */ public static String toPlatformLineSeparators(String str) { - return str == null ? null : replaceLineSeparatorsOf(str, getPlatformLineSeparator()); + logDeprecation(); + return str == null ? null : replaceLineSeparatorsInternalOf(str, getPlatformLineSeparatorInternal()); } /** @@ -113,13 +146,23 @@ public static String toPlatformLineSeparators(String str) { */ @Nullable public static String normaliseLineSeparators(@Nullable String str) { - return str == null ? null : convertLineSeparatorsToUnix(str); + logDeprecation(); + return normaliseLineSeparatorsInternal(str); + } + + public static String normaliseLineSeparatorsInternal(@Nullable String str) { + return str == null ? null : convertLineSeparatorsToUnixInternal(str); } /** * Converts all native file separators in the specified string to '/'. */ public static String normaliseFileSeparators(String path) { + logDeprecation(); + return normaliseFileSeparatorsInternal(path); + } + + public static String normaliseFileSeparatorsInternal(String path) { return path.replace(File.separatorChar, '/'); } @@ -128,6 +171,7 @@ public static String normaliseFileSeparators(String path) { * This is useful for interpolating variables into script strings, as well as in other situations. */ public static String escapeString(Object obj) { + logDeprecation(); return obj == null ? null : StringEscapeUtils.escapeJava(obj.toString()); } @@ -135,6 +179,7 @@ public static String escapeString(Object obj) { * Tells whether the specified string contains any whitespace characters. */ public static boolean containsWhitespace(String str) { + logDeprecation(); for (int i = 0; i < str.length(); i++) { if (Character.isWhitespace(str.charAt(i))) { return true; @@ -148,6 +193,7 @@ public static boolean containsWhitespace(String str) { * and lines that only contain whitespace are not indented. */ public static String indent(String text, String indent) { + logDeprecation(); StringBuilder builder = new StringBuilder(); String[] lines = text.split("\n"); @@ -166,6 +212,7 @@ public static String indent(String text, String indent) { } public static String shorterOf(String s1, String s2) { + logDeprecation(); if (s2.length() >= s1.length()) { return s1; } else { @@ -181,6 +228,7 @@ public static String shorterOf(String s1, String s2) { * @return string with removeString removed or the original string if it did not contain removeString */ public static String minus(String originalString, String removeString) { + logDeprecation(); String s = originalString.toString(); int index = s.indexOf(removeString); if (index == -1) { @@ -194,10 +242,12 @@ public static String minus(String originalString, String removeString) { } public static String normaliseFileAndLineSeparators(String in) { - return normaliseLineSeparators(normaliseFileSeparators(in)); + logDeprecation(); + return normaliseLineSeparatorsInternal(normaliseFileSeparatorsInternal(in)); } public static String camelToKebabCase(String camelCase) { + logDeprecation(); return KEBAB_JOINER.join(Iterables.transform(Arrays.asList(UPPER_CASE.split(camelCase)), TO_LOWERCASE)); } @@ -208,11 +258,11 @@ public static String camelToKebabCase(String camelCase) { * * @param s string to be made lowercase * @return a lowercase string that ignores locale - * * @see GRADLE-3470 * @see Turkish i problem */ public static String toLowerCaseLocaleSafe(String s) { + logDeprecation(); return s.toLowerCase(Locale.ENGLISH); } } From 84907ae84d700b959226e49085038c648474b196 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 15:50:52 +0200 Subject: [PATCH 58/71] Fix TextUtil internal methods visibility Signed-off-by: Paul Merlin --- .../logging/src/main/java/org/gradle/util/TextUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java b/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java index 216455dd5b85..a53f63d79499 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/TextUtil.java @@ -118,7 +118,7 @@ public static String replaceLineSeparatorsOf(CharSequence string, String bySepar return replaceLineSeparatorsInternalOf(string, bySeparator); } - public static String replaceLineSeparatorsInternalOf(CharSequence string, String bySeparator) { + private static String replaceLineSeparatorsInternalOf(CharSequence string, String bySeparator) { logDeprecation(); return replaceAll("\r\n|\r|\n", string, bySeparator); } @@ -150,7 +150,7 @@ public static String normaliseLineSeparators(@Nullable String str) { return normaliseLineSeparatorsInternal(str); } - public static String normaliseLineSeparatorsInternal(@Nullable String str) { + private static String normaliseLineSeparatorsInternal(@Nullable String str) { return str == null ? null : convertLineSeparatorsToUnixInternal(str); } @@ -162,7 +162,7 @@ public static String normaliseFileSeparators(String path) { return normaliseFileSeparatorsInternal(path); } - public static String normaliseFileSeparatorsInternal(String path) { + private static String normaliseFileSeparatorsInternal(String path) { return path.replace(File.separatorChar, '/'); } From 7c5bee6f9dade6f36320e920e5770f3369ca8c25 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 16:24:35 +0200 Subject: [PATCH 59/71] Upgrade tested nebula plugins versions Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/AbstractSmokeTest.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy index 0b19d435e327..06f2da6788b1 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy @@ -61,10 +61,10 @@ abstract class AbstractSmokeTest extends Specification { static nebulaDependencyRecommender = "11.0.0" // https://plugins.gradle.org/plugin/nebula.plugin-plugin - static nebulaPluginPlugin = "16.0.1" + static nebulaPluginPlugin = "17.1.0" // https://plugins.gradle.org/plugin/nebula.lint - static nebulaLint = "17.2.3" + static nebulaLint = "17.7.0" // https://plugins.gradle.org/plugin/org.jetbrains.gradle.plugin.idea-ext static ideaExt = "1.1" @@ -72,7 +72,7 @@ abstract class AbstractSmokeTest extends Specification { // https://plugins.gradle.org/plugin/nebula.dependency-lock // TODO: Re-add "8.8.x", "9.4.x" and "10.1.x" if fixed: // https://github.com/nebula-plugins/gradle-dependency-lock-plugin/issues/215 - static nebulaDependencyLock = Versions.of("12.1.0") + static nebulaDependencyLock = Versions.of("12.6.1") // https://plugins.gradle.org/plugin/nebula.resolution-rules static nebulaResolutionRules = "9.0.0" From dab5ca62357ac1bdabb1f86ffbc1366e26cbcb73 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 16:25:03 +0200 Subject: [PATCH 60/71] Unignore working nebula lint plugin smoke test Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy index e890b844d7ef..67feaaf2de2b 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy @@ -92,8 +92,8 @@ class NebulaPluginsSmokeTest extends AbstractPluginValidatingSmokeTest implement .build() } - @Ignore("Waiting for Groovy3 compatibility https://github.com/gradle/gradle/issues/16358") @Issue('https://plugins.gradle.org/plugin/nebula.lint') + @ToBeFixedForConfigurationCache(because = "Task.project at execution time") def 'nebula lint plugin'() { given: buildFile << """ From 8d3eb8e0f4bdc0041de0d24747417ef589b1ae86 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 16:25:30 +0200 Subject: [PATCH 61/71] Remove deprecation expectation in nebula plugin as it is now gone Signed-off-by: Paul Merlin --- .../org/gradle/smoketests/NebulaPluginsSmokeTest.groovy | 8 -------- 1 file changed, 8 deletions(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy index 67feaaf2de2b..6ff76228185b 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy @@ -21,7 +21,6 @@ import org.gradle.internal.reflect.validation.ValidationMessageChecker import org.gradle.util.GradleVersion import org.gradle.util.Requires import org.gradle.util.TestPrecondition -import spock.lang.Ignore import spock.lang.Issue class NebulaPluginsSmokeTest extends AbstractPluginValidatingSmokeTest implements ValidationMessageChecker { @@ -75,13 +74,6 @@ class NebulaPluginsSmokeTest extends AbstractPluginValidatingSmokeTest implement then: runner('groovydoc') - .expectDeprecationWarning( - "Internal API configureDocumentationVariantWithArtifact (no FileResolver) has been deprecated." + - " This is scheduled to be removed in Gradle 8.0." + - " Please use configureDocumentationVariantWithArtifact (with FileResolver) instead." + - " Consult the upgrading guide for further information: https://docs.gradle.org/${GradleVersion.current().version}/userguide/upgrading_version_7.html#lazypublishartifact_fileresolver", - "" - ) .expectDeprecationWarning( "The IdeaModule.testSourceDirs property has been deprecated." + " This is scheduled to be removed in Gradle 8.0." + From 11e7cc4eac25bb143d72780a6f133e69820f3a9a Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 16:26:20 +0200 Subject: [PATCH 62/71] Do not nag for GUtil.loadProperties() because the nebula.lint plugin still uses it Signed-off-by: Paul Merlin --- subprojects/logging/src/main/java/org/gradle/util/GUtil.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index b1cc90182703..b0897c261f1f 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -259,6 +259,7 @@ public static void addToMap(Map dest, Map src) { } public static Properties loadProperties(File propertyFile) { + logDeprecation(); try { FileInputStream inputStream = new FileInputStream(propertyFile); try { @@ -272,6 +273,7 @@ public static Properties loadProperties(File propertyFile) { } public static Properties loadProperties(URL url) { + // TODO log deprecation when nebula-lint plugin is fixed try { URLConnection uc = url.openConnection(); uc.setUseCaches(false); @@ -282,7 +284,7 @@ public static Properties loadProperties(URL url) { } public static Properties loadProperties(InputStream inputStream) { - logDeprecation(); + // TODO log deprecation when nebula-lint plugin is fixed Properties properties = new Properties(); try { properties.load(inputStream); From b260e6d99cb2f1300c2da9be077c42ae47601d55 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Tue, 6 Sep 2022 16:26:44 +0200 Subject: [PATCH 63/71] Do not nag for NameMatcher.find() because the nebula.dependency-lock plugin still uses it Signed-off-by: Paul Merlin --- .../core/src/main/java/org/gradle/util/NameMatcher.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java index f9233f1b7277..0e37b181e25d 100644 --- a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java +++ b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java @@ -42,7 +42,7 @@ private static void logDeprecation() { private String pattern; public NameMatcher() { - logDeprecation(); + // TODO log deprecation once nebula.dependency-lock plugin is fixed } /** @@ -52,6 +52,7 @@ public NameMatcher() { * @see #find(String, Collection) */ public T find(String pattern, Map items) { + logDeprecation(); String name = find(pattern, items.keySet()); if (name != null) { return items.get(name); @@ -72,6 +73,7 @@ public T find(String pattern, Map items) { * @return The match if exactly 1 match found, null if no matches or multiple matches. */ public String find(String pattern, Collection items) { + // TODO log deprecation once nebula.dependency-lock plugin is fixed this.pattern = pattern; matches.clear(); candidates.clear(); @@ -191,6 +193,7 @@ private static Pattern getKebabCasePatternForName(String name) { * @return The matches. Returns an empty set when there are no matches. */ public Set getMatches() { + logDeprecation(); return matches; } @@ -200,6 +203,7 @@ public Set getMatches() { * @return The matches. Returns an empty set when there are no potential matches. */ public Set getCandidates() { + logDeprecation(); return candidates; } From e9288516ff2e19ecac40203af688d3a5fdf0cfdc Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Wed, 7 Sep 2022 08:55:55 +0200 Subject: [PATCH 64/71] Remove `@ToBeFixedForConfigurationCache` from nebula.plugin-plugin smoke test Signed-off-by: Paul Merlin --- .../groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy index 6ff76228185b..d4bd4dd5fb03 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/NebulaPluginsSmokeTest.groovy @@ -52,7 +52,6 @@ class NebulaPluginsSmokeTest extends AbstractPluginValidatingSmokeTest implement } @Issue('https://plugins.gradle.org/plugin/nebula.plugin-plugin') - @ToBeFixedForConfigurationCache(because = "Gradle.addBuildListener and TaskExecutionGraph.addTaskExecutionListener") def 'nebula plugin plugin'() { when: buildFile << """ From ea8b7be187f17ce6d7ea0f64b5cdce8100396781 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Wed, 7 Sep 2022 16:24:36 +0200 Subject: [PATCH 65/71] Update comments to account for GUtil usage from IDEA Signed-off-by: Paul Merlin --- .../logging/src/main/java/org/gradle/util/GUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java index b0897c261f1f..9f857fb2c07d 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -273,7 +273,7 @@ public static Properties loadProperties(File propertyFile) { } public static Properties loadProperties(URL url) { - // TODO log deprecation when nebula-lint plugin is fixed + // TODO log deprecation when nebula-lint plugin and idea are fixed try { URLConnection uc = url.openConnection(); uc.setUseCaches(false); @@ -284,7 +284,7 @@ public static Properties loadProperties(URL url) { } public static Properties loadProperties(InputStream inputStream) { - // TODO log deprecation when nebula-lint plugin is fixed + // TODO log deprecation when nebula-lint plugin and idea are fixed Properties properties = new Properties(); try { properties.load(inputStream); @@ -360,7 +360,7 @@ public static String toLowerCamelCase(CharSequence string) { } private static String toCamelCase(CharSequence string, boolean lower) { - // TODO log deprecation once protobuf plugin is fixed + // TODO log deprecation once protobuf plugin and idea are fixed if (lower) { logDeprecation(); } From b43db1ef59e97bbac84a1648e728e3b34dde5c86 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Wed, 7 Sep 2022 16:25:06 +0200 Subject: [PATCH 66/71] Do not nag for ConfigureUtil.configureByMap(props,delegate) because IDEA still uses it Signed-off-by: Paul Merlin --- .../src/main/java/org/gradle/util/ConfigureUtil.java | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java index 8bbebcb26a44..4709d562b50b 100644 --- a/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java +++ b/subprojects/model-core/src/main/java/org/gradle/util/ConfigureUtil.java @@ -73,7 +73,11 @@ public class ConfigureUtil { public static T configureByMap(Map properties, T delegate) { - logDeprecation(); + // TODO log deprecation once idea is fixed + return configureByMapInternal(properties, delegate); + } + + private static T configureByMapInternal(Map properties, T delegate) { if (properties.isEmpty()) { return delegate; } @@ -105,7 +109,8 @@ public static T configureByMap(Map properties, T delegate, Collection< throw new IncompleteInputException("Input configuration map does not contain following mandatory keys: " + missingKeys, missingKeys); } } - return configureByMap(properties, delegate); + logDeprecation(); + return configureByMapInternal(properties, delegate); } /** From 0b8becfadd33313eb8267361c9d238fa6614f30d Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Thu, 8 Sep 2022 10:52:21 +0200 Subject: [PATCH 67/71] Extract deprecation method in DefaultGradleVersion Signed-off-by: Paul Merlin --- .../util/internal/DefaultGradleVersion.java | 25 +++++++------------ 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java index 2266baf30c73..ffa5ac2d2d24 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java +++ b/subprojects/logging/src/main/java/org/gradle/util/internal/DefaultGradleVersion.java @@ -187,10 +187,7 @@ public String getVersion() { @Override @Deprecated public String getBuildTime() { - DeprecationLogger.deprecateMethod(GradleVersion.class, "getBuildTime()") - .willBeRemovedInGradle9() - .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") - .nagUser(); + logMethodDeprecation("getBuildTime()"); return getBuildTimestamp(); } @@ -201,10 +198,7 @@ public String getBuildTimestamp() { @Override @Deprecated public String getRevision() { - DeprecationLogger.deprecateMethod(GradleVersion.class, "getRevision()") - .willBeRemovedInGradle9() - .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") - .nagUser(); + logMethodDeprecation("getRevision()"); return getGitRevision(); } @@ -228,12 +222,7 @@ public GradleVersion getBaseVersion() { @Deprecated public GradleVersion getNextMajor() { // TODO add nagging once Spring dependency management plugin is fixed - /* - DeprecationLogger.deprecateMethod(GradleVersion.class, "getNextMajor()") - .willBeRemovedInGradle9() - .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") - .nagUser(); - */ + // logDeprecation("getNextMajor()"); return getNextMajorVersion(); } @@ -313,11 +302,15 @@ public int hashCode() { @Override @Deprecated public boolean isValid() { - DeprecationLogger.deprecateMethod(GradleVersion.class, "isValid()") + logMethodDeprecation("isValid()"); + return versionPart != null; + } + + private static void logMethodDeprecation(String method) { + DeprecationLogger.deprecateMethod(GradleVersion.class, method) .willBeRemovedInGradle9() .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") .nagUser(); - return versionPart != null; } static final class Stage implements Comparable { From a878ce0f5e9eec0e7cdba266a09dd0da65b60c7d Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Thu, 8 Sep 2022 10:53:13 +0200 Subject: [PATCH 68/71] Remove duplicate deprecation logging in CollectionUtils Signed-off-by: Paul Merlin --- .../logging/src/main/java/org/gradle/util/CollectionUtils.java | 1 - 1 file changed, 1 deletion(-) diff --git a/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java index fe390a12fe17..845dfd466453 100644 --- a/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java @@ -93,7 +93,6 @@ public static T single(Iterable source) { } private static T singleInternal(Iterable source) { - logDeprecation(); Iterator iterator = source.iterator(); if (!iterator.hasNext()) { throw new NoSuchElementException("Expecting collection with single element, got none."); From b59f31dd01a0f259bdc343c7f448a383e76b5c13 Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Thu, 8 Sep 2022 13:21:18 +0200 Subject: [PATCH 69/71] Accept CollectionUtils deprecation warning with artifactory plugin Signed-off-by: Paul Merlin --- .../smoketests/ArtifactoryAndDockerSmokeTest.groovy | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/ArtifactoryAndDockerSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/ArtifactoryAndDockerSmokeTest.groovy index c54a195b808f..6b1a44d130fc 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/ArtifactoryAndDockerSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/ArtifactoryAndDockerSmokeTest.groovy @@ -17,11 +17,12 @@ package org.gradle.smoketests import org.gradle.integtests.fixtures.ToBeFixedForConfigurationCache +import org.gradle.util.GradleVersion import org.gradle.util.Requires import static org.gradle.util.TestPrecondition.HAS_DOCKER -@Requires(HAS_DOCKER) +//@Requires(HAS_DOCKER) class ArtifactoryAndDockerSmokeTest extends AbstractPluginValidatingSmokeTest { @ToBeFixedForConfigurationCache(because = "both docker and artifactory plugins are incompatible") @@ -113,7 +114,13 @@ class ArtifactoryAndDockerSmokeTest extends AbstractPluginValidatingSmokeTest { """ then: - runner('artifactoryPublish').build() + runner('artifactoryPublish') + .expectLegacyDeprecationWarning( + "The org.gradle.util.ConfigureUtil type has been deprecated. " + + "This is scheduled to be removed in Gradle 9.0. " + + "Consult the upgrading guide for further information: https://docs.gradle.org/${GradleVersion.current().version}/userguide/upgrading_version_7.html#org_gradle_util_reports_deprecations" + ) + .build() } @Override From 2ae5787b90f47e9d38fdfc3430a68100314ae51d Mon Sep 17 00:00:00 2001 From: Paul Merlin Date: Fri, 9 Sep 2022 14:44:44 +0200 Subject: [PATCH 70/71] Expect org.gradle.util deprecations in play plugin smoke test Signed-off-by: Paul Merlin --- .../org/gradle/smoketests/PlayPluginSmokeTest.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy index 312edfcc869d..67b420bc04b4 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy @@ -18,6 +18,7 @@ package org.gradle.smoketests import org.gradle.integtests.fixtures.RepoScriptBlockUtil import org.gradle.integtests.fixtures.ToBeFixedForConfigurationCache +import org.gradle.util.GradleVersion import org.gradle.util.Requires import org.gradle.util.TestPrecondition @@ -52,12 +53,20 @@ class PlayPluginSmokeTest extends AbstractPluginValidatingSmokeTest { when: def result = runner('build') + .expectLegacyDeprecationWarning(orgGradleUtilTypeDeprecation("VersionNumber")) + .expectLegacyDeprecationWarning(orgGradleUtilTypeDeprecation("CollectionUtils")) .build() then: result.task(':build').outcome == SUCCESS } + private String orgGradleUtilTypeDeprecation(String type) { + return "The org.gradle.util.$type type has been deprecated." + + "This is scheduled to be removed in Gradle 9.0." + + "Consult the upgrading guide for further information: https://docs.gradle.org/${GradleVersion.current().version}/userguide/upgrading_version_7.html#org_gradle_util_reports_deprecations" + } + @Override Map getPluginsToValidate() { [ From ba11ca4f5f4ff477ed37a028ee0d8f48cbefe028 Mon Sep 17 00:00:00 2001 From: Bo Zhang Date: Sat, 10 Sep 2022 13:29:09 +0800 Subject: [PATCH 71/71] Fix expected deprecation message --- .../groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy index 67b420bc04b4..dfa525f5b901 100644 --- a/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy +++ b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/PlayPluginSmokeTest.groovy @@ -62,8 +62,8 @@ class PlayPluginSmokeTest extends AbstractPluginValidatingSmokeTest { } private String orgGradleUtilTypeDeprecation(String type) { - return "The org.gradle.util.$type type has been deprecated." + - "This is scheduled to be removed in Gradle 9.0." + + return "The org.gradle.util.$type type has been deprecated. " + + "This is scheduled to be removed in Gradle 9.0. " + "Consult the upgrading guide for further information: https://docs.gradle.org/${GradleVersion.current().version}/userguide/upgrading_version_7.html#org_gradle_util_reports_deprecations" }