Search code examples
scalagradlescalatest

gradle scalatest stay at "Discovery starting."


I have project that uses gradle, scala, scalatest and the gradle-scalatest-plugin.

I have several tests and they are compiled. But when the run part of them is executed, the gradle is stuck on "Dicovery starting." infinitely.

So I used gradle --debug test to see what is happening. But besides the status information about memory of jvm and lock acquiring, there is no information why it is stuck.

build.gradle File:

buildscript {
  ext.scala_version = "2.12"
  ext.akka_version = "2.5"
  ext.monocle_version = "1.5.0"
  ext.circe_version = "0.8+"

  repositories {
    mavenCentral()
    jcenter()

    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }

  dependencies {
    classpath "com.diffplug.gradle:goomph:3.9.0"
  }
}

plugins {
  id "java"
  id "scala"
  id "com.github.maiflai.scalatest" version "0.19"
  id "com.athaydes.osgi-run" version "1.5.4"
  id "org.dm.bundle" version "0.10.0"

  // For interoperability with Other Company Eclipse P2 Repository
  id "com.diffplug.gradle.p2.asmaven" version "3.9.0"
}

group "project.scalatest"
version 0.1

repositories {
  mavenCentral()
  jcenter()
}

sourceSets {
  test {
    java {
      srcDirs = ['test/main/java']
    }

    scala {
      srcDirs = ['test/main/scala']
    }
  }
}

runOsgi {
  bundles += project
}

bundle {
  instruction '-dsannotations', '*'
}

test {
}

// Adding the Other Company Eclipse P2 project Core Repo as dependency
p2AsMaven {
  group 'project', {
    repo 'https://other-company.de/p2/'
    iu 'de.other-company.project.core'
  }
}

dependencies {
  //compile fileTree(dir: 'libs', include: ['*.jar', '*.java'])
  compile "org.osgi:org.osgi.core:6.0+"
  compile "org.osgi:org.osgi.service.log:1.3+"
  compile "org.osgi:org.osgi.service.component:1.3+"
  compile "org.osgi:org.osgi.service.component.annotations:1.3+"

  compile "project:de.other-company.project.core:+"
  // Include the program repository code as dependency
  //compile fileTree(dir: "../repository")

  compile "org.scala-lang:scala-library:$scala_version+"
  compile "com.typesafe.akka:akka-osgi_$scala_version:$akka_version+"

  compile "io.circe:circe-core_$scala_version:$circe_version"
  compile "io.circe:circe-generic_$scala_version:$circe_version"
  compile "io.circe:circe-parser_$scala_version:$circe_version"
  compile "io.circe:circe-optics_$scala_version:$circe_version"
  compile "com.github.julien-truffaut:monocle-core_$scala_version:$monocle_version"
  compile "com.github.julien-truffaut:monocle-macro_$scala_version:$monocle_version"

  compile "org.slf4j:slf4j-api:1.7.+"
  compile "org.slf4j:slf4j-simple:1.7.+"
  compile "org.slf4j:osgi-over-slf4j:1.7.+"

  testCompile "com.typesafe.akka:akka-testkit_$scala_version:$akka_version+"
  testCompile "org.scalatest:scalatest_$scala_version:3.2+"
  testCompile "org.scalactic:scalactic_$scala_version:3.2+"
  testCompile "org.scalacheck:scalacheck_$scala_version:1.13+"
  testCompile "org.mockito:mockito-core:2.+"
  testRuntime "org.pegdown:pegdown:1.4+"

  osgiRuntime "org.apache.felix:org.apache.felix.configadmin:1.8+"
  osgiRuntime "org.apache.felix:org.apache.felix.scr:2.0+"
  osgiRuntime "org.apache.felix:org.apache.felix.log:1.0+"
}

Solution

  • So I found the solution myself :)

    I did some crappy solution to find and use files in the test. After a research how to do it properly getClass.getResource("...") the problem went away.