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

maven plugin "<importOrder/>" doesn't work #663

Closed
stephen-smith opened this issue Aug 8, 2020 · 1 comment
Closed

maven plugin "<importOrder/>" doesn't work #663

stephen-smith opened this issue Aug 8, 2020 · 1 comment
Labels

Comments

@stephen-smith
Copy link

stephen-smith commented Aug 8, 2020

Maven plugin documents feature that does not (currently?) exist

https://github.com/diffplug/spotless/tree/0df556107251f7fec25282394d448a84eee0a325/plugin-maven#java states that an importOrder element with no attributes or children applies the "standard import order".

throw new IllegalArgumentException("Must specify exactly one of 'file' or 'order'.");
cleary requires an order to be specified; there is no "standard import order".

  • gradle or maven version

    % mvn --version
    Apache Maven 3.6.0
    Maven home: /usr/share/maven
    Java version: 11.0.8, vendor: Debian, runtime: /usr/lib/jvm/java-11-openjdk-amd64
    Default locale: en_US, platform encoding: UTF-8
    OS name: "linux", version: "4.19.0-10-amd64", arch: "amd64", family: "unix"
    
  • spotless version: 2.0.1

  • operating system and version: Debian GNU+Linux 10.5

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

      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.0.1</version>
        <configuration>
          <ratchetFrom>a0ce</ratchetFrom>
          <java>
            <trimTrailingWhitespace />
            <endWithNewline />
            <importOrder/>
            <removeUnusedImports/>
            <prettier>
              <devDependencyProperties>
                <property>
                  <name>prettier</name>
                  <value>2.0.5</value>
                </property>
                <property>
                  <name>prettier-plugin-java</name>
                  <value>0.8.0</value>
                </property>
              </devDependencyProperties>
              <config>
                <parser>java</parser>
              </config>
            </prettier>
          </java>
        </configuration>
      </plugin>
    

    No public repository available. Proprietary code.

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

    This is from mvn -X spotless:check it should have what you need.

    Caused by: java.lang.IllegalArgumentException: Must specify exactly one of 'file' or 'order'.                                                                 
        at com.diffplug.spotless.maven.java.ImportOrder.newFormatterStep (ImportOrder.java:44)                                                                    
        at com.diffplug.spotless.maven.FormatterFactory.lambda$newFormatter$1 (FormatterFactory.java:81)                                                          
        at java.util.stream.ReferencePipeline$3$1.accept (ReferencePipeline.java:195)                                                                             
        at java.util.stream.ReferencePipeline$2$1.accept (ReferencePipeline.java:177)                                                                             
        at java.util.ArrayList$ArrayListSpliterator.forEachRemaining (ArrayList.java:1655)                                                                        
        at java.util.stream.AbstractPipeline.copyInto (AbstractPipeline.java:484)
        at java.util.stream.AbstractPipeline.wrapAndCopyInto (AbstractPipeline.java:474)                                                                          
        at java.util.stream.ReduceOps$ReduceOp.evaluateSequential (ReduceOps.java:913)                                                                            
        at java.util.stream.AbstractPipeline.evaluate (AbstractPipeline.java:234)
        at java.util.stream.ReferencePipeline.collect (ReferencePipeline.java:578)
        at com.diffplug.spotless.maven.FormatterFactory.newFormatter (FormatterFactory.java:82)                                                                   
        at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:141)                                                               
        at com.diffplug.spotless.maven.AbstractSpotlessMojo.execute (AbstractSpotlessMojo.java:127)                                                               
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:137)                                                     
    
@nedtwigg nedtwigg added the bug label Aug 9, 2020
@nedtwigg nedtwigg changed the title gradle-maven-plugin documentation bug maven plugin "<importOrder/>" doesn't work Aug 9, 2020
nedtwigg added a commit that referenced this issue Aug 9, 2020
@nedtwigg
Copy link
Member

Thanks for reporting, fixed in plugin-maven 2.0.2.

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

No branches or pull requests

2 participants