diff --git a/cli/src/main/scala-2.11/coursier/cli/Helper.scala b/cli/src/main/scala-2.11/coursier/cli/Helper.scala index 5bc66ff75..82fd0f60a 100644 --- a/cli/src/main/scala-2.11/coursier/cli/Helper.scala +++ b/cli/src/main/scala-2.11/coursier/cli/Helper.scala @@ -67,12 +67,9 @@ class Helper( val pool = Executors.newFixedThreadPool(parallel, Strategy.DefaultDaemonThreadFactory) val central = MavenRepository("https://repo1.maven.org/maven2/") - val ivy2Local = MavenRepository( - new File(sys.props("user.home") + "/.ivy2/local/").toURI.toString, - ivyLike = true - ) + val defaultRepositories = Seq( - ivy2Local, + Cache.ivy2Local, central ) @@ -81,7 +78,7 @@ class Helper( if (repo0 == "central") Right(central) else if (repo0 == "ivy2local") - Right(ivy2Local) + Right(Cache.ivy2Local) else if (repo0.startsWith("sonatype:")) Right( MavenRepository(s"https://oss.sonatype.org/content/repositories/${repo.drop("sonatype:".length)}") @@ -91,12 +88,8 @@ class Helper( if (repo.startsWith("ivy:")) { val url = repo.drop("ivy:".length) (url, IvyRepository(url)) - } else if (repo.startsWith("ivy-like:")) { - val url = repo.drop("ivy-like:".length) - (url, MavenRepository(url, ivyLike = true)) - } else { + } else (repo, MavenRepository(repo)) - } if (url.startsWith("http://") || url.startsWith("https://") || url.startsWith("file:/")) Right(r) diff --git a/core/shared/src/main/scala/coursier/maven/MavenRepository.scala b/core/shared/src/main/scala/coursier/maven/MavenRepository.scala index 821cd1866..3eddb4b7c 100644 --- a/core/shared/src/main/scala/coursier/maven/MavenRepository.scala +++ b/core/shared/src/main/scala/coursier/maven/MavenRepository.scala @@ -60,7 +60,6 @@ object MavenRepository { case class MavenRepository( root: String, - ivyLike: Boolean = false, changing: Option[Boolean] = None, /** Hackish hack for sbt plugins mainly - what this does really sucks */ sbtAttrStub: Boolean = false @@ -70,7 +69,7 @@ case class MavenRepository( import MavenRepository._ val root0 = if (root.endsWith("/")) root else root + "/" - val source = MavenSource(root0, ivyLike, changing, sbtAttrStub) + val source = MavenSource(root0, changing, sbtAttrStub) def projectArtifact( module: Module, @@ -78,27 +77,14 @@ case class MavenRepository( versioningValue: Option[String] ): Artifact = { - val path = ( - if (ivyLike) - ivyLikePath( - module.organization, - dirModuleName(module, sbtAttrStub), // maybe not what we should do here, don't know - module.name, - versioningValue getOrElse version, - "poms", - "", - "pom" - ) - else - module.organization.split('.').toSeq ++ Seq( - dirModuleName(module, sbtAttrStub), - version, - s"${module.name}-${versioningValue getOrElse version}.pom" - ) - ) .map(encodeURIComponent) + val path = module.organization.split('.').toSeq ++ Seq( + dirModuleName(module, sbtAttrStub), + version, + s"${module.name}-${versioningValue getOrElse version}.pom" + ) Artifact( - root0 + path.mkString("/"), + root0 + path.map(encodeURIComponent).mkString("/"), Map.empty, Map.empty, Attributes("pom", ""), @@ -108,57 +94,51 @@ case class MavenRepository( .withDefaultSignature } - def versionsArtifact(module: Module): Option[Artifact] = - if (ivyLike) None - else { - val path = ( - module.organization.split('.').toSeq ++ Seq( - dirModuleName(module, sbtAttrStub), - "maven-metadata.xml" - ) - ) .map(encodeURIComponent) + def versionsArtifact(module: Module): Option[Artifact] = { - val artifact = - Artifact( - root0 + path.mkString("/"), - Map.empty, - Map.empty, - Attributes("pom", ""), - changing = true - ) - .withDefaultChecksums - .withDefaultSignature + val path = module.organization.split('.').toSeq ++ Seq( + dirModuleName(module, sbtAttrStub), + "maven-metadata.xml" + ) - Some(artifact) - } + val artifact = + Artifact( + root0 + path.map(encodeURIComponent).mkString("/"), + Map.empty, + Map.empty, + Attributes("pom", ""), + changing = true + ) + .withDefaultChecksums + .withDefaultSignature + + Some(artifact) + } def snapshotVersioningArtifact( module: Module, version: String - ): Option[Artifact] = - if (ivyLike) None - else { - val path = ( - module.organization.split('.').toSeq ++ Seq( - dirModuleName(module, sbtAttrStub), - version, - "maven-metadata.xml" - ) - ) .map(encodeURIComponent) + ): Option[Artifact] = { - val artifact = - Artifact( - root0 + path.mkString("/"), - Map.empty, - Map.empty, - Attributes("pom", ""), - changing = true - ) - .withDefaultChecksums - .withDefaultSignature + val path = module.organization.split('.').toSeq ++ Seq( + dirModuleName(module, sbtAttrStub), + version, + "maven-metadata.xml" + ) - Some(artifact) - } + val artifact = + Artifact( + root0 + path.map(encodeURIComponent).mkString("/"), + Map.empty, + Map.empty, + Attributes("pom", ""), + changing = true + ) + .withDefaultChecksums + .withDefaultSignature + + Some(artifact) + } def versions[F[_]]( module: Module, diff --git a/core/shared/src/main/scala/coursier/maven/MavenSource.scala b/core/shared/src/main/scala/coursier/maven/MavenSource.scala index f07a4f5b3..583f28072 100644 --- a/core/shared/src/main/scala/coursier/maven/MavenSource.scala +++ b/core/shared/src/main/scala/coursier/maven/MavenSource.scala @@ -4,7 +4,6 @@ import coursier.core._ case class MavenSource( root: String, - ivyLike: Boolean, changing: Option[Boolean] = None, /** See doc on MavenRepository */ sbtAttrStub: Boolean @@ -46,34 +45,18 @@ case class MavenSource( ): Seq[Artifact] = { def artifactOf(module: Module, publication: Publication) = { - def ivyLikePath0(subDir: String, baseSuffix: String, ext: String) = - ivyLikePath( - module.organization, - MavenRepository.dirModuleName(module, sbtAttrStub), - module.name, - project.version, - subDir, - baseSuffix, - ext + + val versioning = project + .snapshotVersioning + .flatMap(versioning => + mavenVersioning(versioning, publication.classifier, publication.`type`) ) - val path = - if (ivyLike) - ivyLikePath0(publication.`type` + "s", "", publication.ext) - else { - val versioning = - project - .snapshotVersioning - .flatMap(versioning => - mavenVersioning(versioning, publication.classifier, publication.`type`) - ) - - module.organization.split('.').toSeq ++ Seq( - MavenRepository.dirModuleName(module, sbtAttrStub), - project.version, - s"${module.name}-${versioning getOrElse project.version}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}" - ) - } + val path = module.organization.split('.').toSeq ++ Seq( + MavenRepository.dirModuleName(module, sbtAttrStub), + project.version, + s"${module.name}-${versioning getOrElse project.version}${Some(publication.classifier).filter(_.nonEmpty).map("-" + _).mkString}.${publication.ext}" + ) val changing0 = changing.getOrElse(project.version.contains("-SNAPSHOT")) var artifact = diff --git a/web/src/main/scala/coursier/web/Backend.scala b/web/src/main/scala/coursier/web/Backend.scala index 69e6c3d96..64e3511b3 100644 --- a/web/src/main/scala/coursier/web/Backend.scala +++ b/web/src/main/scala/coursier/web/Backend.scala @@ -378,7 +378,7 @@ object App { )), <.td(Seq[Seq[TagMod]]( res.projectCache.get(dep.moduleVersion) match { - case Some((source: MavenSource, proj)) if !source.ivyLike => + case Some((source: MavenSource, proj)) => // FIXME Maven specific, generalize with source.artifacts val version0 = finalVersionOpt getOrElse dep.version val relPath =