From 4512a940fb4aa3f6b99d3977383191fd8af0d9bb Mon Sep 17 00:00:00 2001 From: str4d <str4d@mail.i2p> Date: Sat, 9 Dec 2017 01:43:09 +0000 Subject: [PATCH] Gradle: Run ScalaTest tests in addition to the JUnit tests --- apps/routerconsole/build.gradle | 16 ++++++++++++++++ build.gradle | 2 ++ core/build.gradle | 14 ++++++++++++++ 3 files changed, 32 insertions(+) diff --git a/apps/routerconsole/build.gradle b/apps/routerconsole/build.gradle index 000fa5cc8b..77ae1e0eb1 100644 --- a/apps/routerconsole/build.gradle +++ b/apps/routerconsole/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'war' +apply plugin: 'scala' sourceSets { main { @@ -6,6 +7,11 @@ sourceSets { srcDir 'java/src' } } + test { + scala { + srcDir 'java/test/scalatest' + } + } } dependencies { @@ -16,7 +22,17 @@ dependencies { providedCompile project(':apps:systray') providedCompile project(':apps:jetty') providedCompile project(':apps:jrobin') + + testCompile "org.scala-lang:scala-library:2.12.4" + testCompile 'org.scalatest:scalatest_2.12:3.0.4' +} + +task scalaTest(dependsOn: ['testClasses'], type: JavaExec) { + main = 'org.scalatest.tools.Runner' + args = ['-R', 'build/classes/scala/test', '-o'] + classpath = sourceSets.test.runtimeClasspath } +test.dependsOn scalaTest jar { manifest { diff --git a/build.gradle b/build.gradle index af398cf737..6eab507d8a 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +apply plugin: 'idea' + // Exclude apps/ dir itself, but include its subdirs def javaProjects = subprojects - project(':apps') diff --git a/core/build.gradle b/core/build.gradle index ab2c6260c9..3214c9c6ef 100644 --- a/core/build.gradle +++ b/core/build.gradle @@ -1,4 +1,5 @@ apply plugin: 'java-library' +apply plugin: 'scala' archivesBaseName = 'i2p' @@ -30,13 +31,26 @@ sourceSets { include 'net/i2p/crypto/eddsa/math/baseDblPrecmp' include 'net/i2p/crypto/eddsa/math/basePrecmp' } + scala { + srcDir 'java/test/scalatest' + } } } dependencies { implementation 'gnu.getopt:java-getopt:1.0.13' implementation 'org.gnu.gettext:libintl:0.18.3' + + testCompile "org.scala-lang:scala-library:2.12.4" + testCompile 'org.scalatest:scalatest_2.12:3.0.4' +} + +task scalaTest(dependsOn: ['testClasses'], type: JavaExec) { + main = 'org.scalatest.tools.Runner' + args = ['-R', 'build/classes/scala/test', '-o'] + classpath = sourceSets.test.runtimeClasspath } +test.dependsOn scalaTest configurations { tests -- GitLab