Incompatible with Checkstyle v6.2

Gradle appears to break in a weird way when v6.2 is used. It fails with the exception below. The configuration is,

configurations {
  checkstyleConfig
}
  dependencies {
  checkstyleConfig dependencies.create('com.puppycrawl.tools:checkstyle:6.2') {
      transitive = false
  }
}
  checkstyle {
  showViolations = true
  sourceSets = [sourceSets.main]
  toolVersion = '6.2'
  config = resources.text.fromArchiveEntry(configurations.checkstyleConfig, 'google_checks.xml')
}
Caused by: org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.puppycrawl.tools:checkstyle:DefaultExternalModuleDependency{group='com.puppycrawl.tools', name='checkstyle', version='6.2', configuration='default'}.
Searched in the following locations:
    https://jcenter.bintray.com/com/puppycrawl/tools/checkstyle/DefaultExternalModuleDependency{group='com.puppycrawl.tools', name='checkstyle', version='6.2', configuration='default'}/checkstyle-DefaultExternalModuleDependency{group='com.puppycrawl.tools', name='checkstyle', version='6.2', configuration='default'}.pom
    https://jcenter.bintray.com/com/puppycrawl/tools/checkstyle/DefaultExternalModuleDependency{group='com.puppycrawl.tools', name='checkstyle', version='6.2', configuration='default'}/checkstyle-DefaultExternalModuleDependency{group='com.puppycrawl.tools', name='checkstyle', version='6.2', configuration='default'}.jar
Required by:
    com.github.ben-manes.caffeine:caffeine:1.0.0-SNAPSHOT
 at org.gradle.internal.resolve.result.DefaultBuildableComponentResolveResult.notFound(DefaultBuildableComponentResolveResult.java:40)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainDependencyResolver.resolve(RepositoryChainDependencyResolver.java:86)
 at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainAdapter.resolve(RepositoryChainAdapter.java:69)
 at org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:44)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.resolve(DependencyGraphBuilder.java:577)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$ModuleVersionResolveState.getMetaData(DependencyGraphBuilder.java:587)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.calculateTargetConfigurations(DependencyGraphBuilder.java:272)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder$DependencyEdge.attachToTargetConfigurations(DependencyGraphBuilder.java:246)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:156)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolveDependencyGraph(DependencyGraphBuilder.java:94)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:84)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver$1.execute(DefaultDependencyResolver.java:122)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver$1.execute(DefaultDependencyResolver.java:88)
 at org.gradle.internal.Transformers$4.transform(Transformers.java:136)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:61)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultIvyContextManager.withIvy(DefaultIvyContextManager.java:39)
 at org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultDependencyResolver.resolve(DefaultDependencyResolver.java:88)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver$1.run(CacheLockingArtifactDependencyResolver.java:42)
 at org.gradle.internal.Factories$1.create(Factories.java:22)
 at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:187)
 at org.gradle.cache.internal.DefaultCacheAccess.useCache(DefaultCacheAccess.java:175)
 at org.gradle.cache.internal.DefaultPersistentDirectoryStore.useCache(DefaultPersistentDirectoryStore.java:106)
 at org.gradle.cache.internal.DefaultCacheFactory$ReferenceTrackingCache.useCache(DefaultCacheFactory.java:187)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultCacheLockingManager.useCache(DefaultCacheLockingManager.java:64)
 at org.gradle.api.internal.artifacts.ivyservice.CacheLockingArtifactDependencyResolver.resolve(CacheLockingArtifactDependencyResolver.java:40)
 at org.gradle.api.internal.artifacts.ivyservice.SelfResolvingDependencyResolver.resolve(SelfResolvingDependencyResolver.java:45)
 at org.gradle.api.internal.artifacts.ivyservice.ShortcircuitEmptyConfigsArtifactDependencyResolver.resolve(ShortcircuitEmptyConfigsArtifactDependencyResolver.java:55)
 at org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingArtifactDependencyResolver.resolve(ErrorHandlingArtifactDependencyResolver.java:47)
 at org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolve(DefaultConfigurationResolver.java:46)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveNow(DefaultConfiguration.java:250)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.getResolvedConfiguration(DefaultConfiguration.java:240)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration_Decorated.getResolvedConfiguration(Unknown Source)
 at org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationFileCollection.getFiles(DefaultConfiguration.java:442)
 ... 71 more

‘DependencyHandler’ taskes a dependency notation as an argument. By calling ‘dependencies.create()’ you are creating an actual ‘Dependency’ object, which is unnecessary. Just pass the notation string itself.

dependencies {

checkstyleConfig(‘com.puppycrawl.tools:checkstyle:6.2’) {

transitive = false

}

}

Sorry, I had tried to simplify the extracted piece of build logic. However, your comment did make me take a closer look at the dependency usage and catch the bug, which was entirely on my side. Now its working, thanks!