diff --git a/build.gradle b/build.gradle index 6144d38..8bed252 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ repositories { dependencies { compile gradleApi() - compile "org.scalameta:scalafmt-dynamic_2.12:2.2.2" + compile "org.scalameta:scalafmt-dynamic_2.12:2.3.2" compile group: 'org.scala-lang.modules', name: 'scala-xml_2.12', version: '1.1.1' testCompile group: 'junit', name: 'junit', version: '4.12' diff --git a/src/main/groovy/cz/alenkacz/gradle/scalafmt/ScalafmtFormatBase.groovy b/src/main/groovy/cz/alenkacz/gradle/scalafmt/ScalafmtFormatBase.groovy index e91b886..3d1722a 100644 --- a/src/main/groovy/cz/alenkacz/gradle/scalafmt/ScalafmtFormatBase.groovy +++ b/src/main/groovy/cz/alenkacz/gradle/scalafmt/ScalafmtFormatBase.groovy @@ -6,6 +6,7 @@ import org.gradle.api.tasks.SourceSet import org.scalafmt.interfaces.Scalafmt import org.scalafmt.interfaces.ScalafmtClassLoader import java.nio.file.Paths +import java.util.stream.Collectors class ScalafmtFormatBase extends DefaultTask { SourceSet sourceSet @@ -14,7 +15,13 @@ class ScalafmtFormatBase extends DefaultTask { def formatter = Scalafmt.create(cl) .withRespectVersion(false) .withDefaultVersion("1.5.1") + .withMavenRepositories(repositories()) + private String[] repositories() { + project.getRepositories().stream().map { repository -> + repository.properties.get("url").toString() + }.collect(Collectors.toList()).toArray(new String[0]) + } def runScalafmt(boolean testOnly = false) { if (project.plugins.withType(JavaBasePlugin).empty) {