Skip to content
New issue

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

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

Already on GitHub? # to your account

maven plugin "<importOrder/>" doesn't work for kotlin #679

Closed
5 of 6 tasks
Lzxe92 opened this issue Sep 1, 2020 · 1 comment
Closed
5 of 6 tasks

maven plugin "<importOrder/>" doesn't work for kotlin #679

Lzxe92 opened this issue Sep 1, 2020 · 1 comment

Comments

@Lzxe92
Copy link

Lzxe92 commented Sep 1, 2020

If you are submitting a bug, please include the following:

  • summary of problem
    Trying to use ktlint with spotless maven plugin, however got error when running mvn spotless:check
  • gradle or maven version
Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
Maven home: C:\Users\P1332200\.m2\wrapper\dists\apache-maven-3.6.3-bin\1iopthnavndlasol9gbrbg6bf2\apache-maven-3.6.3
Java version: 11.0.8, vendor: Oracle Corporation, runtime: C:\software\jdk-11.0.8
Default locale: en_US, platform encoding: UTF-8
OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"
  • spotless version
    2.1.0

  • operating system and version

  • copy-paste your full Spotless configuration block(s), and a link to a public git repo that reproduces the
    `
    com.diffplug.spotless
    spotless-maven-plugin
    ${spotless.version}

                  <formats>
                      <!-- you can define as many formats as you want, each is independent -->
                      <format>
                          <!-- define the files to apply to -->
                          <includes>
                              <include>*.md</include>
                              <include>.gitignore</include>
                          </includes>
                          <!-- define the steps to apply to those files -->
                          <trimTrailingWhitespace/>
                          <endWithNewline/>
                          <indent>
                              <tabs>true</tabs>
                              <spacesPerTab>4</spacesPerTab>
                          </indent>
                      </format>
                  </formats>
                  <!-- define a language-specific format -->
                  <java>
                      <!-- These are the defaults, you can override if you want -->
                      <includes>
                          <include>src/main/**/**/*.java</include>
                          <include>src/test/**/**/*.java</include>
                      </includes>
    
                      <importOrder /> <!-- standard import order -->
                      <importOrder>  <!-- or a custom ordering -->
                          <order>java,javax,org,com,com.diffplug,</order>  <!-- or use <file>${basedir}/eclipse.importorder</file> -->
                          <!-- You probably want an empty string at the end - all of the
                               imports you didn't specify explicitly will go there. -->
                      </importOrder>
    
                      <removeUnusedImports /> <!-- self-explanatory -->
    
                      <googleJavaFormat>
                          <version>1.9</version> <!-- optional -->
                          <style>GOOGLE</style>  <!-- or AOSP (optional) -->
                      </googleJavaFormat>
    
                      <licenseHeader>
                          <content>/* (C)$YEAR */</content>  <!-- or <file>${basedir}/license-header</file> -->
                      </licenseHeader>
                  </java>
                  <kotlin>
                      <!-- These are the defaults, you can override if you want -->
                      <includes>
                          <include>src/main/kotlin/**/*.kt</include>
                          <include>src/test/kotlin/**/*.kt</include>
                      </includes>
    
                      <importOrder/> <!-- standard import order -->
                      <importOrder>  <!-- or a custom ordering -->
                          <order>java,javax,org,com,com.diffplug,</order>  <!-- or use <file>${basedir}/eclipse.importorder</file> -->
                          <!-- You probably want an empty string at the end - all of the
                               imports you didn't specify explicitly will go there. -->
                      </importOrder>
    
                      <removeUnusedImports /> <!-- self-explanatory -->
    
                      <ktlint />   <!-- has its own section below -->
                      <ktfmt />    <!-- has its own section below -->
                      <prettierv/> <!-- has its own section below -->
    
                      <licenseHeader>
                          <content>/* (C)$YEAR */</content>  <!-- or <file>${basedir}/license-header</file> -->
                      </licenseHeader>
                  </kotlin>
              </configuration>
          </plugin>`
    

problem if possible

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

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

@nedtwigg
Copy link
Member

nedtwigg commented Sep 1, 2020

It looks like you're using every single kotlin step at once. The kotlin section is meant to be a reference, not a quickstart. I would start here:

And then pick which kotlin steps you want to use:

But also, the importOrder step isn't meant to work for kotlin anyway, it's a typo in the docs. Thanks for reporting!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants