mirror of
https://github.com/tribufu/tribufu-java
synced 2026-05-06 14:57:27 +00:00
Migrate to Scala
This commit is contained in:
parent
3aac52f5a5
commit
4f8c2590ef
6 changed files with 100 additions and 86 deletions
|
|
@ -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 = "com.tribufu.sdk"
|
|||
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<KotlinCompile>() {
|
||||
kotlinOptions.jvmTarget = "1.8"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,65 +0,0 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk.models
|
||||
|
||||
class User {
|
||||
var id = ""
|
||||
var name = ""
|
||||
var display_name = ""
|
||||
var password_hash = ""
|
||||
var role = Role.User
|
||||
var confirmed = false
|
||||
var two_factor_enabled = false
|
||||
var first_name = ""
|
||||
var last_name = ""
|
||||
var verified = false
|
||||
var parental_control = false
|
||||
var profile_url = ""
|
||||
var public_birthday = false
|
||||
var Birthday = ""
|
||||
var location = ""
|
||||
var timezone = ""
|
||||
var language = ""
|
||||
var currency = ""
|
||||
var theme = Theme.Light
|
||||
var ip_address = ""
|
||||
var registration_ip_address = ""
|
||||
var Joined = ""
|
||||
var Updated = ""
|
||||
var failed_logins = 0
|
||||
var about = ""
|
||||
var profile_views = 0
|
||||
var content = 0
|
||||
var avatar_url = ""
|
||||
var background_url = ""
|
||||
var status = Status.Offline
|
||||
var LastOnline = ""
|
||||
var LastActivity = ""
|
||||
var LastPost = ""
|
||||
var warnings = 0
|
||||
var LastWarn = ""
|
||||
}
|
||||
|
||||
enum class Role {
|
||||
User,
|
||||
Bot,
|
||||
Helper,
|
||||
Tester,
|
||||
Developer,
|
||||
Moderator,
|
||||
Admin,
|
||||
Root
|
||||
}
|
||||
|
||||
enum class Theme {
|
||||
Light,
|
||||
Dark
|
||||
}
|
||||
|
||||
enum class Status {
|
||||
Offline,
|
||||
Away,
|
||||
Disturb,
|
||||
Online,
|
||||
Playing
|
||||
}
|
||||
|
|
@ -3,13 +3,15 @@
|
|||
package com.tribufu.sdk
|
||||
|
||||
class TribuFu {
|
||||
Init()
|
||||
|
||||
// Used to load the 'TribuFu' library on application startup.
|
||||
private def Init() {
|
||||
System.loadLibrary("TribuFu_jvm")
|
||||
}
|
||||
|
||||
/**
|
||||
* A native method that is implemented by the 'TribuFu' native library.
|
||||
*/
|
||||
external fun Hello(input: String): String
|
||||
|
||||
// Used to load the 'TribuFu' library on application startup.
|
||||
init {
|
||||
System.loadLibrary("TribuFu_jvm")
|
||||
}
|
||||
@native def Hello(input: String): String
|
||||
}
|
||||
|
|
@ -3,8 +3,8 @@
|
|||
package com.tribufu.sdk.models
|
||||
|
||||
class Email {
|
||||
var address = ""
|
||||
var user_id = "1"
|
||||
var confirmed = false
|
||||
var primary = true
|
||||
val address = ""
|
||||
val user_id = "1"
|
||||
val confirmed = false
|
||||
val primary = true
|
||||
}
|
||||
53
lib/src/main/scala/models/User.scala
Normal file
53
lib/src/main/scala/models/User.scala
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk.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
|
||||
}
|
||||
16
lib/src/test/scala/com/tribufu/sdk/TribuFuSuite.scala
Normal file
16
lib/src/test/scala/com/tribufu/sdk/TribuFuSuite.scala
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
// Copyright (c) TribuFu. All Rights Reserved
|
||||
|
||||
package com.tribufu.sdk
|
||||
|
||||
import org.junit.runner.RunWith
|
||||
import org.scalatest.funsuite.AnyFunSuite
|
||||
import org.scalatestplus.junit.JUnitRunner
|
||||
|
||||
@RunWith(classOf[JUnitRunner])
|
||||
class TribuFuSuite extends AnyFunSuite {
|
||||
test("Hello is always true") {
|
||||
//def library = new TribuFu()
|
||||
//assert(library.Hello())
|
||||
assert(true)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue