From 6c5d398608c2d884796a75cbb7d24eb538ba93ce Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Fri, 10 Feb 2012 13:17:25 +0400 Subject: [PATCH 1/3] Validate resolvers when making ivy configuration and publishing. --- main/Defaults.scala | 12 ++++++++++-- main/Keys.scala | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/main/Defaults.scala b/main/Defaults.scala index 96598e2a5..023ecc6b0 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -769,7 +769,10 @@ object Classpaths }, deliverLocalConfiguration <<= (crossTarget, ivyLoggingLevel) map { (outDir, level) => deliverConfig( outDir, logging = level ) }, deliverConfiguration <<= deliverLocalConfiguration, - publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel) map { (arts, publishTo, mavenStyle, ivyFile, checks, level) => + validateResolvers <<= (fullResolvers, otherResolvers, streams) map { case (full, other, s) => + warnResolversConflict(full ++: other, s.log) + }, + publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel, validateResolvers) map { (arts, publishTo, mavenStyle, ivyFile, checks, level, v) => publishConfig(arts, if(mavenStyle) None else Some(ivyFile), resolverName = getPublishTo(publishTo).name, checksums = checks, logging = level) }, publishLocalConfiguration <<= (packagedArtifacts, deliverLocal, checksums in publishLocal, ivyLoggingLevel) map { @@ -801,6 +804,11 @@ object Classpaths CrossVersion(scalaVersion, binVersion)(base).copy(crossVersion = CrossVersion.Disabled) } ) + def warnResolversConflict(ress: Seq[Resolver], log: Logger) { + for ((name, r) <- ress groupBy (_.name) if r.size > 1) { + log.warn("Multiple resolvers configured with the name '" + name + "'. Rename to avoid conflict.") + } + } def pluginProjectID: Initialize[ModuleID] = (sbtVersion in update, sbtBinaryVersion in update, scalaVersion in update, scalaBinaryVersion in update, projectID, sbtPlugin) { (sbtV, sbtBV, scalaV, scalaBV, pid, isPlugin) => if(isPlugin) @@ -963,7 +971,7 @@ object Classpaths def unmanagedDependencies: Initialize[Task[Classpath]] = (thisProjectRef, configuration, settings, buildDependencies) flatMap unmanagedDependencies0 def mkIvyConfiguration: Initialize[Task[IvyConfiguration]] = - (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums in update, appConfiguration, streams) map { (rs, paths, other, moduleConfs, off, check, app, s) => + (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums in update, appConfiguration, streams, validateResolvers) map { (rs, paths, other, moduleConfs, off, check, app, s, _) => new InlineIvyConfiguration(paths, rs, other, moduleConfs, off, Some(lock(app)), check, s.log) } diff --git a/main/Keys.scala b/main/Keys.scala index 3881f99e2..1b3bfac1a 100644 --- a/main/Keys.scala +++ b/main/Keys.scala @@ -271,6 +271,7 @@ object Keys val projectResolver = TaskKey[Resolver]("project-resolver", "Resolver that handles inter-project dependencies.") val fullResolvers = TaskKey[Seq[Resolver]]("full-resolvers", "Combines the project resolver, default resolvers, and user-defined resolvers.") val otherResolvers = SettingKey[Seq[Resolver]]("other-resolvers", "Resolvers not included in the main resolver chain, such as those in module configurations.") + val validateResolvers = TaskKey[Unit]("validate-resolvers", "Validates that the configured resolvers don't conflict.") val moduleConfigurations = SettingKey[Seq[ModuleConfiguration]]("module-configurations", "Defines module configurations, which override resolvers on a per-module basis.") val retrievePattern = SettingKey[String]("retrieve-pattern", "Pattern used to retrieve managed dependencies to the current build.") val retrieveConfiguration = SettingKey[Option[RetrieveConfiguration]]("retrieve-configuration", "Configures retrieving dependencies to the current build.") From c6ea7ccd673ca5e213f08f32bf0333e50c50bddf Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Fri, 10 Feb 2012 13:26:06 +0400 Subject: [PATCH 2/3] Remove unneeded validation. It would be really nice if sbt allowed to show all paths in a DAG between 2 given vertices. --- main/Defaults.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/Defaults.scala b/main/Defaults.scala index 023ecc6b0..72c0657cd 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -772,7 +772,7 @@ object Classpaths validateResolvers <<= (fullResolvers, otherResolvers, streams) map { case (full, other, s) => warnResolversConflict(full ++: other, s.log) }, - publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel, validateResolvers) map { (arts, publishTo, mavenStyle, ivyFile, checks, level, v) => + publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel) map { (arts, publishTo, mavenStyle, ivyFile, checks, level) => publishConfig(arts, if(mavenStyle) None else Some(ivyFile), resolverName = getPublishTo(publishTo).name, checksums = checks, logging = level) }, publishLocalConfiguration <<= (packagedArtifacts, deliverLocal, checksums in publishLocal, ivyLoggingLevel) map { From 7cf1e3fe3c88b85d87a061857661f62afd177ec9 Mon Sep 17 00:00:00 2001 From: Eugene Vigdorchik Date: Sat, 11 Feb 2012 12:32:40 +0400 Subject: [PATCH 3/3] Remove artificial TaskKey. --- main/Defaults.scala | 6 ++---- main/Keys.scala | 1 - 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/main/Defaults.scala b/main/Defaults.scala index 72c0657cd..7011ba2e9 100644 --- a/main/Defaults.scala +++ b/main/Defaults.scala @@ -769,9 +769,6 @@ object Classpaths }, deliverLocalConfiguration <<= (crossTarget, ivyLoggingLevel) map { (outDir, level) => deliverConfig( outDir, logging = level ) }, deliverConfiguration <<= deliverLocalConfiguration, - validateResolvers <<= (fullResolvers, otherResolvers, streams) map { case (full, other, s) => - warnResolversConflict(full ++: other, s.log) - }, publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel) map { (arts, publishTo, mavenStyle, ivyFile, checks, level) => publishConfig(arts, if(mavenStyle) None else Some(ivyFile), resolverName = getPublishTo(publishTo).name, checksums = checks, logging = level) }, @@ -971,7 +968,8 @@ object Classpaths def unmanagedDependencies: Initialize[Task[Classpath]] = (thisProjectRef, configuration, settings, buildDependencies) flatMap unmanagedDependencies0 def mkIvyConfiguration: Initialize[Task[IvyConfiguration]] = - (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums in update, appConfiguration, streams, validateResolvers) map { (rs, paths, other, moduleConfs, off, check, app, s, _) => + (fullResolvers, ivyPaths, otherResolvers, moduleConfigurations, offline, checksums in update, appConfiguration, streams) map { (rs, paths, other, moduleConfs, off, check, app, s) => + warnResolversConflict(rs ++: other, s.log) new InlineIvyConfiguration(paths, rs, other, moduleConfs, off, Some(lock(app)), check, s.log) } diff --git a/main/Keys.scala b/main/Keys.scala index 1b3bfac1a..3881f99e2 100644 --- a/main/Keys.scala +++ b/main/Keys.scala @@ -271,7 +271,6 @@ object Keys val projectResolver = TaskKey[Resolver]("project-resolver", "Resolver that handles inter-project dependencies.") val fullResolvers = TaskKey[Seq[Resolver]]("full-resolvers", "Combines the project resolver, default resolvers, and user-defined resolvers.") val otherResolvers = SettingKey[Seq[Resolver]]("other-resolvers", "Resolvers not included in the main resolver chain, such as those in module configurations.") - val validateResolvers = TaskKey[Unit]("validate-resolvers", "Validates that the configured resolvers don't conflict.") val moduleConfigurations = SettingKey[Seq[ModuleConfiguration]]("module-configurations", "Defines module configurations, which override resolvers on a per-module basis.") val retrievePattern = SettingKey[String]("retrieve-pattern", "Pattern used to retrieve managed dependencies to the current build.") val retrieveConfiguration = SettingKey[Option[RetrieveConfiguration]]("retrieve-configuration", "Configures retrieving dependencies to the current build.")