aaschmid / gradle-cpd-plugin

Gradle plugin to find duplicate code using PMDs copy/paste detection (= CPD).
Apache License 2.0
96 stars 12 forks source link

Fix deprecation warning "Internal API constructor TaskReportContainer(Class<T>, Task) has been deprecated" #36

Closed aaschmid closed 4 years ago

aaschmid commented 5 years ago

Gradle v5.1 provides a new constructor org.gradle.api.reporting.internal.TaskReportContainer#TaskReportContainer(java.lang.Class<? extends T>, org.gradle.api.Task, org.gradle.api.internal.CollectionCallbackActionDecorator) which should be used in favor of old org.gradle.api.reporting.internal.TaskReportContainer#TaskReportContainer(java.lang.Class<? extends T>, org.gradle.api.Task).

Solution: Use the super(SingleFileReport.class, task, CollectionCallbackActionDecorator.NOOP) in de.aaschmid.gradle.plugins.cpd.internal.CpdReportsImpl#CpdReportsImpl.

Challenges: This required to update the supported version to at least Gradle 5.1. As the logic is within the constructor we cannot do a version distinction here using GradleVersion.current().compareTo(...)

Another possibility to fix at least the depreaction warning is using DeprecationLogger#whileDisabled

aaschmid commented 4 years ago

Fixed with https://github.com/aaschmid/gradle-cpd-plugin/releases/tag/v3.1