diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/Ivy.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/Ivy.scala index 467e9d137..f6d449c4a 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/Ivy.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/Ivy.scala @@ -140,8 +140,8 @@ final class IvySbt(val configuration: IvyConfiguration) { /** * Cleans cached resolution cache. - * - * @param md - module descriptor of the original Ivy graph. + * + * @param md - module descriptor of the original Ivy graph. */ private[sbt] def cleanCachedResolutionCache(md: ModuleDescriptor, log: Logger): Unit = withIvy(log) { i => diff --git a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala index 8d43601fe..8fc1d4866 100644 --- a/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala +++ b/librarymanagement/src/main/scala/sbt/internal/librarymanagement/IvyActions.scala @@ -251,14 +251,14 @@ object IvyActions { updateClassifiers(ivySbt, config, UnresolvedWarningConfiguration(), LogicalClock.unknown, None, Vector(), log) /** - * Creates explicit artifacts for each classifier in `config.module`, and then attempts to resolve them directly. This - * is for Maven compatibility, where these artifacts are not "published" in the POM, so they don't end up in the Ivy - * that sbt generates for them either.
- * Artifacts can be obtained from calling toSeq on UpdateReport.
- * In addition, retrieves specific Ivy artifacts if they have one of the requested `config.configuration.types`. - * @param config important to set `config.configuration.types` to only allow artifact types that can correspond to - * "classified" artifacts (sources and javadocs). - */ + * Creates explicit artifacts for each classifier in `config.module`, and then attempts to resolve them directly. This + * is for Maven compatibility, where these artifacts are not "published" in the POM, so they don't end up in the Ivy + * that sbt generates for them either.
+ * Artifacts can be obtained from calling toSeq on UpdateReport.
+ * In addition, retrieves specific Ivy artifacts if they have one of the requested `config.configuration.types`. + * @param config important to set `config.configuration.types` to only allow artifact types that can correspond to + * "classified" artifacts (sources and javadocs). + */ private[sbt] def updateClassifiers(ivySbt: IvySbt, config: GetClassifiersConfiguration, uwconfig: UnresolvedWarningConfiguration, logicalClock: LogicalClock, depDir: Option[File], artifacts: Vector[(String, ModuleID, Artifact, File)], @@ -283,9 +283,10 @@ object IvyActions { ((sourceArtifactTypes.toIterable map (_ -> Artifact.SourceClassifier)) :: (docArtifactTypes.toIterable map (_ -> Artifact.DocClassifier)) :: Nil).flatten.toMap r.substitute { (conf, mid, artFileSeq) => - artFileSeq map { case (art, f) => - // Deduce the classifier from the type if no classifier is present already - art.copy(classifier = art.classifier orElse typeClassifierMap.get(art.`type`)) -> f + artFileSeq map { + case (art, f) => + // Deduce the classifier from the type if no classifier is present already + art.copy(classifier = art.classifier orElse typeClassifierMap.get(art.`type`)) -> f } } case Left(w) => @@ -318,18 +319,18 @@ object IvyActions { } /** - * Explicitly set an "include all" rule (the default) because otherwise, if we declare ANY explicitArtifacts, - * [[org.apache.ivy.core.resolve.IvyNode#getArtifacts]] (in Ivy 2.3.0-rc1) will not merge in the descriptor's - * artifacts and will only keep the explicitArtifacts. - *
- * Look for the comment saying {{{ - * // and now we filter according to include rules - * }}} - * in `IvyNode`, which iterates on `includes`, which will ordinarily be empty because higher up, in {{{ - * addAllIfNotNull(includes, usage.getDependencyIncludesSet(rootModuleConf)); - * }}} - * `usage.getDependencyIncludesSet` returns null if there are no (explicit) include rules. - */ + * Explicitly set an "include all" rule (the default) because otherwise, if we declare ANY explicitArtifacts, + * [[org.apache.ivy.core.resolve.IvyNode#getArtifacts]] (in Ivy 2.3.0-rc1) will not merge in the descriptor's + * artifacts and will only keep the explicitArtifacts. + *
+ * Look for the comment saying {{{ + * // and now we filter according to include rules + * }}} + * in `IvyNode`, which iterates on `includes`, which will ordinarily be empty because higher up, in {{{ + * addAllIfNotNull(includes, usage.getDependencyIncludesSet(rootModuleConf)); + * }}} + * `usage.getDependencyIncludesSet` returns null if there are no (explicit) include rules. + */ private def intransitiveModuleWithExplicitArts(module: ModuleID, arts: Seq[Artifact]): ModuleID = module.copy(isTransitive = false, explicitArtifacts = arts, inclusions = InclExclRule.everything :: Nil) diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/Artifact.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/Artifact.scala index b5b209bcb..8bf97bc05 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/Artifact.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/Artifact.scala @@ -30,23 +30,23 @@ object Artifact { def javadoc(name: String) = classified(name, DocClassifier) def pom(name: String) = Artifact(name, PomType, PomType, None, Pom :: Nil, None) - // Possible ivy artifact types such that sbt will treat those artifacts at sources / docs - val DefaultSourceTypes = Set("src", "source", "sources") - val DefaultDocTypes = Set("doc", "docs", "javadoc", "javadocs") + // Possible ivy artifact types such that sbt will treat those artifacts at sources / docs + val DefaultSourceTypes = Set("src", "source", "sources") + val DefaultDocTypes = Set("doc", "docs", "javadoc", "javadocs") - val DocClassifier = "javadoc" - val SourceClassifier = "sources" + val DocClassifier = "javadoc" + val SourceClassifier = "sources" - val TestsClassifier = "tests" - // Artifact types used when: - // * artifacts are explicitly created for Maven dependency resolution (see updateClassifiers) - // * declaring artifacts as part of creating Ivy files. - val DocType = "doc" - val SourceType = "src" - val PomType = "pom" + val TestsClassifier = "tests" + // Artifact types used when: + // * artifacts are explicitly created for Maven dependency resolution (see updateClassifiers) + // * declaring artifacts as part of creating Ivy files. + val DocType = "doc" + val SourceType = "src" + val PomType = "pom" - assert (DefaultDocTypes contains DocType) - assert (DefaultSourceTypes contains SourceType) + assert(DefaultDocTypes contains DocType) + assert(DefaultSourceTypes contains SourceType) def extract(url: URL, default: String): String = extract(url.toString, default) def extract(name: String, default: String): String = @@ -73,22 +73,24 @@ object Artifact { base + "-" + module.revision + classifierStr + "." + artifact.extension } - val classifierTypeMap = Map(SourceClassifier -> SourceType, DocClassifier -> DocType) - @deprecated("Configuration should not be decided from the classifier.", "1.0") - def classifierConf(classifier: String): Configuration = - if(classifier.startsWith(TestsClassifier)) - Test - else - Optional - def classifierType(classifier: String): String = classifierTypeMap.getOrElse(classifier.stripPrefix(TestsClassifier + "-"), DefaultType) + val classifierTypeMap = Map(SourceClassifier -> SourceType, DocClassifier -> DocType) + @deprecated("Configuration should not be decided from the classifier.", "1.0") + def classifierConf(classifier: String): Configuration = + if (classifier.startsWith(TestsClassifier)) + Test + else + Optional + def classifierType(classifier: String): String = classifierTypeMap.getOrElse(classifier.stripPrefix(TestsClassifier + "-"), DefaultType) - /** Create a classified explicit artifact, to be used when trying to resolve sources|javadocs from Maven. This is - * necessary because those artifacts are not published in the Ivy generated from the Pom of the module in question. - * The artifact is created under the default configuration. */ - def classified(name: String, classifier: String): Artifact = - Artifact(name, classifierType(classifier), DefaultExtension, Some(classifier), Nil, None) + /** + * Create a classified explicit artifact, to be used when trying to resolve sources|javadocs from Maven. This is + * necessary because those artifacts are not published in the Ivy generated from the Pom of the module in question. + * The artifact is created under the default configuration. + */ + def classified(name: String, classifier: String): Artifact = + Artifact(name, classifierType(classifier), DefaultExtension, Some(classifier), Nil, None) - private val optStringPickler = implicitly[Pickler[Option[String]]] + private val optStringPickler = implicitly[Pickler[Option[String]]] private val optStringUnpickler = implicitly[Unpickler[Option[String]]] private val vectorConfigurationPickler = implicitly[Pickler[Vector[Configuration]]] private val vectorConfigurationUnpickler = implicitly[Unpickler[Vector[Configuration]]] diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala index ed99f6bd1..964fe7447 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/IvyInterface.scala @@ -9,7 +9,7 @@ import scala.xml.NodeSeq import org.apache.ivy.plugins.resolver.{ DependencyResolver, IBiblioResolver } import org.apache.ivy.util.url.CredentialsStore import org.apache.ivy.core.module.descriptor -import org.apache.ivy.util.filter.{Filter => IvyFilter} +import org.apache.ivy.util.filter.{ Filter => IvyFilter } import sbt.serialization._ /** Additional information about a project module */ @@ -27,12 +27,14 @@ final case class ScmInfo(browseUrl: URL, connection: String, devConnection: Opti final case class Developer(id: String, name: String, email: String, url: URL) -/** Rule to either: - * - * Which one depends on the parameter name which it is passed to, but the filter has the same fields in both cases. */ +/** + * Rule to either: + * + * Which one depends on the parameter name which it is passed to, but the filter has the same fields in both cases. + */ final case class InclExclRule(organization: String = "*", name: String = "*", artifact: String = "*", configurations: Seq[String] = Nil) object InclExclRule { def everything = InclExclRule("*", "*", "*", Nil) @@ -40,23 +42,25 @@ object InclExclRule { implicit val pickler: Pickler[InclExclRule] with Unpickler[InclExclRule] = PicklerUnpickler.generate[InclExclRule] } -/** Work around the inadequacy of Ivy's ArtifactTypeFilter (that it cannot reverse a filter) - * @param types represents the artifact types that we should try to resolve for (as in the allowed values of - * `artifact[type]` from a dependency `` section). One can use this to filter - * source / doc artifacts. - * @param inverted whether to invert the types filter (i.e. allow only types NOT in the set) */ +/** + * Work around the inadequacy of Ivy's ArtifactTypeFilter (that it cannot reverse a filter) + * @param types represents the artifact types that we should try to resolve for (as in the allowed values of + * `artifact[type]` from a dependency `` section). One can use this to filter + * source / doc artifacts. + * @param inverted whether to invert the types filter (i.e. allow only types NOT in the set) + */ case class ArtifactTypeFilter(types: Set[String], inverted: Boolean) { def invert = copy(inverted = !inverted) def apply(a: descriptor.Artifact): Boolean = (types contains a.getType) ^ inverted } object ArtifactTypeFilter { - def allow(types: Set[String]) = ArtifactTypeFilter(types, false) - def forbid(types: Set[String]) = ArtifactTypeFilter(types, true) + def allow(types: Set[String]) = ArtifactTypeFilter(types, false) + def forbid(types: Set[String]) = ArtifactTypeFilter(types, true) - implicit def toIvyFilter(f: ArtifactTypeFilter): IvyFilter = new IvyFilter { - override def accept(o: Object): Boolean = Option(o) exists { case a: descriptor.Artifact => f.apply(a) } - } + implicit def toIvyFilter(f: ArtifactTypeFilter): IvyFilter = new IvyFilter { + override def accept(o: Object): Boolean = Option(o) exists { case a: descriptor.Artifact => f.apply(a) } + } } final case class ModuleConfiguration(organization: String, name: String, revision: String, resolver: Resolver) diff --git a/librarymanagement/src/main/scala/sbt/librarymanagement/IvyScala.scala b/librarymanagement/src/main/scala/sbt/librarymanagement/IvyScala.scala index a9b5f54e4..d2df9b4cf 100644 --- a/librarymanagement/src/main/scala/sbt/librarymanagement/IvyScala.scala +++ b/librarymanagement/src/main/scala/sbt/librarymanagement/IvyScala.scala @@ -130,10 +130,10 @@ private[sbt] object IvyScala { * the given configurations. */ private[sbt] def includeRule(organization: String, name: String, configurationNames: Iterable[String], includeTypePattern: String): IncludeRule = - { - val artifact = new ArtifactId(ModuleId.newInstance(organization, name), "*", includeTypePattern, "*") - val rule = new DefaultIncludeRule(artifact, ExactPatternMatcher.INSTANCE, emptyMap[AnyRef, AnyRef]) - configurationNames.foreach(rule.addConfiguration) - rule - } + { + val artifact = new ArtifactId(ModuleId.newInstance(organization, name), "*", includeTypePattern, "*") + val rule = new DefaultIncludeRule(artifact, ExactPatternMatcher.INSTANCE, emptyMap[AnyRef, AnyRef]) + configurationNames.foreach(rule.addConfiguration) + rule + } }