From eaa78748740e02d706662b6ec014e57f6470c3db Mon Sep 17 00:00:00 2001 From: Alexandre Archambault Date: Wed, 30 Dec 2015 01:34:35 +0100 Subject: [PATCH] Move Maven specific method closer to its usage --- .../main/scala/coursier/core/Repository.scala | 23 ---------------- .../scala/coursier/maven/MavenSource.scala | 26 +++++++++++++++++++ 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/core/shared/src/main/scala/coursier/core/Repository.scala b/core/shared/src/main/scala/coursier/core/Repository.scala index 2d0f96dcf..297f95f9a 100644 --- a/core/shared/src/main/scala/coursier/core/Repository.scala +++ b/core/shared/src/main/scala/coursier/core/Repository.scala @@ -38,29 +38,6 @@ object Repository { ) .withDefaultChecksums )) - def withJavadocSources: Artifact = { - val base = underlying.url.stripSuffix(".jar") - underlying.copy(extra = underlying.extra ++ Seq( - "sources" -> Artifact( - base + "-sources.jar", - Map.empty, - Map.empty, - Attributes("jar", "src"), // Are these the right attributes? - changing = underlying.changing - ) - .withDefaultChecksums - .withDefaultSignature, - "javadoc" -> Artifact( - base + "-javadoc.jar", - Map.empty, - Map.empty, - Attributes("jar", "javadoc"), // Same comment as above - changing = underlying.changing - ) - .withDefaultChecksums - .withDefaultSignature - )) - } } } diff --git a/core/shared/src/main/scala/coursier/maven/MavenSource.scala b/core/shared/src/main/scala/coursier/maven/MavenSource.scala index 26973836d..06921e82d 100644 --- a/core/shared/src/main/scala/coursier/maven/MavenSource.scala +++ b/core/shared/src/main/scala/coursier/maven/MavenSource.scala @@ -11,6 +11,32 @@ case class MavenSource( import Repository._ import MavenRepository._ + private implicit class DocSourcesArtifactExtensions(val underlying: Artifact) { + def withJavadocSources: Artifact = { + val base = underlying.url.stripSuffix(".jar") + underlying.copy(extra = underlying.extra ++ Seq( + "sources" -> Artifact( + base + "-sources.jar", + Map.empty, + Map.empty, + Attributes("jar", "src"), // Are these the right attributes? + changing = underlying.changing + ) + .withDefaultChecksums + .withDefaultSignature, + "javadoc" -> Artifact( + base + "-javadoc.jar", + Map.empty, + Map.empty, + Attributes("jar", "javadoc"), // Same comment as above + changing = underlying.changing + ) + .withDefaultChecksums + .withDefaultSignature + )) + } + } + def artifacts( dependency: Dependency, project: Project