aboutsummaryrefslogtreecommitdiff
path: root/coursier/Coursier.scala
blob: f5727a7b877818cdfebbefc72b28430d76a20965 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
package cbt
object Coursier{
  implicit class CoursierDependencyResolution(d: JavaDependency){
    import d._
    def resolveCoursier = {
      import coursier._
      val repositories = Seq(
        Cache.ivy2Local,
        MavenResolver("https://repo1.maven.org/maven2")
      )

      val start = Resolution(
        Set(
          JavaDependency(
            Module(groupId, artifactId), version
          )
        )
      )

      val fetch = Fetch.from(repositories, Cache.fetch())


      val resolution = start.process.run(fetch).run

      val errors: Seq[(JavaDependency, Seq[String])] = resolution.errors

      if(errors.nonEmpty) throw new Exception(errors.toString)

      import java.io.File
      import scalaz.\/
      import scalaz.concurrent.Task

      val localArtifacts: Seq[FileError \/ File] = Task.gatherUnordered(
        resolution.artifacts.map(Cache.file(_).run)
      ).run

      val files = localArtifacts.map(_.toEither match {
        case Left(error) => throw new Exception(error.toString)
        case Right(file) => file
      })

      resolution.dependencies.map( d => cbt.JavaDependency(d.module.organization,d.module.name, d.version)).toVector
    }
  }
}
*/