Skip to content

Commit

Permalink
Add Kotlin language (#1096)
Browse files Browse the repository at this point in the history
* add kotlin and kotlin-test libraries, update github action's plugins
  • Loading branch information
lfoppiano committed May 5, 2024
1 parent d98129f commit 664824d
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 10 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci-build-unstable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v1
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v1
uses: actions/setup-java@v4
with:
java-version: 1.17
java-version: '17.0.10+7'
distribution: 'temurin'
cache: 'gradle'
- name: Build with Gradle
run: ./gradlew clean assemble --info --stacktrace --no-daemon

Expand All @@ -38,10 +40,10 @@ jobs:
steps:
- name: Create more disk space
run: sudo rm -rf /usr/share/dotnet && sudo rm -rf /opt/ghc && sudo rm -rf "/usr/local/share/boost" && sudo rm -rf "$AGENT_TOOLSDIRECTORY"
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Build and push
id: docker_build
uses: mr-smithers-excellent/docker-build-push@v5
uses: mr-smithers-excellent/docker-build-push@v6
with:
username: ${{ secrets.DOCKERHUB_USERNAME_LFOPPIANO }}
password: ${{ secrets.DOCKERHUB_TOKEN_LFOPPIANO }}
Expand Down
29 changes: 25 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ buildscript {
classpath 'gradle.plugin.org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.12.0'
classpath "gradle.plugin.com.github.jengelman.gradle.plugins:shadow:7.0.0"
classpath 'com.adarshr:gradle-test-logger-plugin:2.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.21"
}
}

repositories {
mavenLocal()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}

apply plugin: 'jacoco'
Expand All @@ -29,6 +33,7 @@ allprojects {
apply plugin: 'base'
apply plugin: 'com.github.kt3k.coveralls'
apply plugin: 'com.adarshr.test-logger'
apply plugin: 'org.jetbrains.kotlin.jvm'

group = "org.grobid"

Expand All @@ -55,8 +60,18 @@ subprojects {
}
}

sourceCompatibility = 1.11
targetCompatibility = 1.11
// sourceCompatibility = 1.11
// targetCompatibility = 1.11

kotlin {
jvmToolchain(17)
}

java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(17))
}
}

repositories {
mavenCentral()
Expand Down Expand Up @@ -86,14 +101,20 @@ subprojects {
// packaging local libs inside grobid-core.jar
implementation fileTree(dir: new File(rootProject.rootDir, 'grobid-core/localLibs'), include: localLibs)

testRuntimeOnly 'org.junit.vintage:junit-vintage-engine:5.9.3'
testImplementation(platform('org.junit:junit-bom:5.9.3'))
testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine"
testRuntimeOnly "org.junit.vintage:junit-vintage-engine"
testImplementation(platform('org.junit:junit-bom:5.10.2'))
testRuntimeOnly("org.junit.platform:junit-platform-launcher") {
because("Only needed to run tests in a version of IntelliJ IDEA that bundles older versions")
}
testImplementation('org.junit.jupiter:junit-jupiter')
testImplementation 'org.easymock:easymock:5.1.0'
testImplementation "org.powermock:powermock-api-easymock:2.0.7"
testImplementation "org.powermock:powermock-module-junit4:2.0.7"
testImplementation "xmlunit:xmlunit:1.6"
testImplementation "org.hamcrest:hamcrest-all:1.3"
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation "io.mockk:mockk:1.13.9"

implementation "com.cybozu.labs:langdetect:1.1-20120112"
implementation "com.rockymadden.stringmetric:stringmetric-core_2.11:0.27.4"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ public static boolean toSkipToken(String tok) {
return false;
}

private static boolean toSkipTokenNoHyphen(String tok) {
static boolean toSkipTokenNoHyphen(String tok) {
if (tok.equals(" ") || tok.equals("\n") || tok.equals("\t"))
return true;
else
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.grobid.core.utilities

import org.junit.Test
import kotlin.test.assertFalse
import kotlin.test.assertTrue

class SentenceUtilitiesKTest {

@Test
fun testToSkipToken_shouldReturnTrue() {
val tokens = arrayOf("-", " ", "\n", "\t")

tokens.forEach { token ->
assertTrue(SentenceUtilities.toSkipToken(token))
}

}

@Test
fun testToSkipTokenNoHypen_shouldReturnTrue() {
val tokens = arrayOf(" ", "\n", "\t")

tokens.forEach { token ->
assertTrue(SentenceUtilities.toSkipTokenNoHyphen(token))
}

assertFalse { SentenceUtilities.toSkipTokenNoHyphen("-") }

}


}

0 comments on commit 664824d

Please sign in to comment.