Skip to content

Fix Android compatibility issues #209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Aug 14, 2023
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ Add the library to dependencies:
</dependency>
```

### Android

`kotlinx-io` is not tested on Android on a regular basis,
but the library is compatible with Android 5.0+ (API level 21+).

## Contributing

Read the [Contributing Guidelines](CONTRIBUTING.md).
Expand Down
1 change: 1 addition & 0 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ repositories {

dependencies {
implementation(libs.kotlin.gradle.plugin)
implementation(libs.animalsniffer.gradle.plugin)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file.
*/

import ru.vyarus.gradle.plugin.animalsniffer.AnimalSnifferExtension

pluginManager.withPlugin("java") {
apply(plugin = "ru.vyarus.animalsniffer")

configure<AnimalSnifferExtension> {
sourceSets = listOf((project.extensions.getByName("sourceSets") as SourceSetContainer).getByName("main"))
}
val signature: Configuration by configurations
dependencies {
// Use the same API level as OkHttp
signature("net.sf.androidscents.signature:android-api-level-21:5.0.1_r2@signature")
}
}
1 change: 1 addition & 0 deletions bytestring/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
plugins {
id("kotlinx-io-multiplatform")
id("kotlinx-io-publish")
id("kotlinx-io-android-compat")
alias(libs.plugins.kover)
alias(libs.plugins.dokka)
}
Expand Down
1 change: 1 addition & 0 deletions core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import org.jetbrains.dokka.gradle.DokkaTaskPartial
plugins {
id("kotlinx-io-multiplatform")
id("kotlinx-io-publish")
id("kotlinx-io-android-compat")
alias(libs.plugins.kover)
alias(libs.plugins.dokka)
}
Expand Down
11 changes: 5 additions & 6 deletions core/jvm/src/files/Paths.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
package kotlinx.io.files

import kotlinx.io.*
import java.io.File
import java.io.FileInputStream
import java.io.FileOutputStream
import java.nio.file.*
import java.nio.file.Path as NioPath

public actual class Path internal constructor(internal val nioPath: NioPath)
public actual class Path internal constructor(internal val file: File)

public actual fun Path(path: String): Path = Path(Paths.get(path))
public actual fun Path(path: String): Path = Path(File(path))

public actual fun Path.source(): Source = FileInputStream(nioPath.toFile()).asSource().buffered()
public actual fun Path.source(): Source = FileInputStream(file).asSource().buffered()

public actual fun Path.sink(): Sink = FileOutputStream(nioPath.toFile()).asSink().buffered()
public actual fun Path.sink(): Sink = FileOutputStream(file).asSink().buffered()
3 changes: 3 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ bcv = "0.13.2"
benchmark = "0.4.9"
jmh = "1.36"
coroutines = "1.7.3"
animalsniffer = "1.7.1"

[libraries]

kotlinx-benchmark-runtime = { group = "org.jetbrains.kotlinx", name = "kotlinx-benchmark-runtime", version.ref = "benchmark" }
kotlin-gradle-plugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
kotlinx-coroutines-core = { group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version.ref = "coroutines" }
animalsniffer-gradle-plugin = { group = "ru.vyarus", name = "gradle-animalsniffer-plugin", version.ref = "animalsniffer" }

[plugins]

dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
Expand Down