Skip to content

Commit 2602e0f

Browse files
committed
fix: Make copyKneNativeLib task configuration cache compatible
Resolve Project reference captured in task action by: - Extracting buildDirectory Provider before task registration - Replacing project.logger with task.logger - Simplifying task dependency from project.tasks.matching to direct task name Fixes: Task ":nativertl:copyKneNativeLib" serialization error with configuration cache
1 parent 952f388 commit 2602e0f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

plugin-build/plugin/src/main/kotlin/io/github/kdroidfilter/nucleusnativeaccess/plugin/KotlinNativeExportPlugin.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,12 +163,13 @@ class KotlinNativeExportPlugin : Plugin<Project> {
163163
val linkTaskName = "link${libCap}ReleaseShared$targetCap"
164164
val nativeLibResourceDir = project.layout.buildDirectory.dir("generated/kne/nativeLib")
165165

166+
val buildDir = project.layout.buildDirectory
166167
val copyNativeLib = project.tasks.register("copyKneNativeLib") { task ->
167168
task.group = "kne"
168169
task.description = "Copy native shared library into JVM resources for JAR bundling"
169-
task.dependsOn(project.tasks.matching { it.name == linkTaskName })
170+
task.dependsOn(linkTaskName)
170171
task.doLast {
171-
val releaseDir = project.layout.buildDirectory
172+
val releaseDir = buildDir
172173
.dir("bin/$targetName/${libName}ReleaseShared").get().asFile
173174
val nativeFile = releaseDir.listFiles()?.firstOrNull { f ->
174175
f.extension in listOf("so", "dylib", "dll")
@@ -177,7 +178,7 @@ class KotlinNativeExportPlugin : Plugin<Project> {
177178
val destDir = nativeLibResourceDir.get().asFile.resolve("kne/native/$platform")
178179
destDir.mkdirs()
179180
nativeFile.copyTo(destDir.resolve(nativeFile.name), overwrite = true)
180-
project.logger.lifecycle("kne: Bundled ${nativeFile.name} → kne/native/$platform/")
181+
task.logger.lifecycle("kne: Bundled ${nativeFile.name} → kne/native/$platform/")
181182
}
182183
}
183184
}

0 commit comments

Comments
 (0)