Skip to content

Use flatMap instead of map to make the getSharedObjectFilesProvider depend on the outputs of merge[Variant]NativeLibs#2120

Merged
priettt merged 1 commit intomainfrom
priettt/mergeNativeLibTaskFix
Apr 25, 2025
Merged

Use flatMap instead of map to make the getSharedObjectFilesProvider depend on the outputs of merge[Variant]NativeLibs#2120
priettt merged 1 commit intomainfrom
priettt/mergeNativeLibTaskFix

Conversation

@priettt
Copy link
Contributor

@priettt priettt commented Apr 24, 2025

Goal

Using flatMap wires a dependency between the result and the outputs of the mergeNativeLibs task.

Using map doesn't do that, so I think that's why the provider was realized before the outputs where available, causing the exception:

* What went wrong:
  Configuration cache state could not be cached: field `architecturesDirectory` of task `:app:compressSharedObjectFilesRelease` of type `io.embrace.android.gradle.plugin.tasks.ndk.CompressSharedObjectFilesTask`: error writing value of type 'org.gradle.api.internal.file.DefaultFilePropertyFactory$DefaultDirectoryVar'
> Shared object file not found

Also use elements.map so we don't resolve the task output files too early.

Testing

Tested manually: now the example app builds correctly. We will add additional configuration cache testing later.

@priettt priettt requested a review from a team as a code owner April 24, 2025 22:44
@github-actions
Copy link
Contributor

github-actions bot commented Apr 24, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Member

@fractalwrench fractalwrench left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM once failing tests on CI are addressed

fun `an error is thrown when merge native libs task is not found`() {
// Given a project where merge native libs task is not registered
val projectTypeProvider = project.provider { ProjectType.UNITY }
val projectTypeProvider = project.provider { ProjectType.NATIVE }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this change necessary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh not at all, I thought I removed that change sorry

@priettt priettt force-pushed the priettt/mergeNativeLibTaskFix branch 2 times, most recently from 2c26280 to 5e24665 Compare April 25, 2025 13:58
…epend on the outputs of merge[Variant]NativeLibs
@priettt priettt force-pushed the priettt/mergeNativeLibTaskFix branch from 5e24665 to 4cb22b3 Compare April 25, 2025 14:56
@priettt priettt merged commit 71fe19c into main Apr 25, 2025
11 checks passed
@priettt priettt deleted the priettt/mergeNativeLibTaskFix branch April 25, 2025 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants