Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/code-quality.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
continue-on-error: true

- name: Check for compilation warnings
run: ./gradlew compileKotlin --no-daemon -Dorg.gradle.warning.mode=all
run: ./gradlew compileDebugKotlin --no-daemon -Dorg.gradle.warning.mode=all

- name: Run dependency check
run: ./gradlew dependencyCheck --no-daemon
Expand Down
8 changes: 6 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,18 @@
# https://docs.gradle.org/current/userguide/platforms.html#sub::toml-dependencies-format

[versions]
android-gradle-plugin = "8.7.3"
commons-math3 = "3.6.1"
guava = "33.4.6-jre"
junit-jupiter-engine = "5.12.1"
kotlin = "2.2.20"

[libraries]
commons-math3 = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
commons-math = { module = "org.apache.commons:commons-math3", version.ref = "commons-math3" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
junit-jupiter-engine = { module = "org.junit.jupiter:junit-jupiter-engine", version.ref = "junit-jupiter-engine" }

[plugins]
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version = "2.2.20" }
android-library = { id = "com.android.library", version.ref = "android-gradle-plugin" }
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
116 changes: 80 additions & 36 deletions lib/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,63 @@
*/

plugins {
// Apply the org.jetbrains.kotlin.jvm Plugin to add support for Kotlin.
alias(libs.plugins.kotlin.jvm)

// Apply the java-library plugin for API and implementation separation.
`java-library`
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)

id("com.squareup.wire") version "5.4.0"

// JaCoCo for code coverage
jacoco

`maven-publish`
}

android {
namespace = "org.flex"
compileSdk = 35

defaultConfig {
minSdk = 21

testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

testOptions {
unitTests.all {
it.useJUnitPlatform()
}
}

buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_21
targetCompatibility = JavaVersion.VERSION_21
}

kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_21)
}
}

publishing {
singleVariant("release") {
withSourcesJar()
}
}
}

repositories {
// Use Maven Central for resolving dependencies.
mavenCentral()
// Apply a specific Java toolchain to ensure we use Java 21
kotlin {
jvmToolchain(21)
}

wire {
Expand All @@ -39,6 +81,7 @@ val coroutinesVersion = "1.7.3"
dependencies {
// Kotlin Coroutines - Android compatible
api("org.jetbrains.kotlinx:kotlinx-coroutines-core:$coroutinesVersion")
api("org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion")

// Use the Kotlin Test integration.
Expand All @@ -53,7 +96,7 @@ dependencies {
testImplementation("io.mockk:mockk:1.13.8")

// This dependency is exported to consumers, that is to say found on their compile classpath.
api(libs.commons.math3)
api(libs.commons.math)

// This dependency is used internally, and not exposed to consumers on their own compile classpath.
implementation(libs.guava)
Expand All @@ -63,40 +106,41 @@ dependencies {
implementation("com.squareup.wire:wire-grpc-client:5.4.0")
}

// Apply a specific Java toolchain to ease working on different environments.
java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

tasks.named<Test>("test") {
// Use JUnit Platform for unit tests.
useJUnitPlatform()

// Generate JaCoCo coverage data
finalizedBy(tasks.jacocoTestReport)
}

// Configure JaCoCo code coverage
jacoco {
toolVersion = "0.8.10"
toolVersion = "0.8.12"
}

tasks.jacocoTestReport {
dependsOn(tasks.test)
tasks.register<JacocoReport>("jacocoTestReport") {
dependsOn(tasks.named("testDebugUnitTest"))
dependsOn(tasks.named("testReleaseUnitTest"))

reports {
xml.required = true
html.required = true
csv.required = false
xml.required.set(true)
html.required.set(true)
}

classDirectories.setFrom(files(
fileTree("${layout.buildDirectory.get()}/classes/kotlin/main") {
exclude("**/*Test*")
val debugTree = fileTree(layout.buildDirectory.dir("tmp/kotlin-classes/debug"))
val mainSrc = "src/main/kotlin"

sourceDirectories.setFrom(files(mainSrc))
classDirectories.setFrom(debugTree)
executionData.setFrom(fileTree(layout.buildDirectory.dir("jacoco")).include("*.exec"))
}

publishing {
publications {
register<MavenPublication>("release") {
groupId = "org.flex"
artifactId = "flexible"
version = "0.0.1"

afterEvaluate {
from(components["release"])
}
}
))
sourceDirectories.setFrom(files("src/main/kotlin"))
executionData.setFrom(files("${layout.buildDirectory.get()}/jacoco/test.exec"))
}
repositories {
mavenLocal()
}
}
2 changes: 2 additions & 0 deletions lib/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest />
2 changes: 1 addition & 1 deletion lib/src/main/kotlin/org/flex/FlexClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ abstract class FlexClient(
}

private fun updateStats(update: (SessionStats) -> SessionStats) {
_stats.updateAndGet(update)
_stats.set(update(_stats.get()))
listener.onStatsUpdated(_stats.get())
}
}
Expand Down
5 changes: 3 additions & 2 deletions lib/src/main/proto/org/flex/tensor.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
syntax = "proto3";
package flexible;

package org.flex.flexible;

option java_package = "org.flex.flexible";
option java_multiple_files = true;
message Tensor {
repeated int32 shape = 1;
bytes data = 2;
Expand Down
6 changes: 5 additions & 1 deletion lib/src/main/proto/org/flex/transport.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
syntax = "proto3";
package flexible;

// This defines where the generated Java classes will live
option java_package = "org.flex.flexible";
option java_multiple_files = true;

package org.flex.flexible;

import "org/flex/tensor.proto";

Expand Down
15 changes: 15 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
* For more detailed information on multi-project builds, please refer to https://docs.gradle.org/9.2.0/userguide/multi_project_builds.html in the Gradle documentation.
*/

pluginManagement {
repositories {
google()
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
}

plugins {
// Apply the foojay-resolver plugin to allow automatic download of JDKs
id("org.gradle.toolchains.foojay-resolver-convention") version "1.0.0"
Expand Down
Loading