From 9fb965e4ef22019dcbd0f7441576df354bb1feb8 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Mon, 30 Nov 2015 17:16:53 +0100 Subject: Fix dependency problems in the sbt build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Create the directory for the output file when building an OSGi bundle. Otherwise a publishing command would fail if dist/mkPack had not been run before. - Depend only on “packagedArtifact” in “mkPack”, not on “packageBin”. The latter is sbt’s standard packaging task but some of the required dependencies need to be packaged as OSGi bundles. --- build.sbt | 4 ++-- project/Osgi.scala | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sbt b/build.sbt index 143482a715..6dae804a2a 100644 --- a/build.sbt +++ b/build.sbt @@ -667,7 +667,7 @@ lazy val dist = (project in file("dist")) libraryDependencies ++= Seq(scalaContinuationsLibraryDep, scalaContinuationsPluginDep, scalaSwingDep, jlineDep), mkBin := mkBinImpl.value, mkQuick <<= Def.task {} dependsOn ((distDependencies.map(products in Runtime in _) :+ mkBin): _*), - mkPack <<= Def.task {} dependsOn (packageBin in Compile, mkBin), + mkPack <<= Def.task {} dependsOn (packagedArtifact in (Compile, packageBin), mkBin), target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id, packageBin in Compile := { val extraDeps = Set(scalaContinuationsLibraryDep, scalaContinuationsPluginDep, scalaSwingDep, scalaParserCombinatorsDep, scalaXmlDep) @@ -684,7 +684,7 @@ lazy val dist = (project in file("dist")) }, cleanFiles += (buildDirectory in ThisBuild).value / "quick", cleanFiles += (buildDirectory in ThisBuild).value / "pack", - packageBin in Compile <<= (packageBin in Compile).dependsOn(distDependencies.map(packageBin in Compile in _): _*) + packagedArtifact in (Compile, packageBin) <<= (packagedArtifact in (Compile, packageBin)).dependsOn(distDependencies.map(packagedArtifact in (Compile, packageBin) in _): _*) ) .dependsOn(distDependencies.map(p => p: ClasspathDep[ProjectReference]): _*) diff --git a/project/Osgi.scala b/project/Osgi.scala index 6c0ef74ef5..ed961d1c27 100644 --- a/project/Osgi.scala +++ b/project/Osgi.scala @@ -62,6 +62,7 @@ object Osgi { val jar = synchronized { builder.build } builder.getWarnings.foreach(s => log.warn(s"bnd: $s")) builder.getErrors.foreach(s => log.error(s"bnd: $s")) + IO.createDirectory(artifactPath.getParentFile) jar.write(artifactPath) artifactPath } -- cgit v1.2.3 From 780ac4124a5bf34a3297b563fa4ea09741aa2d7b Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Tue, 27 Oct 2015 14:07:52 +0100 Subject: Make all of partest work in the sbt build - Fix the scoping of files/lib/*.jar. These files were not on the classpath when running partest from sbt. - Pass the same standard Java options to partest as from the command line. This requires new versions of scala-partest and scala-partest-interface. - Fix the classpath scanning in jvm/innerClassEnclMethodJavaReflection. It only worked for JARs and relative directories but not for absolute directory paths (which are produced by sbt). --- build.sbt | 7 ++++--- test/files/jvm/innerClassEnclMethodJavaReflection.scala | 9 +++++---- versions.properties | 2 +- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/build.sbt b/build.sbt index 6dae804a2a..75762696ef 100644 --- a/build.sbt +++ b/build.sbt @@ -68,7 +68,7 @@ val scalaParserCombinatorsDep = withoutScalaLang("org.scala-lang.modules" %% "sc val scalaSwingDep = withoutScalaLang("org.scala-lang.modules" %% "scala-swing" % versionNumber("scala-swing")) val scalaXmlDep = withoutScalaLang("org.scala-lang.modules" %% "scala-xml" % versionNumber("scala-xml")) val partestDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest" % versionNumber("partest")) -val partestInterfaceDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest-interface" % "0.5.0") +val partestInterfaceDep = withoutScalaLang("org.scala-lang.modules" %% "scala-partest-interface" % "0.7.0") val junitDep = "junit" % "junit" % "4.11" val junitIntefaceDep = "com.novocode" % "junit-interface" % "0.11" % "test" val asmDep = "org.scala-lang.modules" % "scala-asm" % versionProps("scala-asm.version") @@ -553,8 +553,8 @@ lazy val test = project .settings( publishArtifact := false, libraryDependencies ++= Seq(asmDep, partestDep, scalaXmlDep, partestInterfaceDep, scalacheckDep), - unmanagedBase in Test := baseDirectory.value / "files" / "lib", - unmanagedJars in Test <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity), + unmanagedBase in IntegrationTest := baseDirectory.value / "files" / "lib", + unmanagedJars in IntegrationTest <+= (unmanagedBase) (j => Attributed.blank(j)) map(identity), // no main sources sources in Compile := Seq.empty, // test sources are compiled in partest run, not here @@ -563,6 +563,7 @@ lazy val test = project javaOptions in IntegrationTest += "-Xmx1G", testFrameworks += new TestFramework("scala.tools.partest.Framework"), testOptions in IntegrationTest += Tests.Setup( () => root.base.getAbsolutePath + "/pull-binary-libs.sh" ! ), + testOptions in IntegrationTest += Tests.Argument("-Dpartest.java_opts=-Xmx1024M -Xms64M -XX:MaxPermSize=128M"), definedTests in IntegrationTest += ( new sbt.TestDefinition( "partest", diff --git a/test/files/jvm/innerClassEnclMethodJavaReflection.scala b/test/files/jvm/innerClassEnclMethodJavaReflection.scala index a4d64d0b67..a60b5cac8e 100644 --- a/test/files/jvm/innerClassEnclMethodJavaReflection.scala +++ b/test/files/jvm/innerClassEnclMethodJavaReflection.scala @@ -25,12 +25,13 @@ object Test extends App { def testClasses(jarOrDirectory: String): Unit = { val classPath = AbstractFile.getDirectory(new java.io.File(jarOrDirectory)) + val basePath = classPath.path + "/" - def flatten(f: AbstractFile): Iterator[AbstractFile] = - if (f.isClassContainer) f.iterator.flatMap(flatten) - else Iterator(f) + def flatten(f: AbstractFile, s: String): Iterator[(AbstractFile, String)] = + if (f.isClassContainer) f.iterator.map(ch => (ch, (if(s.isEmpty) "" else s + "/") + ch.name)).flatMap((flatten _).tupled) + else Iterator((f, s)) - val classFullNames = flatten(classPath).filter(_.hasExtension("class")).map(_.path.replace("/", ".").replaceAll(".class$", "")) + val classFullNames = flatten(classPath, "").filter(_._1.hasExtension("class")).map(_._2.replace("/", ".").replaceAll(".class$", "")) // it seems that Class objects can only be GC'd together with their class loader // (http://stackoverflow.com/questions/2433261/when-and-how-are-classes-garbage-collected-in-java) diff --git a/versions.properties b/versions.properties index 2253921940..145881ab9b 100644 --- a/versions.properties +++ b/versions.properties @@ -36,7 +36,7 @@ jline.version=2.12.1 scala-asm.version=5.0.4-scala-3 # external modules, used internally (not shipped) -partest.version.number=1.0.9 +partest.version.number=1.0.11 scalacheck.version.number=1.11.6 # TODO: modularize the compiler -- cgit v1.2.3 From 2a57f828b2ab911ab70f20a9eb4db1f754a62e47 Mon Sep 17 00:00:00 2001 From: Stefan Zeiger Date: Thu, 3 Dec 2015 11:07:55 -0800 Subject: Create partest.properties from the sbt build This allows partest to be run from the command line on the artifacts produced by the sbt build. The actual location for partest.properties is hardcoded in the partest script as build/pack/partest.properties. This will have to be changed when we make sbt the default build tool. To test this now you can manually copy the generated file from build-sbt/quick/partest.properties to build/pack/partest.properties. --- build.sbt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index 75762696ef..6f82d78413 100644 --- a/build.sbt +++ b/build.sbt @@ -667,7 +667,13 @@ lazy val dist = (project in file("dist")) .settings( libraryDependencies ++= Seq(scalaContinuationsLibraryDep, scalaContinuationsPluginDep, scalaSwingDep, jlineDep), mkBin := mkBinImpl.value, - mkQuick <<= Def.task {} dependsOn ((distDependencies.map(products in Runtime in _) :+ mkBin): _*), + mkQuick <<= Def.task { + val cp = (fullClasspath in IntegrationTest in LocalProject("test")).value + val propsFile = (buildDirectory in ThisBuild).value / "quick" / "partest.properties" + val props = new java.util.Properties() + props.setProperty("partest.classpath", cp.map(_.data.getAbsolutePath).mkString(sys.props("path.separator"))) + IO.write(props, null, propsFile) + } dependsOn ((distDependencies.map(products in Runtime in _) :+ mkBin): _*), mkPack <<= Def.task {} dependsOn (packagedArtifact in (Compile, packageBin), mkBin), target := (baseDirectory in ThisBuild).value / "target" / thisProject.value.id, packageBin in Compile := { -- cgit v1.2.3