Skip to content
This repository was archived by the owner on Jun 21, 2019. It is now read-only.

Code formatting #2

Merged
merged 7 commits into from
Sep 28, 2017
Merged

Conversation

MrCustomizer
Copy link
Collaborator

I've added the spotless plugin for code formatting to the project. Travis-CI fails, if the formatting of a file does not comply to the code style settings.

I've tried to find formatting settings, that fit the current project, so that as few changes to the existing files have to be done as possible.

By executing the gradle task spotlessApply, the files are automatically formatted. At the moment, the user has to run this task by himself.

Auto formatting in Eclipse
Spotless internally uses Eclipses formatter, so Eclipse users could just import the code formatter options and the import order file from the projects base directory and use Eclipse's save actions to automatically apply the formatting on every save. I expect this to work pretty flawlessly, but I haven't tested this.

Auto formatting in Intellij Idea
For users of Idea I see only two options for automatic formatting, both of them are probably not ideal (suggestions for better solutions are very welcome):

  1. Either import the formatting settings from the file spotless.eclipseformat.xml. I don't know, how well this works, as I could imagine that there are incompatibilities between Eclipse's and Idea's formatters. I haven't tested this, yet.
  2. Or enable the setting to automatically save files before starting the build. Execute the spotlessApply task on every build (right click on the task in the view "Gradle project" and activate "Execute before Build"). Reassign Ctrl-S to "Build project" or use the current shortcut for "Build project" instead of saving. With all the obvious side effects.

@maxidorius maxidorius merged commit 0170888 into kamax-matrix:master Sep 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants