GradleUp/static-analysis-plugin

Error when using Gradle 7.0

davidalbers opened this issue · 2 comments

I'm trying to use this plugin in a project that uses Gradle 7. When I run evaluateViolations I get the following error:

Could not determine the dependencies of task ':project:collectKtlintDebugAndroidTestVariantViolations'.
> Could not create task ':project:collectKtlintAndroidTestViolations'.
   > Querying the mapped value of task ':project:ktlintAndroidTestSourceSetCheck' property 'reporterOutputDir' before task ':project:ktlintAndroidTestSourceSetCheck' has completed is not supported

* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Exception is:
org.gradle.api.internal.tasks.TaskDependencyResolveException: Could not determine the dependencies of task ':project:collectKtlintDebugAndroidTestVariantViolations'.
	at org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:71
Caused by: org.gradle.api.internal.tasks.DefaultTaskContainer$TaskCreationException: Could not create task ':project:collectKtlintAndroidTestViolations'.
	at org.gradle.api.internal.tasks.DefaultTaskContainer.taskCreationException(DefaultTaskContainer.java:719)
	... 114 more
Caused by: org.gradle.api.InvalidUserCodeException: Querying the mapped value of task ':project:ktlintAndroidTestSourceSetCheck' property 'reporterOutputDir' before task ':project:ktlintAndroidTestSourceSetCheck' has completed is not supported
	at org.gradle.api.internal.provider.TransformBackedProvider.lambda$beforeRead$0(TransformBackedProvider.java:84)
	at org.gradle.api.internal.provider.ValueSupplier$TaskProducer.visitContentProducerTasks(ValueSupplier.java:136)
	at org.gradle.api.internal.provider.TransformBackedProvider.beforeRead(TransformBackedProvider.java:81)
	at org.gradle.api.internal.provider.TransformBackedProvider.calculateOwnValue(TransformBackedProvider.java:63)
	at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateValue(AbstractMinimalProvider.java:103)
	at org.gradle.api.internal.provider.MappingProvider.calculateOwnValue(MappingProvider.java:55)
	at org.gradle.api.internal.provider.AbstractMinimalProvider.calculateValue(AbstractMinimalProvider.java:103)
	at org.gradle.api.internal.provider.DefaultProperty.calculateValueFrom(DefaultProperty.java:128)
	at org.gradle.api.internal.provider.DefaultProperty.calculateValueFrom(DefaultProperty.java:25)
	at org.gradle.api.internal.provider.AbstractProperty.doCalculateValue(AbstractProperty.java:133)
	at org.gradle.api.internal.provider.AbstractProperty.calculateOwnValue(AbstractProperty.java:127)
	at org.gradle.api.internal.provider.AbstractMinimalProvider.get(AbstractMinimalProvider.java:84)
	at org.gradle.api.provider.Provider$get.call(Unknown Source)
	at com.gradleup.staticanalysis.internal.ktlint.KtlintConfigurator$_createCollectViolationsTask_closure9$_closure17.doCall(KtlintConfigurator.groovy:141)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	... 140 more

I think it's related to this change

Hi @davidalbers I am releasing version 1.4 of the plugin. This should support Gradle 7.x. Can you try and let me know?

I haven't had time to test the plugin against the latest Ktlint version. The project officially supports Ktlint until version 9.2.1 as can be seen from this test

I tried it and it works! Thanks for the quick response!

Note: I was using ktlint 10.1.0 and got this error:

   > No property for KtLint output files. Please check if the KtLint plugin has changed.

downgrading to the supported 9.2.1 works fine though.