Repository navigation
Kotlin support in Maven plugin - #223
Conversation
Moved all generic formatter methods to `FormatterFactory` so that it is a base class for every configuration element. Made `Java`, `Scala` and `Format` extend it.
Kotlin formatter now supports all generic formatting steps (e.g. license header) and standard Ktlint formatter with configurable version.
To share same regex between Gradle and Maven plugins.
8599bb2 to
b761c4b
Compare
| public class Kotlin extends FormatterFactory { | ||
|
|
||
| private static final Set<String> DEFAULT_INCLUDES = unmodifiableSet(newHashSet("src/main/kotlin/**/*.kt", | ||
| "src/test/kotlin/**/*.kt")); |
There was a problem hiding this comment.
Feel free to ignore this, but I would've written as ImmutableSet.of("src/main/.... ImmutableSet gives compile-warnings if you accidentally call modifier-methods like put, and it's a little faster since it doesn't have to worry about the modification usecase.
|
Just noticed that there's no docs for kotlin or scala: https://github.com/diffplug/spotless/blob/master/plugin-maven/README.md |
|
@nedtwigg updated code to use |
| import com.diffplug.spotless.FormatterStep; | ||
| import com.diffplug.spotless.LineEnding; | ||
| import com.diffplug.spotless.maven.generic.LicenseHeader; | ||
| import com.diffplug.spotless.maven.generic.*; |
There was a problem hiding this comment.
I admit that I was surprised that this change from a full import to a wildcard import was apparently accepted by Travis CI.
@nedtwigg Do you think it would be a good idea if I open an issue to cover catching wildcard imports in the future?
There was a problem hiding this comment.
The eclipse formatter that we use doesn't have any rules against wildcard imports. It might be worth a bullet-point in this issue, maybe a config option on importSorter if it ever gets updated: #167
There was a problem hiding this comment.
@nedtwigg I'm not sure that I understood your last message correctly.
Did you mean that you'd like me to write a new message on #167 - a reminder of sorts - to add a convert-wildcard-imports-to-full-imports option to the new importOrder() formatting option that would be implemented? Or did you mean something else?
There was a problem hiding this comment.
Yup! You can make a new issue too if you'd like, but it seems like implementing the wildcard imports issue is so closely tied to the ImportSorter that it makes sense to bundle them.
There was a problem hiding this comment.
Cool! I'll go act on that now, then. :)
|
@lutovich Would you like me to cut a release with these changes? If so, would you like it to be another BETA, or should it be |
|
Hi @nedtwigg, sorry for the delayed response. I'd vote for another beta, do not have a direct use-case for the Kotlin formatter. |
| public final class KotlinConstants { | ||
|
|
||
| // '^' is prepended to the regex in LICENSE_HEADER_DELIMITER later in FormatExtension.licenseHeader(String, String) | ||
| public static final String LICENSE_HEADER_DELIMITER = "(package |@file)"; |
No description provided.