Skip to content

Commit dca1d36

Browse files
committed
When no formatter dependency is declared, the plugin should fail
1 parent 028ebdf commit dca1d36

File tree

6 files changed

+14
-4
lines changed

6 files changed

+14
-4
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
A maven plugin that automatically deploys code formatters as `pre-commit` git hook.
77
On commit, the hook will automatically format staged files.
88

9+
# Breaking changes between 4.x and 5.x
10+
11+
* If the plugin runs without any formatter dependency, it will fail. This is done to prevent silent misconfiguration from happening.
12+
913
# Breaking changes between 3.x and 4.x
1014

1115
* `Google Java Format` is not enabled by default anymore. `com.cosium.code:google-java-format` must be added as a dependency to the plugin to keep using it.

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.cosium.code</groupId>
66
<artifactId>git-code-format-maven-plugin-parent</artifactId>
7-
<version>4.4-SNAPSHOT</version>
7+
<version>5.0-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>git-code-format-maven-plugin</artifactId>

core/src/main/java/com/cosium/code/format/AbstractMavenGitCodeFormatMojo.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,12 @@ private List<CodeFormatter> createCodeFormatters() {
8585

8686
List<CodeFormatterFactory> formatterFactories = new ArrayList<>();
8787
ServiceLoader.load(CodeFormatterFactory.class).forEach(formatterFactories::add);
88+
if (formatterFactories.isEmpty()) {
89+
throw new IllegalStateException(
90+
"No "
91+
+ CodeFormatter.class
92+
+ " instance found. You probably forgot to declare a code formatter as a plugin's dependency. You can use https://github.com/Cosium/git-code-format-maven-plugin#automatic-code-format-and-validation-activation as an example.");
93+
}
8894

8995
CodeFormatterConfigurationFactory formatterConfigurationFactory =
9096
new CodeFormatterConfigurationFactory(

google-java-format/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.cosium.code</groupId>
66
<artifactId>git-code-format-maven-plugin-parent</artifactId>
7-
<version>4.4-SNAPSHOT</version>
7+
<version>5.0-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>google-java-format</artifactId>

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
<groupId>com.cosium.code</groupId>
55
<artifactId>git-code-format-maven-plugin-parent</artifactId>
6-
<version>4.4-SNAPSHOT</version>
6+
<version>5.0-SNAPSHOT</version>
77
<packaging>pom</packaging>
88

99
<name>Git Code Format Maven Plugin Parent</name>

spi/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>com.cosium.code</groupId>
66
<artifactId>git-code-format-maven-plugin-parent</artifactId>
7-
<version>4.4-SNAPSHOT</version>
7+
<version>5.0-SNAPSHOT</version>
88
</parent>
99

1010
<artifactId>git-code-format-maven-plugin-spi</artifactId>

0 commit comments

Comments
 (0)