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/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 { 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..76b4f4576d7a 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,13 +24,25 @@ /** * 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 { + + private static void logDeprecation() { + 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"; + public DistributionLocator() { + logDeprecation(); + } + public URI getDistributionFor(GradleVersion version) { return getDistributionFor(version, "bin"); } 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..0e37b181e25d 100644 --- a/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java +++ b/subprojects/core/src/main/java/org/gradle/util/NameMatcher.java @@ -20,18 +20,31 @@ 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 { + + private static void logDeprecation() { + 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; + public NameMatcher() { + // TODO log deprecation once nebula.dependency-lock plugin is fixed + } + /** * Locates the best match for a camel case pattern in a key set of a map and returns the corresponding value. * @@ -39,6 +52,7 @@ public class 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); @@ -59,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(); @@ -178,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; } @@ -187,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; } 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..5480b391fa42 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 { + private static void logDeprecation() { + 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 = '.'; @@ -38,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)) { 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..6e530ee66756 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,30 @@ package org.gradle.util; import org.gradle.internal.UncheckedException; +import org.gradle.internal.deprecation.DeprecationLogger; +import org.gradle.util.internal.TextUtil; 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 { + + private static void logDeprecation() { + DeprecationLogger.deprecateType(RelativePathUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + + public RelativePathUtil() { + logDeprecation(); + } + /** * Returns a relative path from 'from' to 'to' * @@ -35,6 +49,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) { 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..46958317aa92 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 { + + private static void logDeprecation() { + 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); @@ -38,51 +47,70 @@ public class VersionNumber implements Comparable { 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); + 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; + // TODO log deprecation once protobuf/osdetector plugin is fixed + if (logDeprecation) { + logDeprecation(); + deprecationLogged = true; + } + } + + private void maybeLogDeprecation() { + if(!deprecationLogged) { + logDeprecation(); + } } public int getMajor() { + maybeLogDeprecation(); return major; } public int getMinor() { + maybeLogDeprecation(); return minor; } public int getMicro() { + maybeLogDeprecation(); return micro; } public int getPatch() { + maybeLogDeprecation(); return patch; } @Nullable public String getQualifier() { + maybeLogDeprecation(); return qualifier; } public VersionNumber getBaseVersion() { - return new VersionNumber(major, minor, micro, patch, null, scheme); + maybeLogDeprecation(); + return new VersionNumber(major, minor, micro, patch, null, scheme, false); } @Override public int compareTo(VersionNumber other) { + // TODO log deprecation once protobuf/osdetector plugin is fixed if (major != other.major) { return major - other.major; } @@ -115,6 +143,7 @@ public int hashCode() { @Override public String toString() { + maybeLogDeprecation(); return scheme.format(this); } @@ -123,13 +152,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; } @@ -137,10 +167,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); } @@ -196,12 +228,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; 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..87bb040e4e05 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,16 +36,29 @@ /** * 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 { + + private static void logDeprecation() { + DeprecationLogger.deprecateType(WrapUtil.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + + public WrapUtil() { + logDeprecation(); + } + /** * Wraps the given items in a mutable unordered set. */ @SafeVarargs @SuppressWarnings("varargs") public static Set toSet(T... items) { + logDeprecation(); Set coll = new HashSet(); Collections.addAll(coll, items); return coll; @@ -56,6 +70,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; @@ -67,6 +82,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; @@ -78,6 +94,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; @@ -89,6 +106,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; @@ -100,6 +118,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; @@ -109,6 +128,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); @@ -120,6 +140,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; @@ -128,6 +149,7 @@ public static Map toMap(K key, V value) { @SafeVarargs @SuppressWarnings("varargs") public static T[] toArray(T... items) { + logDeprecation(); return items; } 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 24e7ba8edb11..aeaeed5a8193 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,29 @@ 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. + +* `ClosureBackedAction` +* `CollectionUtils` +* `ConfigureUtil` +* `DistributionLocator` +* `GFileUtils` +* `GradleVersion.getBuildTime()` +* `GradleVersion.getNextMajor()` +* `GradleVersion.getRevision()` +* `GradleVersion.isValid()` +* `GUtil` +* `NameMatcher` +* `NameValidator` +* `RelativePathUtil` +* `TextUtil` +* `SingleMessageLogger` +* `VersionNumber` +* `WrapUtil` + === Potential breaking changes [[kotlin_1_7_10]] 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/logging/build.gradle.kts b/subprojects/logging/build.gradle.kts index 591af2ee8961..a0272405e875 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/util/**") } 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 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 5acf5ce4aabf..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 @@ -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; @@ -393,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); 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 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 89% 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 index b7c71f9a64c9..845dfd466453 100644 --- a/subprojects/base-services/src/main/java/org/gradle/util/CollectionUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/CollectionUtils.java @@ -27,6 +27,7 @@ import org.gradle.internal.Factory; import org.gradle.internal.Pair; import org.gradle.internal.Transformers; +import org.gradle.internal.deprecation.DeprecationLogger; import javax.annotation.Nullable; import java.lang.reflect.Array; @@ -58,23 +59,40 @@ * Plugins should prefer external collection frameworks over this class. * Internally, all code should use {@link org.gradle.util.internal.CollectionUtils}. * - * @deprecated Will be removed in Gradle 8.0. + * @deprecated Will be removed in Gradle 9.0. */ @Deprecated public abstract class CollectionUtils { + private static void logDeprecation() { + DeprecationLogger.deprecateType(CollectionUtils.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + + public CollectionUtils() { + logDeprecation(); + } + /** * Returns null if the collection is empty otherwise expects a {@link #single(Iterable)} element to be found. */ @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) { Iterator iterator = source.iterator(); if (!iterator.hasNext()) { throw new NoSuchElementException("Expecting collection with single element, got none."); @@ -87,6 +105,7 @@ public static T single(Iterable source) { } public static Collection checkedCast(Class type, Collection input) { + logDeprecation(); for (Object o : input) { castNullable(type, o); } @@ -95,6 +114,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; @@ -106,6 +126,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; @@ -116,6 +137,7 @@ public static T findFirst(T[] source, Spec filter) { } public static T first(Iterable source) { + logDeprecation(); return source.iterator().next(); } @@ -159,6 +181,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); @@ -172,6 +195,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()); @@ -187,6 +211,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]); @@ -212,6 +237,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)); } @@ -246,6 +276,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) { @@ -290,6 +325,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; } @@ -297,6 +333,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()); @@ -305,6 +342,7 @@ public static List toList(Enumeration things) { } private static List toMutableList(Iterable things) { + logDeprecation(); if (things == null) { return new ArrayList(0); } @@ -317,6 +355,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()) { @@ -332,6 +371,7 @@ public static List intersection(Collection> avail } public static List toList(T[] things) { + logDeprecation(); if (things == null || things.length == 0) { return new ArrayList(0); } @@ -342,6 +382,7 @@ public static List toList(T[] things) { } public static Set toSet(Iterable things) { + logDeprecation(); if (things == null) { return new HashSet(0); } @@ -358,6 +399,7 @@ public static Set toSet(Iterable things) { } public static List compact(List list) { + logDeprecation(); boolean foundAtLeastOneNull = false; List compacted = null; int i = 0; @@ -381,14 +423,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) { @@ -402,6 +451,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); } @@ -417,6 +467,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)); } @@ -432,6 +483,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; @@ -450,6 +502,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); } @@ -465,6 +518,7 @@ public static > C addAll(C t1, Iterable> C addAll(C t1, T... t2) { + logDeprecation(); Collections.addAll(t1, t2); return t1; } @@ -479,6 +533,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(); + } + } } /** @@ -495,6 +559,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"); } @@ -502,7 +567,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); @@ -561,6 +626,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"); } @@ -587,6 +653,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"); @@ -606,6 +673,7 @@ public static Pair, Collection> partition(Iterable items /** * Injection step. + * * @param target type. * @param item type. */ @@ -615,8 +683,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() { @@ -629,6 +704,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"); } @@ -640,12 +716,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) { @@ -657,6 +734,7 @@ public static Map> groupBy(Iterable iterabl } public static Iterable unpack(final Iterable> factories) { + logDeprecation(); return new Iterable() { private final Iterator> delegate = factories.iterator(); @@ -684,11 +762,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())); } } 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 87% 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 index 163bdc36a5da..a3876541b56f 100644 --- a/subprojects/base-services/src/main/java/org/gradle/util/GFileUtils.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GFileUtils.java @@ -20,6 +20,8 @@ import org.apache.commons.lang.StringUtils; 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; @@ -46,12 +48,24 @@ *

* 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 { + private static void logDeprecation() { + DeprecationLogger.deprecateType(GFileUtils.class) + .willBeRemovedInGradle9() + .withUpgradeGuideSection(7, "org_gradle_util_reports_deprecations") + .nagUser(); + } + + public GFileUtils() { + logDeprecation(); + } + public static FileInputStream openInputStream(File file) { + logDeprecation(); try { return FileUtils.openInputStream(file); } catch (IOException e) { @@ -64,9 +78,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); @@ -78,6 +93,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) { @@ -105,6 +125,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) { @@ -113,9 +138,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); } } @@ -125,6 +151,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) { @@ -133,6 +160,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) { @@ -141,6 +169,11 @@ public static void copyDirectory(File source, File destination) { } public static void moveDirectory(File source, File destination) { + logDeprecation(); + moveDirectoryInternal(source, destination); + } + + private static void moveDirectoryInternal(File source, File destination) { try { FileUtils.moveDirectory(source, destination); } catch (IOException e) { @@ -149,6 +182,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); @@ -160,6 +194,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) { @@ -187,6 +222,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) { @@ -195,10 +231,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()); @@ -207,6 +245,7 @@ public static List toPaths(Collection files) { } public static void copyURLToFile(URL source, File destination) { + logDeprecation(); try { FileUtils.copyURLToFile(source, destination); } catch (IOException e) { @@ -215,6 +254,7 @@ public static void copyURLToFile(URL source, File destination) { } public static void deleteDirectory(File directory) { + logDeprecation(); try { FileUtils.deleteDirectory(directory); } catch (IOException e) { @@ -223,6 +263,7 @@ public static void deleteDirectory(File directory) { } public static boolean deleteQuietly(@Nullable File file) { + logDeprecation(); return FileUtils.deleteQuietly(file); } @@ -231,8 +272,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(); + } } } @@ -245,6 +294,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 { @@ -259,7 +309,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); @@ -267,6 +317,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) { @@ -275,6 +326,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) { @@ -301,6 +353,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; @@ -346,6 +399,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)); 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 93% 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 index d73c32c822e8..9f857fb2c07d 100644 --- a/subprojects/base-services/src/main/java/org/gradle/util/GUtil.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GUtil.java @@ -24,7 +24,9 @@ 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 org.gradle.util.internal.CollectionUtils; import javax.annotation.Nullable; import java.io.File; @@ -63,13 +65,25 @@ * 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 { + + private static void logDeprecation() { + 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]*)"); + public GUtil() { + logDeprecation(); + } + public static > T flatten(Object[] elements, T addTo, boolean flattenMaps) { return flatten(asList(elements), addTo, flattenMaps); } @@ -93,6 +107,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(); @@ -140,10 +155,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); @@ -152,6 +169,7 @@ public static List prefix(String prefix, Collection strings) { } public static boolean isTrue(@Nullable Object object) { + logDeprecation(); if (object == null) { return false; } @@ -162,6 +180,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. @@ -177,6 +196,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); @@ -192,6 +212,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) { @@ -209,6 +230,7 @@ public static > T addToCollection(T dest, Ite } public static Comparator caseInsensitive() { + logDeprecation(); return new Comparator() { @Override public int compare(String o1, String o2) { @@ -222,6 +244,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); @@ -229,12 +252,14 @@ 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()); } } public static Properties loadProperties(File propertyFile) { + logDeprecation(); try { FileInputStream inputStream = new FileInputStream(propertyFile); try { @@ -248,6 +273,7 @@ public static Properties loadProperties(File propertyFile) { } public static Properties loadProperties(URL url) { + // TODO log deprecation when nebula-lint plugin and idea are fixed try { URLConnection uc = url.openConnection(); uc.setUseCaches(false); @@ -258,6 +284,7 @@ public static Properties loadProperties(URL url) { } public static Properties loadProperties(InputStream inputStream) { + // TODO log deprecation when nebula-lint plugin and idea are fixed Properties properties = new Properties(); try { properties.load(inputStream); @@ -270,6 +297,7 @@ public static Properties loadProperties(InputStream inputStream) { } public static void saveProperties(Properties properties, File propertyFile) { + logDeprecation(); try { FileOutputStream propertiesFileOutputStream = new FileOutputStream(propertyFile); try { @@ -283,6 +311,7 @@ public static void saveProperties(Properties properties, File propertyFile) { } public static void saveProperties(Properties properties, OutputStream outputStream) { + logDeprecation(); try { try { properties.store(outputStream, null); @@ -295,6 +324,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) { @@ -304,6 +334,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) { @@ -329,6 +360,10 @@ public static String toLowerCamelCase(CharSequence string) { } private static String toCamelCase(CharSequence string, boolean lower) { + // TODO log deprecation once protobuf plugin and idea are fixed + if (lower) { + logDeprecation(); + } if (string == null) { return null; } @@ -365,6 +400,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(); @@ -378,6 +414,7 @@ public static String toWords(CharSequence string) { } public static String toWords(CharSequence string, char separator) { + // TODO log deprecation once android plugin is fixed if (string == null) { return null; } @@ -415,12 +452,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); @@ -431,6 +470,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) { @@ -459,6 +499,7 @@ public int compare(T o1, T o2) { */ @Nullable public static T uncheckedCall(Callable callable) { + logDeprecation(); try { return callable.call(); } catch (Exception e) { @@ -467,6 +508,7 @@ public static T uncheckedCall(Callable callable) { } public static > T toEnum(Class enumType, Object value) { + logDeprecation(); if (enumType.isInstance(value)) { return enumType.cast(value); } @@ -514,6 +556,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)); @@ -528,6 +571,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); } @@ -545,6 +589,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) { @@ -553,6 +598,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. * 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 89% 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 index 202a5e0f94a2..bc657249b7ae 100644 --- a/subprojects/base-services/src/main/java/org/gradle/util/GradleVersion.java +++ b/subprojects/logging/src/main/java/org/gradle/util/GradleVersion.java @@ -26,7 +26,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 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/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(); + } } 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 79% 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 index 5fb438526c3b..a53f63d79499 100644 --- a/subprojects/base-services/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); + } + + private 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); + } + + private 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); + } + + private 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); } } 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 95% 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 index 4b6c92e12e2a..ffa5ac2d2d24 100644 --- 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 @@ -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,7 @@ public String getVersion() { @Override @Deprecated public String getBuildTime() { + logMethodDeprecation("getBuildTime()"); return getBuildTimestamp(); } @@ -196,6 +198,7 @@ public String getBuildTimestamp() { @Override @Deprecated public String getRevision() { + logMethodDeprecation("getRevision()"); return getGitRevision(); } @@ -218,6 +221,8 @@ public GradleVersion getBaseVersion() { @Override @Deprecated public GradleVersion getNextMajor() { + // TODO add nagging once Spring dependency management plugin is fixed + // logDeprecation("getNextMajor()"); return getNextMajorVersion(); } @@ -297,9 +302,17 @@ public int hashCode() { @Override @Deprecated public boolean 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(); + } + static final class Stage implements Comparable { final int stage; final int number; 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 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 diff --git a/subprojects/model-core/src/main/java/org/gradle/util/ClosureBackedAction.java b/subprojects/model-core/src/main/java/org/gradle/util/ClosureBackedAction.java index 51dc3d289596..6e3e8cec1c5f 100644 --- a/subprojects/model-core/src/main/java/org/gradle/util/ClosureBackedAction.java +++ b/subprojects/model-core/src/main/java/org/gradle/util/ClosureBackedAction.java @@ -20,6 +20,7 @@ import groovy.lang.Closure; import org.gradle.api.Action; import org.gradle.api.InvalidActionClosureException; +import org.gradle.internal.deprecation.DeprecationLogger; /** @@ -27,12 +28,19 @@ *

* 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; 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..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 @@ -19,11 +19,13 @@ 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; 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; @@ -65,12 +67,17 @@ *

* 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 { public static T configureByMap(Map properties, T delegate) { + // TODO log deprecation once idea is fixed + return configureByMapInternal(properties, delegate); + } + + private static T configureByMapInternal(Map properties, T delegate) { if (properties.isEmpty()) { return delegate; } @@ -102,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); } /** @@ -115,6 +123,7 @@ public static class IncompleteInputException extends RuntimeException { public IncompleteInputException(String message, Collection missingKeys) { super(message); this.missingKeys = missingKeys; + logDeprecation(); } public Collection getMissingKeys() { @@ -136,6 +145,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; } @@ -153,6 +164,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(); } @@ -164,6 +176,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; } @@ -176,6 +189,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; } @@ -195,6 +209,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. * 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/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy b/subprojects/smoke-test/src/smokeTest/groovy/org/gradle/smoketests/AbstractSmokeTest.groovy index 8a114d342bfe..f693bd3696f7 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" @@ -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" @@ -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" 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 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..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 @@ -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 { @@ -53,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 << """ @@ -75,13 +73,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." + @@ -92,8 +83,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 << """ 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..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 @@ -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() { [ 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") + } +} diff --git a/subprojects/test-kit/build.gradle.kts b/subprojects/test-kit/build.gradle.kts index 49331c1b2ea2..4bf59aac82a2 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")) 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 } }