From 4fd93e904f4c34eb287c793953c206e585584b01 Mon Sep 17 00:00:00 2001 From: GuilhermeWerner <26710260+GuilhermeWerner@users.noreply.github.com> Date: Mon, 26 Apr 2021 09:13:20 -0300 Subject: [PATCH] Migrate back to Kotlin --- lib/build.gradle.kts | 32 +++++------ .../tribufu/TribuFu.kt} | 21 ++++---- lib/src/main/resources/.gitkeep | 0 lib/src/main/scala/tribufu/models/Email.scala | 10 ---- lib/src/main/scala/tribufu/models/User.scala | 53 ------------------- lib/src/test/resources/.gitkeep | 0 lib/src/test/scala/tribufu/LibrarySuite.scala | 16 ------ 7 files changed, 23 insertions(+), 109 deletions(-) rename lib/src/main/{scala/tribufu/Library.scala => kotlin/tribufu/TribuFu.kt} (53%) delete mode 100644 lib/src/main/resources/.gitkeep delete mode 100644 lib/src/main/scala/tribufu/models/Email.scala delete mode 100644 lib/src/main/scala/tribufu/models/User.scala delete mode 100644 lib/src/test/resources/.gitkeep delete mode 100644 lib/src/test/scala/tribufu/LibrarySuite.scala diff --git a/lib/build.gradle.kts b/lib/build.gradle.kts index 5e3addf..69a91e7 100644 --- a/lib/build.gradle.kts +++ b/lib/build.gradle.kts @@ -1,8 +1,8 @@ -plugins { - // Apply the scala Plugin to add support for Scala. - scala +import org.jetbrains.kotlin.gradle.tasks.KotlinCompile + +plugins { + kotlin("jvm") version "1.4.10" - // Apply the java-library plugin for API and implementation separation. `java-library` } @@ -10,27 +10,15 @@ group = "tribufu" version = "0.0.1" repositories { - // Use Maven Central for resolving dependencies. mavenCentral() } dependencies { - // Use Scala 2.13 in our library project - implementation("org.scala-lang:scala-library:2.13.3") + testImplementation(kotlin("test-junit")) +} - // 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.test { + useJUnit() } tasks.jar { @@ -38,3 +26,7 @@ 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/scala/tribufu/Library.scala b/lib/src/main/kotlin/tribufu/TribuFu.kt similarity index 53% rename from lib/src/main/scala/tribufu/Library.scala rename to lib/src/main/kotlin/tribufu/TribuFu.kt index bb85a8c..1f8fc36 100644 --- a/lib/src/main/scala/tribufu/Library.scala +++ b/lib/src/main/kotlin/tribufu/TribuFu.kt @@ -2,16 +2,17 @@ package tribufu -class Library { - init() - - private def init() { - // Used to load the 'TribuFu' library on application startup. - //System.loadLibrary("TribuFu") - } - +class TribuFu { /** - * A native method that is implemented by the 'TribuFu' native library. + * A native method that is implemented by the 'TribuFu' native library, which is packaged with + * this library. */ - //@native def Hello(): Int + // external fun Hello(): Int + + companion object { + // Used to load the 'TribuFu' library on application startup. + init { + //System.loadLibrary("TribuFu") + } + } } diff --git a/lib/src/main/resources/.gitkeep b/lib/src/main/resources/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/lib/src/main/scala/tribufu/models/Email.scala b/lib/src/main/scala/tribufu/models/Email.scala deleted file mode 100644 index 376f9a6..0000000 --- a/lib/src/main/scala/tribufu/models/Email.scala +++ /dev/null @@ -1,10 +0,0 @@ -// Copyright (c) TribuFu. All Rights Reserved - -package tribufu.models - -class Email { - val address = "" - val user_id = "1" - val confirmed = false - val primary = true -} diff --git a/lib/src/main/scala/tribufu/models/User.scala b/lib/src/main/scala/tribufu/models/User.scala deleted file mode 100644 index 30dd310..0000000 --- a/lib/src/main/scala/tribufu/models/User.scala +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright (c) TribuFu. All Rights Reserved - -package tribufu.models - -class User { - val id = "" - val name = "" - val display_name = "" - val password_hash = "" - val role = Role.User - val confirmed = false - val two_factor_enabled = false - val first_name = "" - val last_name = "" - val verified = false - val parental_control = false - val profile_url = "" - val public_birthday = false - val Birthday = "" - val location = "" - val timezone = "" - val language = "" - val currency = "" - val theme = Theme.Light - val ip_address = "" - val registration_ip_address = "" - val Joined = "" - val Updated = "" - val failed_logins = 0 - val about = "" - val profile_views = 0 - val content = 0 - val avatar_url = "" - val background_url = "" - val status = Status.Offline - val LastOnline = "" - val LastActivity = "" - val LastPost = "" - val warnings = 0 - val LastWarn = "" -} - -object Role extends Enumeration { - val User, Bot, Helper, Tester, Developer, Moderator, Admin, Root = Value -} - -object Theme extends Enumeration { - val Light, Dark = Value -} - -object Status extends Enumeration { - val Offline, Away, Disturb, Online, Playing = Value -} diff --git a/lib/src/test/resources/.gitkeep b/lib/src/test/resources/.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 deleted file mode 100644 index 0754d10..0000000 --- a/lib/src/test/scala/tribufu/LibrarySuite.scala +++ /dev/null @@ -1,16 +0,0 @@ -// 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) - } -}