Skip to content

Commit

Permalink
passing defined repositories to scalafmt (alenkacz#28)
Browse files Browse the repository at this point in the history
  • Loading branch information
Miroslav Slivka committed Dec 9, 2019
1 parent 9170b25 commit 998319f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {
Expand Down

0 comments on commit 998319f

Please sign in to comment.