Skip to content

Regression in gradle/6.23.0. Unable to configre ktlint #1911

Description

@AntsyLich

summary of problem

spotless {
    kotlin { 
        ktlint()
    }
}

Having the simple block below highlights ktlint(). Hovering on it shows the message "Type BaseKotlinExtension.KtlintConfig! is inaccessible in this context due to: public open inner class KtlintConfig defined in com.diffplug.gradle.spotless.BaseKotlinExtension". But spotless works fine. Now if i try to access any method of ktlint config like below red squiggly line appers below that method and hovering over them shows the message "Cannot access 'BaseKotlinExtension': it is package-private in 'com.diffplug.gradle.spotless'"

spotless {
    kotlin {
        ktlint()
            .customRuleSets(listOf("io.nlopez.compose.rules:ktlint:0.3.3"))
    }
}

Gradle or Maven version

Gradle 8.4

spotless version

gradle/6.23.0

operating system and version

Windows 11

copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the problem if possible

See above

copy-paste the full content of any console errors emitted by gradlew spotless[Apply/Check] --stacktrace

> Configure project :app
w: file:///D:/[...]/android/app/build.gradle.kts:46:9: Type BaseKotlinExtension.KtlintConfig! is inaccessible in this context due to: public open inner class KtlintConfig defined in com.diffplug.gradle.spotless.BaseKotlinExtension
w: file:///D:/[...]/android/app/build.gradle.kts:46:9: Type BaseKotlinExtension.KtlintConfig! is inaccessible in this context due to: public open inner class KtlintConfig defined in com.diffplug.gradle.spotless.BaseKotlinExtension
e: file:///D:/[...]/android/app/build.gradle.kts:47:14: Cannot access 'BaseKotlinExtension': it is package-private in 'com.diffplug.gradle.spotless'

FAILURE: Build failed with an exception.

* Where:
Build file 'D:\[...]\android\app\build.gradle.kts' line: 47

* What went wrong:
Script compilation error:

  Line 47:             .customRuleSets(listOf("io.nlopez.compose.rules:ktlint:0.3.3"))
                        ^ Cannot access 'BaseKotlinExtension': it is package-private in 'com.diffplug.gradle.spotless'

If you're just submitting a feature request or question, no need for the above.

Activity

  1. Goooler commented on Nov 27, 2023

    @Goooler
    Member

    Fixing this in #1912.

  2. TWiStErRob commented on Nov 27, 2023

    @TWiStErRob

    See also gradle-nexus/publish-plugin#286, same issue.

  3. StefanLobbenmeierObjego commented on Nov 27, 2023

    @StefanLobbenmeierObjego

    ktfmt is affected by the same issue, adding this here in case someone searches for that instead:

    * What went wrong:
    Script compilation error:
    
      Line 141:     kotlinGradle { ktfmt().dropboxStyle() }
                                           ^ Cannot access 'BaseKotlinExtension': it is package-private in 'com.diffplug.gradle.spotless'
    
    1 error
    
  4. added a commit that references this issue on Nov 27, 2023
  5. madorb commented on Nov 28, 2023

    @madorb

    Same issue with greclipse()

  6. nedtwigg commented on Nov 29, 2023

    @nedtwigg
    Member

    Fixed in plugin-gradle 6.23.1. It has been published in the Gradle plugin repository, but the maven central sync appears to be jammed for now. Should resolve in a few hours.

  7. StefanLobbenmeierObjego commented on Nov 30, 2023

    @StefanLobbenmeierObjego

    I was able to update to v6.23.2 now and that fixed the issue, thanks ❤️

  8. yoobi commented on May 25, 2024

    @yoobi

    I am having the same issue with 6.25.0

    No signature of method: com.diffplug.gradle.spotless.BaseKotlinExtension$KtlintConfig.userData() is applicable for argument types: (LinkedHashMap) values: [[android:true]
    
    ktlint().userData(["android": "true"])
    
  9. Goooler commented on May 25, 2024

    @Goooler
    Member

    userData method has been removed from Ktlint step in #1891, you may use editorConfigOverride instead.

    I noted this in 6.23.0 changelog.

  10. yoobi commented on May 25, 2024

    @yoobi

    Oh shoot I missed this, sorry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions