GradleのCheckstyleプラグインで、Unable to instantiate ‘RecordComponentName’ class

build.gradle に Checkstyle プラグインを適用し、build や checkstyleMain などを実行しようすると下記のようなエラーとなりました。

Unable to instantiate 'RecordComponentName' class, it is also not possible to instantiate it as .RecordComponentName, RecordComponentNameCheck, .RecordComponentNameCheck. Please recheck that class name is specified as canonical name or read how to configure short name usage https://checkstyle.org/config.html#Packages. Please also recheck that provided ClassLoader to Checker is configured correctly.

私の環境は下記の通りです。

  • Gradle 7.2

また、build.gradle には下記のような設定をしていました。

plugins {
  id 'org.springframework.boot' version '2.5.4'
  id 'checkstyle'
}

build.gradle に Checkstyle の最新バージョンを適用してみます。2021-09-05 時点の最新バージョンは 9.0 でした。

具体的には、build.gradle に下記を追記しました。

checkstyle {
  toolVersion '9.0'
}

再度 build や checkstyleMain を実行すると、上記のエラーは解消されました。