From c1760fdc3c41b3d0971573a4776e68ec0261f4fc Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Wed, 30 Dec 2015 13:41:31 -0500 Subject: [PATCH 1/5] Move intransitive warning to update. Ref #2127 --- main/src/main/scala/sbt/Defaults.scala | 8 ++-- notes/0.13.10.markdown | 2 +- .../dependency-management/pom-type/build.sbt | 37 ++++++++++--------- .../dependency-management/pom-type/pending | 2 +- 4 files changed, 27 insertions(+), 22 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index ca3f7d988..35e0416b4 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1442,6 +1442,7 @@ object Classpaths { val logicalClock = LogicalClock(st.hashCode) val depDir = dependencyCacheDirectory.value val uc0 = updateConfiguration.value + val ms = publishMavenStyle.value // Normally, log would capture log messages at all levels. // Ivy logs are treated specially using sbt.UpdateConfiguration.logging. // This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug. @@ -1457,17 +1458,17 @@ object Classpaths { cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, uc, transform, skip = (skip in update).value, force = isRoot || forceUpdateByTime, depsUpdated = depsUpdated, uwConfig = uwConfig, logicalClock = logicalClock, depDir = Some(depDir), - ewo = ewo, log = s.log) + ewo = ewo, mavenStyle = ms, log = s.log) } @deprecated("Use cachedUpdate with the variant that takes unresolvedHandler instead.", "0.13.6") def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration, transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean, log: Logger): UpdateReport = cachedUpdate(cacheFile, label, module, config, transform, skip, force, depsUpdated, - UnresolvedWarningConfiguration(), LogicalClock.unknown, None, EvictionWarningOptions.empty, log) + UnresolvedWarningConfiguration(), LogicalClock.unknown, None, EvictionWarningOptions.empty, true, log) private[sbt] def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration, transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean, uwConfig: UnresolvedWarningConfiguration, logicalClock: LogicalClock, depDir: Option[File], - ewo: EvictionWarningOptions, log: Logger): UpdateReport = + ewo: EvictionWarningOptions, mavenStyle: Boolean, log: Logger): UpdateReport = { implicit val updateCache = updateIC type In = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil @@ -1486,6 +1487,7 @@ object Classpaths { val ew = EvictionWarning(module, ewo, result, log) ew.lines foreach { log.warn(_) } ew.infoAllTheThings foreach { log.info(_) } + val cw = CompatibilityWarning(module, mavenStyle, log) result } def uptodate(inChanged: Boolean, out: UpdateReport): Boolean = diff --git a/notes/0.13.10.markdown b/notes/0.13.10.markdown index 8e19fa621..7f1cf76b7 100644 --- a/notes/0.13.10.markdown +++ b/notes/0.13.10.markdown @@ -73,7 +73,7 @@ ### Improvements - Scala version used by the build is updated to 2.10.6. [#2311][2311] by [@eed3si9n][@eed3si9n] -- `makePom` warns when it sees intransitive dependencies, which do not translate to Maven. [#2127][2127] by [@jsuereth][@jsuereth] +- If `publishMavenStyle` is `true`, `update` task warns when it sees intransitive dependencies, which do not translate to Maven. [#2127][2127] by [@jsuereth][@jsuereth] - Adds `Def.settings`, which facilitates mixing settings with seq of settings. See below. - sbt Serialization is updated to 0.1.2. [2117][#2117] by [@dwijnand][@dwijnand] - Hides the stack trace on compilation error in build definition. [#2071][2071]/[#2091][2091] by [@Duhemm][@Duhemm] diff --git a/sbt/src/sbt-test/dependency-management/pom-type/build.sbt b/sbt/src/sbt-test/dependency-management/pom-type/build.sbt index 79af2c7af..b83e9fbbb 100644 --- a/sbt/src/sbt-test/dependency-management/pom-type/build.sbt +++ b/sbt/src/sbt-test/dependency-management/pom-type/build.sbt @@ -1,19 +1,22 @@ -scalaVersion := "2.10.2" - -libraryDependencies += "org.scala-sbt" %% "sbinary" % "0.4.1" withSources() withJavadoc() -libraryDependencies += "org.scala-sbt" % "io" % "0.13.8" intransitive() - lazy val checkPom = taskKey[Unit]("check pom to ensure no sections are generated") -checkPom := { - val pomFile = makePom.value - val pom = xml.XML.loadFile(pomFile) - val tpe = pom \\ "type" - if(tpe.nonEmpty) { - sys.error("Expected no sections, got: " + tpe + " in \n\n" + pom) - } - val dir = (streams in makePom).value.cacheDirectory / "out" - val lines = IO.readLines(dir) - val hasError = lines exists { line => line contains "Translating intransitive dependency "} - assert(hasError, s"Failed to detect intransitive dependencies, got: ${lines.mkString("\n")}") -} \ No newline at end of file +lazy val root = (project in file(".")). + settings( + scalaVersion := "2.10.6", + libraryDependencies += "org.scala-tools.sbinary" %% "sbinary" % "0.4.1" withSources() withJavadoc(), + libraryDependencies += "org.scala-sbt" % "io" % "0.13.8" intransitive(), + checkPom := { + val pomFile = makePom.value + val pom = xml.XML.loadFile(pomFile) + val tpe = pom \\ "type" + if(tpe.nonEmpty) { + sys.error("Expected no sections, got: " + tpe + " in \n\n" + pom) + } + val ur = update.value + val dir = (streams in update).value.cacheDirectory / "out" + val lines = IO.readLines(dir) + val hasError = lines exists { line => line contains "Found intransitive dependency "} + assert(hasError, s"Failed to detect intransitive dependencies, got: ${lines.mkString("\n")}") + }, + resolvers += Resolver.typesafeIvyRepo("releases") + ) diff --git a/sbt/src/sbt-test/dependency-management/pom-type/pending b/sbt/src/sbt-test/dependency-management/pom-type/pending index 0e9f0f7b6..8d831496e 100644 --- a/sbt/src/sbt-test/dependency-management/pom-type/pending +++ b/sbt/src/sbt-test/dependency-management/pom-type/pending @@ -1 +1 @@ -> checkPom \ No newline at end of file +> checkPom From 4b0fcf354d42c3d109b0fa16b1b35d4333e798d9 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Thu, 31 Dec 2015 00:25:21 -0500 Subject: [PATCH 2/5] Reproduce "configuration not public" on local test->test. #1827 --- .../chainresolver/build.sbt | 36 +++++++++++++++++++ .../dependency-management/chainresolver/test | 3 ++ 2 files changed, 39 insertions(+) create mode 100644 sbt/src/sbt-test/dependency-management/chainresolver/build.sbt create mode 100644 sbt/src/sbt-test/dependency-management/chainresolver/test diff --git a/sbt/src/sbt-test/dependency-management/chainresolver/build.sbt b/sbt/src/sbt-test/dependency-management/chainresolver/build.sbt new file mode 100644 index 000000000..f9454c341 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/chainresolver/build.sbt @@ -0,0 +1,36 @@ +lazy val check = taskKey[Unit]("Runs the check") + +def commonSettings: Seq[Def.Setting[_]] = + Seq( + ivyPaths := new IvyPaths( (baseDirectory in ThisBuild).value, Some((target in LocalRootProject).value / "ivy-cache")), + scalaVersion in ThisBuild := "2.11.7", + organization in ThisBuild := "com.example", + version in ThisBuild := "0.1.0-SNAPSHOT", + autoScalaLibrary := false, + crossPaths := false + ) + +lazy val realCommonsIoClient = project. + settings( + commonSettings, + name := "a", + libraryDependencies := Seq( + "commons-io" % "commons-io" % "1.3" + ), + fullResolvers := fullResolvers.value.filterNot(_.name == "inter-project") + ) + +lazy val fakeCommonsIo = project. + settings( + commonSettings, + organization := "commons-io", + name := "commons-io", + version := "1.3" + ) + +lazy val fakeCommonsIoClient = project. + dependsOn(fakeCommonsIo % "test->test"). + settings( + commonSettings, + name := "c" + ) diff --git a/sbt/src/sbt-test/dependency-management/chainresolver/test b/sbt/src/sbt-test/dependency-management/chainresolver/test new file mode 100644 index 000000000..c3786f997 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/chainresolver/test @@ -0,0 +1,3 @@ +> realCommonsIoClient/update + +> fakeCommonsIoClient/update From 4d58714aa73f7c1163fc63d3393ab2cd0c803864 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 22 Jan 2016 01:39:00 -0500 Subject: [PATCH 3/5] Adds CompatibilityWarningOptions. Fixes #2347 This addresses 0.13.10 regression, which currently warns users about Maven incompatibility on a private configuration. This adds a config class so the build user can control the level of the warning as well as the target configuration to be monitored. By default, we are only going to look at `Compile` and `Runtime`. --- main/src/main/scala/sbt/Defaults.scala | 11 +++++++---- main/src/main/scala/sbt/Keys.scala | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/main/src/main/scala/sbt/Defaults.scala b/main/src/main/scala/sbt/Defaults.scala index 35e0416b4..989cd72b3 100755 --- a/main/src/main/scala/sbt/Defaults.scala +++ b/main/src/main/scala/sbt/Defaults.scala @@ -1136,6 +1136,7 @@ object Classpaths { private[this] def baseGlobalDefaults = Defaults.globalDefaults(Seq( conflictWarning :== ConflictWarning.default("global"), + compatibilityWarningOptions :== CompatibilityWarningOptions.default, homepage :== None, startYear :== None, licenses :== Nil, @@ -1443,6 +1444,7 @@ object Classpaths { val depDir = dependencyCacheDirectory.value val uc0 = updateConfiguration.value val ms = publishMavenStyle.value + val cw = compatibilityWarningOptions.value // Normally, log would capture log messages at all levels. // Ivy logs are treated specially using sbt.UpdateConfiguration.logging. // This code bumps up the sbt.UpdateConfiguration.logging to Full when logLevel is Debug. @@ -1458,17 +1460,18 @@ object Classpaths { cachedUpdate(s.cacheDirectory / updateCacheName.value, show, ivyModule.value, uc, transform, skip = (skip in update).value, force = isRoot || forceUpdateByTime, depsUpdated = depsUpdated, uwConfig = uwConfig, logicalClock = logicalClock, depDir = Some(depDir), - ewo = ewo, mavenStyle = ms, log = s.log) + ewo = ewo, mavenStyle = ms, compatWarning = cw, log = s.log) } @deprecated("Use cachedUpdate with the variant that takes unresolvedHandler instead.", "0.13.6") def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration, transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean, log: Logger): UpdateReport = cachedUpdate(cacheFile, label, module, config, transform, skip, force, depsUpdated, - UnresolvedWarningConfiguration(), LogicalClock.unknown, None, EvictionWarningOptions.empty, true, log) + UnresolvedWarningConfiguration(), LogicalClock.unknown, None, EvictionWarningOptions.empty, true, CompatibilityWarningOptions.default, log) private[sbt] def cachedUpdate(cacheFile: File, label: String, module: IvySbt#Module, config: UpdateConfiguration, transform: UpdateReport => UpdateReport, skip: Boolean, force: Boolean, depsUpdated: Boolean, uwConfig: UnresolvedWarningConfiguration, logicalClock: LogicalClock, depDir: Option[File], - ewo: EvictionWarningOptions, mavenStyle: Boolean, log: Logger): UpdateReport = + ewo: EvictionWarningOptions, mavenStyle: Boolean, compatWarning: CompatibilityWarningOptions, + log: Logger): UpdateReport = { implicit val updateCache = updateIC type In = IvyConfiguration :+: ModuleSettings :+: UpdateConfiguration :+: HNil @@ -1487,7 +1490,7 @@ object Classpaths { val ew = EvictionWarning(module, ewo, result, log) ew.lines foreach { log.warn(_) } ew.infoAllTheThings foreach { log.info(_) } - val cw = CompatibilityWarning(module, mavenStyle, log) + val cw = CompatibilityWarning.run(compatWarning, module, mavenStyle, log) result } def uptodate(inChanged: Boolean, out: UpdateReport): Boolean = diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index 86ef49416..f647b7bca 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -376,6 +376,7 @@ object Keys { val forceUpdatePeriod = SettingKey[Option[FiniteDuration]]("force-update-period", "Duration after which to force a full update to occur", CSetting) val classifiersModule = TaskKey[GetClassifiersModule]("classifiers-module", rank = CTask) + val compatibilityWarningOptions = SettingKey[CompatibilityWarningOptions]("compatibility-warning", "Configures warnings around Maven incompatibility.", CSetting) val conflictWarning = SettingKey[ConflictWarning]("conflict-warning", "Configures warnings for conflicts in dependency management.", CSetting) val conflictManager = SettingKey[ConflictManager]("conflict-manager", "Selects the conflict manager to use for dependency management.", CSetting) val autoScalaLibrary = SettingKey[Boolean]("auto-scala-library", "Adds a dependency on scala-library if true.", ASetting) From e270d2bec1099b089c0f6390fdfa903b4ce27514 Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Fri, 26 Feb 2016 17:48:33 -0500 Subject: [PATCH 4/5] Adjust to code reorganization. --- main/src/main/scala/sbt/Keys.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/main/src/main/scala/sbt/Keys.scala b/main/src/main/scala/sbt/Keys.scala index f647b7bca..ae44ae8eb 100644 --- a/main/src/main/scala/sbt/Keys.scala +++ b/main/src/main/scala/sbt/Keys.scala @@ -46,6 +46,7 @@ import sbt.librarymanagement.{ UpdateReport } import sbt.internal.librarymanagement.{ + CompatibilityWarningOptions, DeliverConfiguration, GetClassifiersModule, IvyConfiguration, From f21c0c973f04142e07e2157a2cc49b4526a8116e Mon Sep 17 00:00:00 2001 From: Eugene Yokota Date: Sat, 27 Feb 2016 00:13:49 -0500 Subject: [PATCH 5/5] enabling dependency-management/pom-type --- sbt/src/sbt-test/dependency-management/pom-type/{pending => test} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename sbt/src/sbt-test/dependency-management/pom-type/{pending => test} (100%) diff --git a/sbt/src/sbt-test/dependency-management/pom-type/pending b/sbt/src/sbt-test/dependency-management/pom-type/test similarity index 100% rename from sbt/src/sbt-test/dependency-management/pom-type/pending rename to sbt/src/sbt-test/dependency-management/pom-type/test