Skip to content

Commit

Permalink
fix jvm build
Browse files Browse the repository at this point in the history
  • Loading branch information
luca992 committed Aug 8, 2024
1 parent 6dd1895 commit 3851117
Show file tree
Hide file tree
Showing 17 changed files with 230 additions and 139 deletions.
14 changes: 7 additions & 7 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,20 @@ org-kodein-mock-mockmp = { id = "org.kodein.mock.mockmp", version.ref = "mockmp"

[versions]

kotlin = "2.0.0"
agp = "8.2.2"
kotlin = "2.0.10"
agp = "8.3.2"
compose-jb = "1.6.11"
vanniktech-publish = "0.27.0"
vanniktech-publish = "0.29.0"
okio = "3.9.0"
multiplatform-resources = "0.24.0"
multiplatform-resources = "0.24.1"
mockmp = "1.17.0"
kermit = "2.0.4"

androidx-activity = "1.9.0"
androidx-lifecycle = "2.8.1"
androidx-activity = "1.9.1"
androidx-lifecycle = "2.8.4"
androidx-startup = "1.1.1"
androidx-appcompat = "1.7.0"
androidx-runner = "1.5.2"
androidx-runner = "1.6.1"

[libraries]

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
17 changes: 15 additions & 2 deletions kotlin-js-store/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
package io.michaelrocks.libphonenumber.kotlin.io

expect abstract class InputStream: AutoCloseable {
abstract override fun close(): kotlin.Unit
}
interface InputStream : AutoCloseable

Original file line number Diff line number Diff line change
@@ -1,20 +1,6 @@
package io.michaelrocks.libphonenumber.kotlin.io

expect open class ObjectInputStream(inputStream: InputStream) : InputStream, ObjectInput, ObjectStreamConstants {
override fun readFully(b: ByteArray?): Unit
override fun readFully(b: ByteArray?, off: Int, len: Int): Unit
override fun skipBytes(n: Int): Int
override fun readBoolean(): Boolean
override fun readByte(): Byte
override fun readUnsignedByte(): Int
override fun readShort(): Short
override fun readUnsignedShort(): Int
override fun readChar(): Char
override fun readInt(): Int
override fun readLong(): Long
override fun readFloat(): Float
override fun readDouble(): Double
override fun readLine(): String
override fun readUTF(): String
override fun close()
}
interface ObjectInputStream : InputStream, ObjectInput, ObjectStreamConstants


expect fun getPlatformObjectInputStream(inputStream: InputStream): ObjectInputStream
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import io.michaelrocks.libphonenumber.kotlin.Phonemetadata
import io.michaelrocks.libphonenumber.kotlin.Phonemetadata.PhoneMetadata
import io.michaelrocks.libphonenumber.kotlin.io.InputStream
import io.michaelrocks.libphonenumber.kotlin.io.ObjectInputStream
import io.michaelrocks.libphonenumber.kotlin.io.getPlatformObjectInputStream
import okio.IOException
import kotlin.jvm.JvmStatic

Expand All @@ -40,7 +41,7 @@ class MetadataParser private constructor(private val strictMode: Boolean) {
}
var ois: ObjectInputStream? = null
return try {
ois = ObjectInputStream(source)
ois = getPlatformObjectInputStream(source)
val phoneMetadataCollection = Phonemetadata.PhoneMetadataCollection()
phoneMetadataCollection.readExternal(ois)
val phoneMetadata = phoneMetadataCollection.metadataList
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package io.michaelrocks.libphonenumber.kotlin.io

actual typealias InputStream = java.io.InputStream
class JavaInputStream(val javaInputStream: java.io.InputStream) : InputStream {

override fun close() {
javaInputStream.close()
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,96 @@
package io.michaelrocks.libphonenumber.kotlin.io

actual typealias ObjectInputStream = java.io.ObjectInputStream

actual fun getPlatformObjectInputStream(inputStream: InputStream): ObjectInputStream {
return JavaObjectInputStream(java.io.ObjectInputStream((inputStream as JavaInputStream).javaInputStream))
}

class JavaObjectInputStream(val objectInputStream: java.io.ObjectInputStream) : ObjectInputStream {
override fun readObject(): Any? {
return objectInputStream.readObject()
}

override fun read(): Int {
return objectInputStream.read()
}

override fun read(b: ByteArray?): Int {
return objectInputStream.read(b)
}

override fun read(b: ByteArray?, off: Int, len: Int): Int {
return objectInputStream.read(b, off, len)
}

override fun skip(n: Long): Long {
return objectInputStream.skip(n)
}

override fun available(): Int {
return objectInputStream.available()
}

override fun close() {
objectInputStream.close()
}

override fun readFully(b: ByteArray?) {
objectInputStream.readFully(b)
}

override fun readFully(b: ByteArray?, off: Int, len: Int) {
objectInputStream.readFully(b, off, len)
}

override fun skipBytes(n: Int): Int {
return objectInputStream.skipBytes(n)
}

override fun readBoolean(): Boolean {
return objectInputStream.readBoolean()
}

override fun readByte(): Byte {
return objectInputStream.readByte()
}

override fun readUnsignedByte(): Int {
return objectInputStream.readUnsignedByte()
}

override fun readShort(): Short {
return objectInputStream.readShort()
}

override fun readUnsignedShort(): Int {
return objectInputStream.readUnsignedShort()
}

override fun readChar(): Char {
return objectInputStream.readChar()
}

override fun readInt(): Int {
return objectInputStream.readInt()
}

override fun readLong(): Long {
return objectInputStream.readLong()
}

override fun readFloat(): Float {
return objectInputStream.readFloat()
}

override fun readDouble(): Double {
return objectInputStream.readDouble()
}

override fun readLine(): String? {
return objectInputStream.readLine()
}

override fun readUTF(): String? {
return objectInputStream.readUTF()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import co.touchlab.kermit.Logger
import dev.icerock.moko.resources.AssetResource
import io.michaelrocks.libphonenumber.kotlin.MetadataLoader
import io.michaelrocks.libphonenumber.kotlin.io.InputStream
import io.michaelrocks.libphonenumber.kotlin.io.JavaInputStream

/**
* A [MetadataLoader] implementation that reads phone number metadata files as classpath
* resources.
*/
class ClassPathResourceMetadataLoader : MetadataLoader {
override fun loadMetadata(phoneMetadataResource: AssetResource): InputStream? {
return phoneMetadataResource.resourcesClassLoader.getResourceAsStream(phoneMetadataResource.filePath)
return JavaInputStream(phoneMetadataResource.resourcesClassLoader.getResourceAsStream(phoneMetadataResource.filePath))
}

companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,8 @@ package io.michaelrocks.libphonenumber.kotlin.io

import okio.BufferedSource

actual abstract class InputStream : AutoCloseable {
actual abstract override fun close()
}

class OkioInputStream(val bufferedSource: BufferedSource) : InputStream() {
class OkioInputStream(val bufferedSource: BufferedSource) : InputStream {

override fun close() {
bufferedSource.close()
Expand Down
Loading

0 comments on commit 3851117

Please sign in to comment.