mirror of https://github.com/sbt/sbt.git
Merge pull request #8238 from eed3si9n/wip/junit-java
[2.x] fix: Java-only tests
This commit is contained in:
commit
a8fc24dda6
|
|
@ -19,14 +19,32 @@ object Compiler:
|
||||||
val sh = Keys.scalaHome.value
|
val sh = Keys.scalaHome.value
|
||||||
val app = Keys.appConfiguration.value
|
val app = Keys.appConfiguration.value
|
||||||
val sv = Keys.scalaVersion.value
|
val sv = Keys.scalaVersion.value
|
||||||
|
val managed = Keys.managedScalaInstance.value
|
||||||
sh match
|
sh match
|
||||||
case Some(h) => scalaInstanceFromHome(h)
|
case Some(h) => scalaInstanceFromHome(h)
|
||||||
case _ =>
|
case _ =>
|
||||||
val scalaProvider = app.provider.scalaProvider
|
val scalaProvider = app.provider.scalaProvider
|
||||||
scalaInstanceFromUpdate
|
if !managed then emptyScalaInstance
|
||||||
|
else scalaInstanceFromUpdate
|
||||||
}
|
}
|
||||||
|
|
||||||
// use the same class loader as the Scala classes used by sbt
|
/**
|
||||||
|
* A dummy ScalaInstance for Java-only projects.
|
||||||
|
*/
|
||||||
|
def emptyScalaInstance: Def.Initialize[Task[ScalaInstance]] = Def.task {
|
||||||
|
makeScalaInstance(
|
||||||
|
"0.0.0",
|
||||||
|
Array.empty,
|
||||||
|
Seq.empty,
|
||||||
|
Seq.empty,
|
||||||
|
Keys.state.value,
|
||||||
|
Keys.scalaInstanceTopLoader.value,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the same class loader as the Scala classes used by sbt
|
||||||
|
// This will fail for "doc" task https://github.com/sbt/sbt/issues/7725
|
||||||
|
// because Scala 3 uses ScalaDocTool configuration to manage doc tools.
|
||||||
def optimizedScalaInstance(
|
def optimizedScalaInstance(
|
||||||
sv: String,
|
sv: String,
|
||||||
scalaProvider: ScalaProvider
|
scalaProvider: ScalaProvider
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.2" % Test
|
||||||
|
managedScalaInstance := false
|
||||||
|
|
@ -0,0 +1,9 @@
|
||||||
|
package com.example;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public final class ATest {
|
||||||
|
@Test
|
||||||
|
public void testSomething() {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
> test
|
||||||
|
> doc
|
||||||
|
|
@ -1 +1 @@
|
||||||
libraryDependencies += "com.novocode" % "junit-interface" % "0.8" % "test"
|
libraryDependencies += "com.github.sbt" % "junit-interface" % "0.13.2" % Test
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue