diff --git a/plugin/src/main/scala/coursier/InterProjectRepository.scala b/plugin/src/main/scala/coursier/InterProjectRepository.scala index 9e21bb58d..8eb094420 100644 --- a/plugin/src/main/scala/coursier/InterProjectRepository.scala +++ b/plugin/src/main/scala/coursier/InterProjectRepository.scala @@ -2,40 +2,12 @@ package coursier import scalaz.{ -\/, \/-, Monad, EitherT } -case class InterProjectSource(artifacts: Map[(Module, String), Map[String, Seq[Artifact]]]) extends Artifact.Source { - def artifacts( - dependency: Dependency, - project: Project, - overrideClassifiers: Option[Seq[String]] - ): Seq[Artifact] = - overrideClassifiers match { - case None => - artifacts - .get(dependency.moduleVersion) - .toSeq - .flatMap(_.get(dependency.configuration)) - .flatten - case Some(_) => - Nil - } -} - -case class InterProjectRepository(projects: Seq[(Project, Seq[(String, Seq[Artifact])])]) extends Repository { +case class InterProjectRepository(projects: Seq[Project]) extends Repository { private val map = projects - .map { case (proj, _) => proj.moduleVersion -> proj } + .map { proj => proj.moduleVersion -> proj } .toMap - val source = InterProjectSource( - projects.map { case (proj, artifactsByConfig) => - val artifacts = artifactsByConfig.toMap - val allArtifacts = proj.allConfigurations.map { case (config, extends0) => - config -> (extends0 + config).toSeq.flatMap(artifacts.getOrElse(_, Nil)) - } - proj.moduleVersion -> allArtifacts - }.toMap - ) - def find[F[_]]( module: Module, version: String, @@ -45,7 +17,7 @@ case class InterProjectRepository(projects: Seq[(Project, Seq[(String, Seq[Artif ): EitherT[F, String, (Artifact.Source, Project)] = { val res = map.get((module, version)) match { case Some(proj) => - \/-((source, proj)) + \/-((Artifact.Source.empty, proj)) case None => -\/("Not found") } diff --git a/plugin/src/main/scala/coursier/Keys.scala b/plugin/src/main/scala/coursier/Keys.scala index 3ae648fe3..d870f320d 100644 --- a/plugin/src/main/scala/coursier/Keys.scala +++ b/plugin/src/main/scala/coursier/Keys.scala @@ -18,8 +18,8 @@ object Keys { val coursierCache = SettingKey[File]("coursier-cache", "") - val coursierProject = TaskKey[(Project, Seq[(String, Seq[Artifact])])]("coursier-project", "") - val coursierProjects = TaskKey[Seq[(Project, Seq[(String, Seq[Artifact])])]]("coursier-projects", "") + val coursierProject = TaskKey[Project]("coursier-project", "") + val coursierProjects = TaskKey[Seq[Project]]("coursier-projects", "") val coursierPublications = TaskKey[Seq[(String, Publication)]]("coursier-publications", "") val coursierSbtClassifiersModule = TaskKey[GetClassifiersModule]("coursier-sbt-classifiers-module", "") diff --git a/plugin/src/main/scala/coursier/Tasks.scala b/plugin/src/main/scala/coursier/Tasks.scala index dc0e97c48..1e43da038 100644 --- a/plugin/src/main/scala/coursier/Tasks.scala +++ b/plugin/src/main/scala/coursier/Tasks.scala @@ -32,7 +32,7 @@ object Tasks { resolvers } - def coursierProjectTask: Def.Initialize[sbt.Task[(Project, Seq[(String, Seq[Artifact])])]] = + def coursierProjectTask: Def.Initialize[sbt.Task[Project]] = ( sbt.Keys.state, sbt.Keys.thisProjectRef @@ -41,41 +41,23 @@ object Tasks { // should projectID.configurations be used instead? val configurations = ivyConfigurations.in(projectRef).get(state) - // exportedProducts looks like what we want, but depends on the update task, which - // make the whole thing run into cycles... - val artifacts = configurations.map { cfg => - cfg.name -> Option(classDirectory.in(projectRef).in(cfg).getOrElse(state, null)) - }.collect { case (name, Some(classDir)) => - name -> Seq( - Artifact( - classDir.toURI.toString, - Map.empty, - Map.empty, - Attributes(), - changing = true - ) - ) - } - val allDependenciesTask = allDependencies.in(projectRef).get(state) for { allDependencies <- allDependenciesTask } yield { - val proj = FromSbt.project( + FromSbt.project( projectID.in(projectRef).get(state), allDependencies, configurations.map { cfg => cfg.name -> cfg.extendsConfigs.map(_.name) }.toMap, scalaVersion.in(projectRef).get(state), scalaBinaryVersion.in(projectRef).get(state) ) - - (proj, artifacts) } } - def coursierProjectsTask: Def.Initialize[sbt.Task[Seq[(Project, Seq[(String, Seq[Artifact])])]]] = + def coursierProjectsTask: Def.Initialize[sbt.Task[Seq[Project]]] = sbt.Keys.state.flatMap { state => val projects = structure(state).allProjectRefs coursierProject.forAllProjects(state, projects).map(_.values.toVector) @@ -162,7 +144,7 @@ object Tasks { scalaBinaryVersion.value ) else { - val (proj, _) = coursierProject.value + val proj = coursierProject.value val publications = coursierPublications.value proj.copy(publications = publications) } @@ -202,7 +184,7 @@ object Tasks { val startRes = Resolution( currentProject.dependencies.map { case (_, dep) => dep }.toSet, filter = Some(dep => !dep.optional), - forceVersions = projects.map { case (proj, _) => proj.moduleVersion }.toMap + forceVersions = projects.map(_.moduleVersion).toMap ) // required for publish to be fine, later on @@ -224,7 +206,7 @@ object Tasks { def report = { if (verbosity >= 1) { println("InterProjectRepository") - for ((p, _) <- projects) + for (p <- projects) println(s" ${p.module}:${p.version}") }