diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 69a91e7..5e3addf 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,8 +1,8 @@ -import org.jetbrains.kotlin.gradle.tasks.KotlinCompile - plugins { - kotlin("jvm") version "1.4.10" + // Apply the scala Plugin to add support for Scala. + scala + // Apply the java-library plugin for API and implementation separation. `java-library` } @@ -10,15 +10,27 @@ group = "tribufu" version = "0.0.1" repositories { + // Use Maven Central for resolving dependencies. mavenCentral() } dependencies { - testImplementation(kotlin("test-junit")) -} + // Use Scala 2.13 in our library project + implementation("org.scala-lang:scala-library:2.13.3") -tasks.test { - useJUnit() + // This dependency is used internally, and not exposed to consumers on their own compile classpath. + implementation("com.google.guava:guava:30.0-jre") + + // Use Scalatest for testing our library + testImplementation("junit:junit:4.13.1") + testImplementation("org.scalatest:scalatest_2.13:3.2.3") + testImplementation("org.scalatestplus:junit-4-13_2.13:3.2.2.0") + + // Need scala-xml at test runtime + testRuntimeOnly("org.scala-lang.modules:scala-xml_2.13:1.2.0") + + // This dependency is exported to consumers, that is to say found on their compile classpath. + api("org.apache.commons:commons-math3:3.6.1") } tasks.jar { @@ -26,7 +38,3 @@ tasks.jar { attributes(mapOf("Implementation-Title" to project.name, "Implementation-Version" to project.version)) } } - -tasks.withType() { - kotlinOptions.jvmTarget = "1.8" -} diff --git a/lib/src/main/kotlin/tribufu/TribuFu.kt b/lib/src/main/scala/tribufu/Library.scala similarity index 66% rename from lib/src/main/kotlin/tribufu/TribuFu.kt rename to lib/src/main/scala/tribufu/Library.scala index 1f8fc36..330edb3 100644 --- a/lib/src/main/kotlin/tribufu/TribuFu.kt +++ b/lib/src/main/scala/tribufu/Library.scala @@ -2,17 +2,17 @@ package tribufu -class TribuFu { +class Library { + init() + + private def init(){ + // Used to load the 'TribuFu' library on application startup. + //System.loadLibrary("TribuFu") + } + /** * A native method that is implemented by the 'TribuFu' native library, which is packaged with * this library. */ - // external fun Hello(): Int - - companion object { - // Used to load the 'TribuFu' library on application startup. - init { - //System.loadLibrary("TribuFu") - } - } + //@native def Hello(): Int } diff --git a/lib/src/test/kotlin/.gitkeep b/lib/src/test/kotlin/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/src/test/scala/tribufu/LibrarySuite.scala b/lib/src/test/scala/tribufu/LibrarySuite.scala new file mode 100644 index 0000000..0754d10 --- /dev/null +++ b/lib/src/test/scala/tribufu/LibrarySuite.scala @@ -0,0 +1,16 @@ +// Copyright (c) TribuFu. All Rights Reserved + +package tribufu + +import org.junit.runner.RunWith +import org.scalatest.funsuite.AnyFunSuite +import org.scalatestplus.junit.JUnitRunner + +@RunWith(classOf[JUnitRunner]) +class LibrarySuite extends AnyFunSuite { + test("Hello is always true") { + //def library = new Library() + //assert(library.Hello()) + assert(true) + } +}