Is there a way to configure the project-specific Java code style and import rules in IntelliJ with a Gradle task?
In Eclipse it is possible by copying org.eclipse.jdt.core.prefs
and org.eclipse.jdt.ui.prefs
to $PROJECT/.settings/
.
Use EditorConfig. It's cross platform/IDE/tool and IDEA has native support for it so it pretty much does what you want in less destructive way.
For example all my projects have the following .editorconfig
file:
# EditorConfig is awesome: http://EditorConfig.org
# top-most EditorConfig file
root = true
# all-encompassing default settings unless otherwise specified
[*]
indent_style = space
indent_size = 4
end_of_line = lf
insert_final_newline = true
charset = utf-8
trim_trailing_whitespace = true
For actual code style conventions, I recommend human eye. Code style is social, not technical problem. If, however, you run some really obscure and specific formatting ruleset, you should look into IntelliJ IDEA help: Exporting and Importing Settings for sharing the formatting configurations between devs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With