Skip to content

Commit 3548029

Browse files
authored
Merge branch 'master' into renovate/macos-13.x
2 parents a4b1afd + 792fba4 commit 3548029

File tree

13 files changed

+175
-72
lines changed

13 files changed

+175
-72
lines changed

.github/workflows/build.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727

2828
steps:
2929
- name: Checkout
30-
uses: actions/checkout@v3
30+
uses: actions/checkout@v4
3131

3232
- name: Validate Gradle Wrapper
3333
uses: gradle/wrapper-validation-action@v1
@@ -45,8 +45,8 @@ jobs:
4545
emulator:
4646
runs-on: macos-latest
4747
steps:
48-
- uses: actions/checkout@v3
49-
- uses: actions/setup-java@v3.12.0
48+
- uses: actions/checkout@v4
49+
- uses: actions/setup-java@v3.13.0
5050
with:
5151
distribution: 'zulu'
5252
java-version: 19
@@ -66,7 +66,7 @@ jobs:
6666

6767
steps:
6868
- name: Checkout
69-
uses: actions/checkout@v3
69+
uses: actions/checkout@v4
7070

7171
- name: Validate Gradle Wrapper
7272
uses: gradle/wrapper-validation-action@v1
@@ -91,7 +91,7 @@ jobs:
9191

9292
steps:
9393
- name: Checkout
94-
uses: actions/checkout@v3
94+
uses: actions/checkout@v4
9595

9696
- name: Validate Gradle Wrapper
9797
uses: gradle/wrapper-validation-action@v1
@@ -120,7 +120,7 @@ jobs:
120120

121121
steps:
122122
- name: Checkout
123-
uses: actions/checkout@v3
123+
uses: actions/checkout@v4
124124

125125
- name: Configure JDK
126126
uses: actions/setup-java@v3
@@ -143,7 +143,7 @@ jobs:
143143

144144
steps:
145145
- name: Checkout
146-
uses: actions/checkout@v3
146+
uses: actions/checkout@v4
147147
with:
148148
fetch-depth: 0
149149

build-support/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ gradlePlugin {
2222
}
2323

2424
dependencies {
25-
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.0")
25+
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.10")
2626
}

build-support/src/main/kotlin/platforms.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ fun KotlinMultiplatformExtension.configureOrCreateNativePlatforms() {
4646
watchosSimulatorArm64()
4747
// Required to generate tests tasks: https://youtrack.jetbrains.com/issue/KT-26547
4848
linuxX64()
49+
linuxArm64()
4950
macosX64()
5051
macosArm64()
5152
mingwX64()
@@ -72,7 +73,8 @@ val mingwTargets = listOf(
7273
)
7374

7475
val linuxTargets = listOf(
75-
"linuxX64"
76+
"linuxX64",
77+
"linuxArm64",
7678
)
7779

7880
val nativeTargets = appleTargets + linuxTargets + mingwTargets

gradle/libs.versions.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ androidx-test-runner = { module = "androidx.test:runner", version = "1.5.2" }
1010
binaryCompatibilityValidator = { module = "org.jetbrains.kotlinx.binary-compatibility-validator:org.jetbrains.kotlinx.binary-compatibility-validator.gradle.plugin", version = "0.13.2" }
1111
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test" }
1212
kotlin-test-junit = { module = "org.jetbrains.kotlin:kotlin-test-junit" }
13-
kotlin-time = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version = "0.4.0" }
13+
kotlin-time = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version = "0.4.1" }
1414
jmh-gradle-plugin = { module = "me.champeau.jmh:jmh-gradle-plugin", version = "0.7.1" }
1515
jmh-core = { module = "org.openjdk.jmh:jmh-core", version.ref = "jmh" }
1616
jmh-generator = { module = "org.openjdk.jmh:jmh-generator-annprocess", version.ref = "jmh" }
17-
dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.8.20" }
18-
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.20.0" }
17+
dokka = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version = "1.9.0" }
18+
spotless = { module = "com.diffplug.spotless:spotless-plugin-gradle", version = "6.21.0" }
1919
bnd = { module = "biz.aQute.bnd:biz.aQute.bnd.gradle", version = "6.4.0" }
2020
vanniktech-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version = "0.25.3" }
2121
test-junit = { module = "junit:junit", version = "4.13.2" }
2222
test-assertj = { module = "org.assertj:assertj-core", version = "3.24.2" }
23-
test-assertk = "com.willowtreeapps.assertk:assertk:0.26.1"
23+
test-assertk = "com.willowtreeapps.assertk:assertk:0.27.0"
2424
test-jimfs = "com.google.jimfs:jimfs:1.3.0"

gradle/wrapper/gradle-wrapper.jar

346 Bytes
Binary file not shown.

gradle/wrapper/gradle-wrapper.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip
44
networkTimeout=10000
55
validateDistributionUrl=true
66
zipStoreBase=GRADLE_USER_HOME

gradlew

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

okio/build.gradle.kts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ plugins {
3737
* | | |-- watchosArm64
3838
* | | '-- watchosX86
3939
* | '-- linux
40-
* | '-- linuxX64
40+
* | |-- linuxX64
41+
* | '-- linuxArm64
4142
* '-- wasm
4243
* ```
4344
*

okio/src/jvmMain/kotlin/okio/DeflaterSink.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919

2020
package okio
2121

22-
import java.io.IOException
2322
import java.util.zip.Deflater
2423

2524
/**
@@ -83,10 +82,14 @@ internal constructor(private val sink: BufferedSink, private val deflater: Defla
8382
// Java 1.7, and is public (although with @hide) on Android since 2.3.
8483
// The @hide tag means that this code won't compile against the Android
8584
// 2.3 SDK, but it will run fine there.
86-
val deflated = if (syncFlush) {
87-
deflater.deflate(s.data, s.limit, Segment.SIZE - s.limit, Deflater.SYNC_FLUSH)
88-
} else {
89-
deflater.deflate(s.data, s.limit, Segment.SIZE - s.limit)
85+
val deflated = try {
86+
if (syncFlush) {
87+
deflater.deflate(s.data, s.limit, Segment.SIZE - s.limit, Deflater.SYNC_FLUSH)
88+
} else {
89+
deflater.deflate(s.data, s.limit, Segment.SIZE - s.limit)
90+
}
91+
} catch (npe: NullPointerException) {
92+
throw IOException("Deflater already closed", npe)
9093
}
9194

9295
if (deflated > 0) {

okio/src/jvmMain/kotlin/okio/internal/ResourceFileSystem.kt

Lines changed: 48 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ import okio.Path.Companion.toOkioPath
2828
import okio.Path.Companion.toPath
2929
import okio.Sink
3030
import okio.Source
31+
import okio.source
3132

3233
/**
3334
* A file system exposing Java classpath resources. It is equivalent to the files returned by
@@ -41,8 +42,9 @@ import okio.Source
4142
* This file system is read-only.
4243
*/
4344
internal class ResourceFileSystem internal constructor(
44-
classLoader: ClassLoader,
45+
private val classLoader: ClassLoader,
4546
indexEagerly: Boolean,
47+
private val systemFileSystem: FileSystem = SYSTEM,
4648
) : FileSystem() {
4749
private val roots: List<Pair<FileSystem, Path>> by lazy { classLoader.toClasspathRoots() }
4850

@@ -122,14 +124,10 @@ internal class ResourceFileSystem internal constructor(
122124

123125
override fun source(file: Path): Source {
124126
if (!keepPath(file)) throw FileNotFoundException("file not found: $file")
125-
val relativePath = file.toRelativePath()
126-
for ((fileSystem, base) in roots) {
127-
try {
128-
return fileSystem.source(base / relativePath)
129-
} catch (_: FileNotFoundException) {
130-
}
131-
}
132-
throw FileNotFoundException("file not found: $file")
127+
// Make sure we have a path that doesn't start with '/'.
128+
val relativePath = ROOT.resolve(file).relativeTo(ROOT)
129+
return classLoader.getResourceAsStream(relativePath.toString())?.source()
130+
?: throw FileNotFoundException("file not found: $file")
133131
}
134132

135133
override fun sink(file: Path, mustCreate: Boolean): Sink {
@@ -157,6 +155,47 @@ internal class ResourceFileSystem internal constructor(
157155
return canonicalThis.relativeTo(ROOT).toString()
158156
}
159157

158+
/**
159+
* Returns a search path of classpath roots. Each element contains a file system to use, and
160+
* the base directory of that file system to search from.
161+
*/
162+
private fun ClassLoader.toClasspathRoots(): List<Pair<FileSystem, Path>> {
163+
// We'd like to build this upon an API like ClassLoader.getURLs() but unfortunately that
164+
// API exists only on URLClassLoader (and that isn't the default class loader implementation).
165+
//
166+
// The closest we have is `ClassLoader.getResources("")`. It returns all classpath roots that
167+
// are directories but none that are .jar files. To mitigate that we also search for all
168+
// `META-INF/MANIFEST.MF` files, hastily assuming that every .jar file will have such an
169+
// entry.
170+
//
171+
// Classpath entries that aren't directories and don't have a META-INF/MANIFEST.MF file will
172+
// not be visible in this file system.
173+
return getResources("").toList().mapNotNull { it.toFileRoot() } +
174+
getResources("META-INF/MANIFEST.MF").toList().mapNotNull { it.toJarRoot() }
175+
}
176+
177+
private fun URL.toFileRoot(): Pair<FileSystem, Path>? {
178+
if (protocol != "file") return null // Ignore unexpected URLs.
179+
return systemFileSystem to File(toURI()).toOkioPath()
180+
}
181+
182+
private fun URL.toJarRoot(): Pair<FileSystem, Path>? {
183+
val urlString = toString()
184+
if (!urlString.startsWith("jar:file:")) return null // Ignore unexpected URLs.
185+
186+
// Given a URL like `jar:file:/tmp/foo.jar!/META-INF/MANIFEST.MF`, get the path to the archive
187+
// file, like `/tmp/foo.jar`.
188+
val suffixStart = urlString.lastIndexOf("!")
189+
if (suffixStart == -1) return null
190+
val path = File(URI.create(urlString.substring("jar:".length, suffixStart))).toOkioPath()
191+
val zip = openZip(
192+
zipPath = path,
193+
fileSystem = systemFileSystem,
194+
predicate = { entry -> keepPath(entry.canonicalPath) },
195+
)
196+
return zip to ROOT
197+
}
198+
160199
private companion object {
161200
val ROOT = "/".toPath()
162201

@@ -165,47 +204,6 @@ internal class ResourceFileSystem internal constructor(
165204
return ROOT / (toString().removePrefix(prefix).replace('\\', '/'))
166205
}
167206

168-
/**
169-
* Returns a search path of classpath roots. Each element contains a file system to use, and
170-
* the base directory of that file system to search from.
171-
*/
172-
fun ClassLoader.toClasspathRoots(): List<Pair<FileSystem, Path>> {
173-
// We'd like to build this upon an API like ClassLoader.getURLs() but unfortunately that
174-
// API exists only on URLClassLoader (and that isn't the default class loader implementation).
175-
//
176-
// The closest we have is `ClassLoader.getResources("")`. It returns all classpath roots that
177-
// are directories but none that are .jar files. To mitigate that we also search for all
178-
// `META-INF/MANIFEST.MF` files, hastily assuming that every .jar file will have such an
179-
// entry.
180-
//
181-
// Classpath entries that aren't directories and don't have a META-INF/MANIFEST.MF file will
182-
// not be visible in this file system.
183-
return getResources("").toList().mapNotNull { it.toFileRoot() } +
184-
getResources("META-INF/MANIFEST.MF").toList().mapNotNull { it.toJarRoot() }
185-
}
186-
187-
fun URL.toFileRoot(): Pair<FileSystem, Path>? {
188-
if (protocol != "file") return null // Ignore unexpected URLs.
189-
return SYSTEM to File(toURI()).toOkioPath()
190-
}
191-
192-
fun URL.toJarRoot(): Pair<FileSystem, Path>? {
193-
val urlString = toString()
194-
if (!urlString.startsWith("jar:file:")) return null // Ignore unexpected URLs.
195-
196-
// Given a URL like `jar:file:/tmp/foo.jar!/META-INF/MANIFEST.MF`, get the path to the archive
197-
// file, like `/tmp/foo.jar`.
198-
val suffixStart = urlString.lastIndexOf("!")
199-
if (suffixStart == -1) return null
200-
val path = File(URI.create(urlString.substring("jar:".length, suffixStart))).toOkioPath()
201-
val zip = openZip(
202-
zipPath = path,
203-
fileSystem = SYSTEM,
204-
predicate = { entry -> keepPath(entry.canonicalPath) },
205-
)
206-
return zip to ROOT
207-
}
208-
209207
private fun keepPath(path: Path) = !path.name.endsWith(".class", ignoreCase = true)
210208
}
211209
}

0 commit comments

Comments
 (0)