From daa743ae92d811cd00130e2ddc7994526acc6566 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Sat, 8 Mar 2014 09:29:06 -0800 Subject: [PATCH] Fork in test to work around classpath issues Forking is needed to fix scalac classloader issues (see scala/scala-xml#20) that conflate the compiler's run-time classpath and the compilation classpath. The run-time (boot)classpath leaks into the compilation classpath, so that scalac see classes that are used to run it as classes used to compile against... Forking uses a minimal classpath, so this craziness is avoided. Alternatively, we could manage the scala instance as shown at the end of this file (commented) --- src/main/scala/ScalaModulePlugin.scala | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/main/scala/ScalaModulePlugin.scala b/src/main/scala/ScalaModulePlugin.scala index 827048e..3bb805e 100644 --- a/src/main/scala/ScalaModulePlugin.scala +++ b/src/main/scala/ScalaModulePlugin.scala @@ -25,6 +25,8 @@ object ScalaModulePlugin extends Plugin { // to allow compiling against snapshot versions of Scala resolvers += Resolver.sonatypeRepo("snapshots"), + // resolvers += "scala-release-temp" at "http://private-repo.typesafe.com/typesafe/scala-release-temp/" + // don't use for doc scope, scaladoc warnings are not to be reckoned with // TODO: turn on for nightlies, but don't enable for PR validation... "-Xfatal-warnings" scalacOptions in compile ++= Seq("-optimize", "-feature", "-deprecation", "-unchecked", "-Xlint"), @@ -44,6 +46,13 @@ object ScalaModulePlugin extends Plugin { (baseDirectory.value / s"${name.value}.properties") -> s"${name.value}.properties" }, + // needed to fix classloader issues (see scala/scala-xml#20) + // essentially, the problem is that the run-time bootclasspath leaks into the compilation classpath, + // so that scalac see classes used to run it, as classes used to compile against... + // forking uses a minimal classpath, so this craziness is avoided + // alternatively, manage the scala instance as shown at the end of this file (commented) + fork in Test := true, + publishArtifact in Test := false, // maven publishing @@ -103,3 +112,16 @@ object ScalaModulePlugin extends Plugin { // import com.typesafe.tools.mima.plugin.MimaKeys.previousArtifact // previousArtifact := Some(organization.value %% name.value % binaryReferenceVersion.value) } + + +// ALTERNATIVE to fork in test for fixing classpath issues noted above: +// manage the Scala instance ourselves to exclude the published scala-xml (scala-compiler depends on it) +// since this dependency hides the classes we're testing +// managedScalaInstance := false +// +// ivyConfigurations += Configurations.ScalaTool +// +// libraryDependencies ++= Seq( +// "org.scala-lang" % "scala-library" % scalaVersion.value, +// ("org.scala-lang" % "scala-compiler" % scalaVersion.value % "scala-tool").exclude("org.scala-lang.modules", s"scala-xml_${scalaBinaryVersion.value}") +// )