Skip to content

Commit

Permalink
Report an error when custom ruleset providers are still registered un…
Browse files Browse the repository at this point in the history
…der the old package (#485)

* Also added explicit note into 0.32.0 CHANGELOG
* Fixed template service registration

Fixes #481
  • Loading branch information
shashachu authored Jun 11, 2019
1 parent 044b8e2 commit af72025
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Code now lives in `com.pinterest` package
- groupId now `com.pinterest`
- Custom ruleset `META-INF.services` file must be renamed to `com.pinterest.ktlint.core.RuleSetProvider`

## [0.31.0] - 2019-03-10

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.github.shyiko.ktlint.core

/**
* https://github.com/pinterest/ktlint/issues/481
*
* Keep the RuleSetProvider in the old package so that we can detect it and throw an error.
*/
@Deprecated("RuleSetProvider has moved to com.pinterest.ktlint.core")
interface RuleSetProvider
9 changes: 9 additions & 0 deletions ktlint/src/main/kotlin/com/pinterest/ktlint/Main.kt
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ class KtlintCommandLine {
if (!rulesets.isEmpty()) {
loadJARs(dependencyResolver, rulesets)
}

// Detect custom rulesets that have not been moved to the new package
if (ServiceLoader.load(com.github.shyiko.ktlint.core.RuleSetProvider::class.java).any()) {
System.err.println("[ERROR] Cannot load custom ruleset!")
System.err.println("[ERROR] RuleSetProvider has moved to com.pinterest.ktlint.core.")
System.err.println("[ERROR] Please rename META-INF/services/com.github.shyiko.ktlint.core.RuleSetProvider to META-INF/services/com.pinterest.ktlint.core.RuleSetProvider")
exitProcess(1)
}

// standard should go first
val ruleSetProviders =
ServiceLoader.load(RuleSetProvider::class.java)
Expand Down

0 comments on commit af72025

Please sign in to comment.