Skip to content
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

KspTaskNative is not configuration cacheable #1522

Closed
yigit opened this issue Sep 4, 2023 · 11 comments
Closed

KspTaskNative is not configuration cacheable #1522

yigit opened this issue Sep 4, 2023 · 11 comments
Milestone

Comments

@yigit
Copy link
Collaborator

yigit commented Sep 4, 2023

KspTaskNative is not configuration cacheable due to a problem in KonanTarget. (https://youtrack.jetbrains.com/issue/KT-61657/KonanTarget-should-implement-equals-or-custom-serialization)

This especially becomes a problem due to the onlyIf check, which always fails after a KSP task is configuration cached.

I think KSP should update its onlyIf check to find the target again from HostManager using its name until the Kotlin plugin issue is fixed (to be able to keep the task cacheable).

@PaulWoitaschek
Copy link
Contributor

I submitted a hotfix as it will probably take a while until this gets fixed upstream.

We have a build logic where we conditionally disable native targets based on gradle properties.

This leads to the situation that the ksp tasks are skipped even though they should not.
For more context, see:
https://kotlinlang.slack.com/archives/C013BA8EQSE/p1692613954005859

ting-yuan pushed a commit that referenced this issue Sep 5, 2023
github-actions bot pushed a commit that referenced this issue Sep 5, 2023
This is a workaround for #1522

(cherry picked from commit d0b972d)
@ting-yuan ting-yuan added this to the 1.0.14 milestone Sep 5, 2023
@ting-yuan
Copy link
Collaborator

ting-yuan commented Sep 5, 2023

I've merged @PaulWoitaschek's patch and it'll be available in the 1.9.10-1.0.14-SNAPSHOT tomorrow. The formal release will take a bit longer. I'm wondering if it's possible to override the Task.onlyIf check in your Gradle build scripts? E.g., Task.setOnlyIf { ... }

@yigit
Copy link
Collaborator Author

yigit commented Sep 6, 2023

I tried that but the timing is very tricky.
When I register a configure block with task type filter, gradle calls my block before KSP 😔

@PaulWoitaschek
Copy link
Contributor

PaulWoitaschek commented Sep 6, 2023

You can not override it. You can only add additional statements. Gradle will then run all onlyIf blocks. It will only run the task if all evaluate to true.

Not true

    @Override
    public void setOnlyIf(final Closure onlyIfClosure) {
        taskMutator.mutate("Task.setOnlyIf(Closure)", new Runnable() {
            @Override
            public void run() {
                onlyIfSpec = createNewOnlyIfSpec().and(onlyIfClosure, "Task satisfies onlyIf closure");
            }
        });
    }

@ting-yuan
Copy link
Collaborator

@yigit Would wrapping that around with afterEvaluate feasible?

ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Sep 11, 2023
ting-yuan pushed a commit to ting-yuan/ksp that referenced this issue Sep 11, 2023
ting-yuan pushed a commit that referenced this issue Sep 11, 2023
This is a workaround for #1522

(cherry picked from commit d0b972d)
@ting-yuan
Copy link
Collaborator

I'm going to include the patch into 1.9.20-Beta-1.0.13 and later releases so that you won't need to work it around in build scripts.

@PaulWoitaschek
Copy link
Contributor

Thanks! Is it safe to use the 1.9.20-Beta ksp version on 1.9.10?

It warns at configuration time:

ksp-1.9.20-Beta-1.0.13 is too new for kotlin-1.9.10. Please upgrade kotlin-gradle-plugin to 1.9.20-Beta.

@ting-yuan
Copy link
Collaborator

Unfortunately, no. It is built for Kotlin 1.9.20-Beta and there may be some incompatibilities to 1.9.10.

@PaulWoitaschek
Copy link
Contributor

@ting-yuan
Can we get a release for 1.9.10? I'd really make use of config cache for our project.

@ting-yuan
Copy link
Collaborator

Do you really need Kotlin 1.9.10, or will Kotlin 1.9.20 be OK? IIUC 1.9.20 will be out very soon and KSP 1.9.20-1.0.14 will follow very closely after that.

@PaulWoitaschek
Copy link
Contributor

As compose often times takes a bit longer we'd love a .10 version.

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

No branches or pull requests

3 participants