summaryrefslogtreecommitdiff
path: root/test/osgi/src/ScalaOsgiHelper.scala
blob: 7ba8883bb8cff7b4d23e43bcad10d373b28f86e0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package tools.test.osgi

import org.ops4j.pax.exam.CoreOptions._
import org.ops4j.pax.exam
import java.io.File

trait ScalaOsgiHelper {

  private def allBundleFiles = {
    def bundleLocation = new File(sys.props.getOrElse("scala.bundle.dir", "build/osgi"))
    bundleLocation.listFiles filter (_.getName endsWith ".jar")
  }

  private def filteredBundleFiles(names: String*): Array[exam.Option] =
     for(bundle <- allBundleFiles; if names exists (bundle.getName contains _))
     yield makeBundle(bundle)

  private def makeBundle(file: File): exam.Option =
      bundle(file.toURI.toASCIIString)

  def standardOptions: Array[exam.Option]  = {
    val bundles = (allBundleFiles map makeBundle)
    bundles ++ Array[exam.Option](junitBundles())
    // to change the local repo used (for some operations, but not all -- which is why I didn't bother):
    // systemProperty("org.ops4j.pax.url.mvn.localRepository").value(sys.props("maven.repo.local")))
  }

  def justReflectionOptions: Array[exam.Option]  = {
    val bundles = filteredBundleFiles("scala-library", "scala-reflect")
    bundles ++ Array[exam.Option](junitBundles())
  }

  def justCoreLibraryOptions: Array[exam.Option]  = {
    val bundles = filteredBundleFiles("scala-library")
    bundles ++ Array[exam.Option](junitBundles())
  }

}