Skip to content

feature parity with others klint gradle plugins #616

Description

@LifeIsStrange

I would like spotless to become the best reference solution for Klint.

There is at least two competitors:
https://github.com/jeremymailen/kotlinter-gradle with ~100 commits it seems a bit young but:
like him does spotless supports:

  • incremental build support (performance matters)
  • file reports
  • *.kts source support
  • ability to have different code style between .kt and .kts files (a minor feature)

https://github.com/jlleitschuh/ktlint-gradle this one has had a lot of work with its ~600 commits (still less than spotless)

  • Gradle build caching
  • ???

My biggest question is: which one is the fastest (using intellij) ?
Maybe that #601 would help performance
Maybe that your current use of reflection (#524) might harm performance too ?

What do you think ?

Activity

  1. nedtwigg commented on Jun 18, 2020

    @nedtwigg
    Member

    For every formatter that Spotless suppports, there are multiple formatter-specific plugins on the plugin portal. I believe that is largely because once a plugin has been published, you cannot update its tags or descriptions. e.g. if you search the portal for google-java-format or ktlint, Spotless does not show up. We will be fixing that soon by publishing at a new id, com.diffplug.spotless, and adding tags for all the formatters we support today.

    In terms of performance, Spotless already supports incremental build and the local build cache. We have to fix #566 before we can support remote build cache.

    A less-well-known advantage is that we cache classloaders across subprojects and daemon runs, which allows the JIT to perform much better than a simple "every project and build gets its own classloader". At the time we implemented that feature a long time ago, it was a many-X performance improvement, perhaps the other projects implemented that as well, I don't know.

    A huge performance improvement is ratchetFrom 'origin/main', which allows you to:

    • keep copyright headers up-to-date
    • migrate your format gracefully
    • really really really big speed improvement (~10-100x)

    An ooper-dooper performance improvement is our IDE hook, which currently has only a VS Code plugin but could easily have an IntelliJ plugin as well.

    If you want separate format for .kt and .kts, you can do that if we make this method public and rename it to format:

    import com.diffplug.gradle.spotless.KotlinExtension
    
    spotless {
      kotlin {
        target 'src/**/*.kt'
        ktlint()
      }
      format 'kotlinScript', KotlinExtension, {
        target 'src/**/*.kts'
        ktlint()
      }

    I am confident that our use of reflection has a too-small-to-measure impact on performance, because per-format-call we are only making one or two reflection calls. The main problem with our reflection is that it's hard to read. #524 would fix this. And that hard-to-read part cascades into missing features like #142 and #409.

    So that's the landscape. if you would like to make improvements to our docs or implementation anywhere, we would be happy to assist you!

  2. nedtwigg commented on Jun 19, 2020

    @nedtwigg
    Member

    Just FYI, the example above with format 'kotlinScript', KotlinExtension, { will work as of plugin-gradle 4.4.0 and higher.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions