From 7abe7a95a42cccc9567eb68d4e43589db4f5c546 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Thu, 20 Aug 2015 23:11:15 +0100 Subject: [PATCH] Add updateClassifiers SNAPSHOT srcs test. Currently fails with: [info] java.lang.AssertionError: assertion failed: Bippy should contain def release = 2, contents: [info] package t [info] [info] object Bippy { [info] def release = 1 [info] } Also fails with MavenResolverPlugin.. :( --- .../bippy/Bippy.scala | 5 +++ .../build.sbt | 38 +++++++++++++++++++ .../changes/Bippy2.scala | 5 +++ .../update-classifiers-snapshot-srcs/test | 12 ++++++ 4 files changed, 60 insertions(+) create mode 100644 sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/bippy/Bippy.scala create mode 100644 sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/build.sbt create mode 100644 sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/changes/Bippy2.scala create mode 100644 sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/test diff --git a/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/bippy/Bippy.scala b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/bippy/Bippy.scala new file mode 100644 index 000000000..4551f8de6 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/bippy/Bippy.scala @@ -0,0 +1,5 @@ +package t + +object Bippy { + def release = 1 +} diff --git a/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/build.sbt b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/build.sbt new file mode 100644 index 000000000..06932eb7e --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/build.sbt @@ -0,0 +1,38 @@ +def ivyHome = Def.setting((target in LocalRootProject).value / "ivy") +def localRepo = Def.setting((target in LocalRootProject).value / "local-repo") + +val commonSettings = Seq[Def.Setting[_]]( + organization := "org.example", + version := "1.0-SNAPSHOT", + scalaVersion := "2.11.7", + ivyPaths := new IvyPaths((baseDirectory in ThisBuild).value, Some(ivyHome.value)), + fullResolvers := fullResolvers.value.filterNot(_ == projectResolver.value) +) + +lazy val bippy = project settings ( + commonSettings, + resolvers += Resolver.file("ivy-local", file(sys.props("user.home")) / ".ivy2" / "local")(Resolver.ivyStylePatterns), + publishTo := Some(Resolver.file("local-repo", localRepo.value)) +) + +lazy val myapp = project settings ( + commonSettings, + resolvers += new MavenRepository("local-repo", localRepo.value.toURL.toString) withLocalIfFile false, + libraryDependencies += "org.example" %% "bippy" % "1.0-SNAPSHOT" +) + +InputKey[Unit]("check") := { + import sbt.complete.DefaultParsers._ + val n = (token(Space) ~> token(Digit)).map(_.asDigit).parsed + + val jarname = "bippy_2.11-1.0-SNAPSHOT-sources.jar" + val file1 = ivyHome.value / "cache" / "org.example" / "bippy_2.11" / "srcs" / jarname + val file2 = ivyHome.value / "maven-cache" / "org" / "example" / "bippy_2.11" / "1.0-SNAPSHOT" / jarname + val file = if (file1.exists()) file1 else if (file2.exists) file2 else sys error s"$jarname MIA" + val jar = new java.util.jar.JarFile(file) + val s = IO readStream jar.getInputStream(jar.getJarEntry("Bippy.scala")) + + val expected = s"def release = $n" + assert(s contains expected, s"""Bippy should contain $expected, contents:\n$s""") + () +} diff --git a/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/changes/Bippy2.scala b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/changes/Bippy2.scala new file mode 100644 index 000000000..61b347466 --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/changes/Bippy2.scala @@ -0,0 +1,5 @@ +package t + +object Bippy { + def release = 2 +} diff --git a/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/test b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/test new file mode 100644 index 000000000..a4142446b --- /dev/null +++ b/sbt/src/sbt-test/dependency-management/update-classifiers-snapshot-srcs/test @@ -0,0 +1,12 @@ +> bippy/publish +> myapp/updateClassifiers + +# Sanity check before real test +> check 1 + +$ copy-file changes/Bippy2.scala bippy/Bippy.scala + +> bippy/publish +> myapp/updateClassifiers + +> check 2