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

'tabulation.char=space' is not honoured and not formatted with spaces #269

Closed
donovanmuller opened this issue Feb 14, 2018 · 7 comments
Closed

Comments

@donovanmuller
Copy link

Using the following plugin configuration:

            ...
            <plugin>
                <groupId>net.revelc.code.formatter</groupId>
                <artifactId>formatter-maven-plugin</artifactId>
                <version>2.7.1</version>
                <configuration>
                    <configFile>${project.basedir}/eclipse/eclipse-code-formatter.xml</configFile>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>format</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
            ...

and the attached Eclipse formatting file eclipse-code-formatter.xml.txt with the 'Tab policy' set to 'Spaces only':

<setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/>

screen shot 2018-02-14 at 14 48 54

Running mvn formatter:format formats files with tab characters and not spaces as per the formatter file setting.

However, using the Eclipse Code Formatter IntellIJ plugin and the same formatter file as attached and the result is as expected (using spaces).

@ctubbsii
Copy link
Member

Have you tried that configuration file in Eclipse directly? This plugin uses the Eclipse formatter and should format exactly as Eclipse would. I think the problem might be that Eclipse won't necessarily change whitespace unless there's another formatting change also required. I could be wrong about that.

@donovanmuller
Copy link
Author

Yes, Eclipse formats as expected:

eclipse-format

@ctubbsii
Copy link
Member

Oh, I think I might know what's happening. I think it's not using your plugin configuration correctly, because it's not being executed as part of a maven build lifecycle. This is the same issue as #261 . Try running mvn clean formatter:format or mvn compile formatter:format instead of just mvn formatter:format.

Also, since you're just using formatter to refer to the plugin, I assume you're also configuring pluginGroups for net.revelc.code.formatter as in these instructions.

@donovanmuller
Copy link
Author

@ctubbsii Running as part of a lifecycle worked. Tried it with mvn clean formatter:format

Thanks

@leblonk
Copy link

leblonk commented May 23, 2018

I ran into this same problem on a multimodule project (where I was erroneously trying to refer to the parent directory). Underlying issue seems to be that the plugin doesn't fail if it can't find the formatter file from the config, but instead silently reverts to the default setup. In debug mode, there's a stacktrace showing the file wasn't found.

@ctubbsii
Copy link
Member

@leblonk Sounds like a separate issue. Mind creating one regarding the silent failure when the preferred config cannot be loaded?

@leblonk
Copy link

leblonk commented May 23, 2018

So done: #275

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

No branches or pull requests

3 participants