Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.2.1 breaks the build with: unresolved reference: detekt #2152

Closed
jcornaz opened this issue Dec 1, 2019 · 4 comments · Fixed by #2159
Closed

1.2.1 breaks the build with: unresolved reference: detekt #2152

jcornaz opened this issue Dec 1, 2019 · 4 comments · Fixed by #2159

Comments

@jcornaz
Copy link

jcornaz commented Dec 1, 2019

Expected Behavior

I have a project using detekt 1.2.0:
https://github.com/jcornaz/kwik/tree/3ba15e2fd54228ae5214f45b39a5977a1af14b7e

I would like to update detekt to version 1.2.1. Since it is a patch I expect the update to be possible without any failure.

Observed Behavior

If I update detekt version to 1.2.1 the build breaks with the following message:

Script compilation errors:

  Line 06: import io.gitlab.arturbosch.detekt.detekt
                                              ^ Unresolved reference: detekt

  Line 72:     detekt {
               ^ Unresolved reference: detekt

  Line 73:         input = files(
                   ^ Unresolved reference: input

  Line 77:         buildUponDefaultConfig = true
                   ^ Unresolved reference: buildUponDefaultConfig

  Line 78:         config = files("$rootDir/detekt-config.yml")
                   ^ Unresolved reference: config

Steps to Reproduce

Setup working version:

git clone git@github.com:jcornaz/kwik.git
cd kwik
git checkout 3ba15e2fd54228ae5214f45b39a5977a1af14b7e
./gradlew detekt # Observe success

Then in line 15 of build.gradle.kts replace 1.2.0 by 1.2.1.

Finally, observe the problem:

./gradlew detekt

Context

I want to update detekt from version 1.2.0 to 1.2.1.

Your Environment

  • Version of detekt used: 1.2.1
  • Version of Gradle used: 6.0.1
  • Operating System and version: Linux version 5.3.12-1-MANJARO
  • Link to your project: https://github.com/jcornaz/kwik
@3flex
Copy link
Member

3flex commented Dec 2, 2019

Looking at your build file you should be able to remove import io.gitlab.arturbosch.detekt.detekt and get it working again. Sorry about that, we should have had a deprecation message where that extension was being used.

You'll also need to change config = files("$rootDir/detekt-config.yml") to config.setFrom( files("$rootDir/detekt-config.yml")). This one should have triggered a deprecation warning in 1.2.0 for direct usage of config =. If it didn't can you please advise?

jcornaz added a commit to jcornaz/kwik that referenced this issue Dec 2, 2019
@jcornaz
Copy link
Author

jcornaz commented Dec 2, 2019

@3flex

Thanks for your support.

However, I couldn't get it working again. You can find a version with the changes you told me to do at the commit: d9c6c919675ac729658dfebbc73ad6c011f4b4c2 of the project.

This one should have triggered a deprecation warning in 1.2.0 for direct usage of config =

No, I confirm I don't see any warning if I use config = with detekt: 1.2.0. (Absence of warning is observable at commit 92ea258094e577de6adccefcfe91f35a6d0fdc54 of the project).

@1951FDG
Copy link

1951FDG commented Dec 2, 2019

I can also confirm I don't see any warning if I use config = with detekt: 1.2.1.

jcornaz added a commit to jcornaz/kwik that referenced this issue Dec 2, 2019
Verision 1.2.0 has a serious issue: detekt/detekt#2128
Version 1.2.1 breaks the build: detekt/detekt#2152
3flex added a commit that referenced this issue Dec 3, 2019
Restore the extension with a deprecation warning.

See #2152
@3flex
Copy link
Member

3flex commented Dec 3, 2019

@jcornaz I've worked out what the issue is. 1.2.1 removed this Gradle extension: https://github.com/arturbosch/detekt/blob/1.2.0/detekt-gradle-plugin/src/main/kotlin/io/gitlab/arturbosch/detekt/KotlinExtension.kt

It was there to allow the type-safe accessors to work in Gradle Kotlin DSL, which is why removing it causes failures in the build when type-safe accessors are not available.

I see two options:

  1. Add the extension back to the plugin with a deprecation warning, advising that there's a misconfiguration in the build file and linking to https://docs.gradle.org/current/userguide/kotlin_dsl.html
  2. Describe how the Gradle build files should be corrected (an easy way is to remove apply false against detekt in the plugins block - not strictly correct if you don't want to apply the plugin to the root project, but it restores type-safe accessors. Other options are to apply the plugin in individual module build files or use the standard API)

It probably does no harm to leave the extension in place, though it's not documented in the Gradle Kotlin DSL primer so it's probably not a supported workaround. Adding back with a deprecation message seems the best option. I'll open a PR.

I can also confirm I don't see any warning if I use config = with detekt: 1.2.1.

@1951FDG @jcornaz my mistake, the deprecation wasn't on config in the extension, but in the tasks. It doesn't affect the detekt {} block.

sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Dec 3, 2019
For details see [1]. Note that the "detekt" extension is automatically
provided when applying the plugin to the root project, also see [2].

[1] https://arturbosch.github.io/detekt/changelog.html#121
[2] detekt/detekt#2152 (comment)

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch-si.com>
sschuberth added a commit to oss-review-toolkit/ort that referenced this issue Dec 3, 2019
For details see [1]. Note that the "detekt" extension is automatically
provided when applying the plugin to the root project, also see [2].

[1] https://arturbosch.github.io/detekt/changelog.html#121
[2] detekt/detekt#2152 (comment)

Signed-off-by: Sebastian Schuberth <sebastian.schuberth@bosch-si.com>
3flex added a commit that referenced this issue Dec 4, 2019
Restore the extension with a deprecation warning.

See #2152
@arturbosch arturbosch added this to the 1.2.2 milestone Dec 5, 2019
smyachenkov pushed a commit to smyachenkov/detekt that referenced this issue Dec 9, 2019
Restore the extension with a deprecation warning.

See detekt#2152
smyachenkov pushed a commit to smyachenkov/detekt that referenced this issue Dec 9, 2019
Restore the extension with a deprecation warning.

See detekt#2152
@lock lock bot locked as resolved and limited conversation to collaborators Mar 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants