editorconfig-maven-plugin icon indicating copy to clipboard operation
editorconfig-maven-plugin copied to clipboard

A Maven plugin for checking whether project files comply with format rules defined in .editorconfig files and eventually also for fixing the violations

ifdef::env-github[] :warning-caption: :warning: endif::[]

= editorconfig-maven-plugin

https://github.com/ec4j/editorconfig-maven-plugin/blob/master/LICENSE[image:https://img.shields.io/github/license/ec4j/editorconfig-maven-plugin.svg[License]] http://search.maven.org/#search%7Cga%7C1%7Corg.ec4j.maven[image:https://img.shields.io/maven-central/v/org.ec4j.maven/editorconfig-maven-plugin.svg[Maven Central]] http://travis-ci.org/ec4j/editorconfig-maven-plugin[image:https://img.shields.io/travis/ec4j/editorconfig-maven-plugin/master.svg?logo=travis&color=white&label=Travis+CI[Travis CI build status]] https://ci.appveyor.com/project/ppalaga/editorconfig-maven-plugin[image:https://img.shields.io/appveyor/ci/ppalaga/editorconfig-maven-plugin/master.svg?logo=appveyor&color=white&label=AppVeyor+Windows+CI[AppVeyor Windows CI build status]]

editorconfig-maven-plugin is a Maven plugin for checking whether project files comply with format rules defined in http://editorconfig.org/[.editorconfig] files and eventually also for fixing the violations.

WARNING: editorconfig-maven-plugin is new. Expect issues of all kinds which is not to say that you should not https://github.com/ec4j/editorconfig-maven-plugin/issues[report] them :)

== Basic usage

editorconfig-maven-plugin requires Java 8+ and Maven 3.3.1+.

To make the build fail if any of your source files does not comply with .editorconfig rules, add the following to your project:

[source,xml]

org.ec4j.maven editorconfig-maven-plugin check verify check src/main/**/*.whatever ----

In case any violations are detected, you may want to fix them automagically by running

[source,xml]

mvn editorconfig:format

== Configuration

See http://ec4j.github.io/editorconfig-maven-plugin/check-mojo.html[editorconfig:check] and http://ec4j.github.io/editorconfig-maven-plugin/format-mojo.html[editorconfig:format].

== How it works

editorconfig-maven-plugin is designed around the Linter interface. https://github.com/ec4j/editorconfig-linters/blob/master/editorconfig-lint-api/src/main/java/org/ec4j/lint/api/Linter.java[Linter] is a processor specialized for some particular file format (such as YAML or XML) for which it can detect whether some particular .editorconfig properties are satisfied and eventually propose a https://github.com/ec4j/editorconfig-linters/blob/master/editorconfig-lint-api/src/main/java/org/ec4j/lint/api/Edit.java[fix] that can be applied automatically.

.Linters available in editorconfig-maven-plugin |=== |Class name |Default includes|Default excludes |Supported .editorconfig properties

|https://github.com/ec4j/editorconfig-linters/blob/master/editorconfig-linters/src/main/java/org/ec4j/linters/TextLinter.java[TextLinter] |pass:[**/*] | |https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#end_of_line[end_of_line], https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#trim_trailing_whitespace[trim_trailing_whitespace], https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#insert_final_newline[insert_final_newline]

|https://github.com/ec4j/editorconfig-linters/blob/master/editorconfig-linters/src/main/java/org/ec4j/linters/XmlLinter.java[XmlLinter] |pass:[**/*.xml], pass:[**/*.xsl] | |https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_style[indent_style], https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties#indent_size[indent_size] |===

Contributions of further Linters are highly welcome! Please https://github.com/ec4j/editorconfig-maven-plugin/issues[open an issue] when you start working on something to avoid duplicate work.

== How to build

Prerequisites:

  • Java 8+
  • Optionally Maven 3.5.0+, unless you want to use ./mvnw or mvnw.bat delivered by the project

The most common build with unit tests:

[source,shell]

./mvnw clean install

On Windows:

[source,shell]

.\mvnw.cmd clean install

== Misc.

  • All code and contributions are under link:/LICENSE[Apache License]
  • Issues and Discussions: https://github.com/ec4j/editorconfig-maven-plugin/issues