Skip to content

Commit

Permalink
Look for scalafmt config also in the root project
Browse files Browse the repository at this point in the history
  • Loading branch information
alenkacz authored Feb 1, 2019
2 parents f670172 + 142eea1 commit 1ee6cf8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ Usage
}

scalafmt {
// configFilePath = ".scalafmt.conf" // .scalafmt.conf in the project root is default value, provide only if other location is needed
// .scalafmt.conf in the project root is default value, provide only if other location is needed
// config file has to be relative path from current project or root project in case of multimodule projects
// example usage:
// configFilePath = ".scalafmt.conf"
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ class ConfigFactory {
static ScalafmtConfig load(Logger logger, Project project, String configFilePath) {
def customConfig = project.file(configFilePath)
if (!customConfig.exists()) {
logger.info("Custom config $configFilePath not found, using default scalafmt config")
return ScalafmtConfig$.MODULE$.default
// when config does not exist in the project folder, look also to a root of multimodule project
customConfig = project.rootProject.file(configFilePath)
if (!customConfig.exists()) {
logger.info("Custom config $configFilePath not found, using default scalafmt config")
return ScalafmtConfig$.MODULE$.default
}
}
def parsedConfig = Config.fromHoconString(customConfig.text, Config.fromHoconString$default$2())

Expand Down

0 comments on commit 1ee6cf8

Please sign in to comment.