Docker container to run the IntelliJ formatter on your groovy files.
$ docker run --rm intellij-format -h
IntelliJ IDEA 2018.2.5, build IC-182.4892.20 Formatter
Usage: format [-h] [-r|-R] [-s|-settings settingsPath] path1 path2...
-h|-help Show a help message and exit.
-s|-settings A path to Intellij IDEA code style settings .xml file.
-r|-R Scan directories recursively.
-m|-mask A comma-separated list of file masks.
path<n> A path to a file or a directory.
Use the --user
option to preserve your files ownership and the --volume
option to mount your current directory in the container.
- Format a single HelloWorld.groovy groovy file:
$ docker run --rm --user $(id -u):$(id -g) --volume $(pwd):/data intellij-format HelloWorld.groovy
- Format all the groovy files in the current directory recursively:
$ docker run --rm --user $(id -u):$(id -g) --volume $(pwd):/data intellij-format -r -m *.groovy .
$ docker build -t intellij-format .
By default, the IntelliJ formatter will use the code style settings configured in the file groovy-code-style.xml.
This file can be generated directly from IntelliJ by following this documentation: Copying Code Style Settings
Since this code style settings file is copied during the build of the image, any modification to it must be followed by a re-build of the container to be applied. This mechanism allows for a versionning of the code style settings with the repository.