diff --git a/cache/src/main/scala/coursier/Cache.scala b/cache/src/main/scala/coursier/Cache.scala index 76871be43..7448fb091 100644 --- a/cache/src/main/scala/coursier/Cache.scala +++ b/cache/src/main/scala/coursier/Cache.scala @@ -467,13 +467,33 @@ object Cache { } } + private lazy val ivy2HomeUri = { + // a bit touchy on Windows... - don't try to manually write down the URI with s"file://..." + val str = new File(sys.props("user.home") + "/.ivy2/").toURI.toString + if (str.endsWith("/")) + str + else + str + "/" + } + lazy val ivy2Local = IvyRepository( - // a bit touchy on Windows... - don't try to get the URI manually like s"file://..." - new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString + + ivy2HomeUri + "local/" + "[organisation]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/" + "[artifact](-[classifier]).[ext]" ) + lazy val ivy2Cache = IvyRepository( + ivy2HomeUri + "cache/" + + "(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[organisation]/[module]/[type]s/[artifact]-[revision](-[classifier]).[ext]", + metadataPatternOpt = Some( + ivy2HomeUri + "cache/" + + "(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[organisation]/[module]/[type]-[revision](-[classifier]).[ext]" + ), + withChecksums = false, + withSignatures = false, + dropInfoAttributes = true + ) + lazy val defaultBase = new File( sys.env.getOrElse( "COURSIER_CACHE", diff --git a/cache/src/main/scala/coursier/CacheParse.scala b/cache/src/main/scala/coursier/CacheParse.scala index 69409ecad..8914e3ad4 100644 --- a/cache/src/main/scala/coursier/CacheParse.scala +++ b/cache/src/main/scala/coursier/CacheParse.scala @@ -10,6 +10,8 @@ object CacheParse { def repository(s: String): Validation[String, Repository] = if (s == "ivy2local" || s == "ivy2Local") Cache.ivy2Local.success + else if (s == "ivy2cache" || s == "ivy2Cache") + Cache.ivy2Cache.success else { val repo = Parse.repository(s) diff --git a/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala b/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala index 5fc7e077d..599b5ceac 100644 --- a/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala +++ b/core/shared/src/main/scala/coursier/ivy/IvyRepository.scala @@ -12,7 +12,9 @@ case class IvyRepository( properties: Map[String, String] = Map.empty, withChecksums: Boolean = true, withSignatures: Boolean = true, - withArtifacts: Boolean = true + withArtifacts: Boolean = true, + // hack for SBT putting infos in properties + dropInfoAttributes: Boolean = false ) extends Repository { def metadataPattern: String = metadataPatternOpt.getOrElse(pattern) @@ -138,14 +140,28 @@ case class IvyRepository( for { artifact <- EitherT(F.point(eitherArtifact)) ivy <- fetch(artifact) - proj <- EitherT(F.point { + proj0 <- EitherT(F.point { for { xml <- \/.fromEither(compatibility.xmlParse(ivy)) _ <- if (xml.label == "ivy-module") \/-(()) else -\/("Module definition not found") proj <- IvyXml.project(xml) } yield proj }) - } yield (source, proj) + } yield { + val proj = + if (dropInfoAttributes) + proj0.copy( + module = proj0.module.copy( + attributes = proj0.module.attributes.filter { + case (k, _) => !k.startsWith("info.") + } + ) + ) + else + proj0 + + (source, proj) + } } }