diff --git a/README.md b/README.md index 258e50c..016355a 100644 --- a/README.md +++ b/README.md @@ -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" } diff --git a/src/main/groovy/cz/alenkacz/gradle/scalafmt/ConfigFactory.groovy b/src/main/groovy/cz/alenkacz/gradle/scalafmt/ConfigFactory.groovy index 368ab31..96bb0dc 100644 --- a/src/main/groovy/cz/alenkacz/gradle/scalafmt/ConfigFactory.groovy +++ b/src/main/groovy/cz/alenkacz/gradle/scalafmt/ConfigFactory.groovy @@ -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())