ballerina-platform / ballerina-lang

The Ballerina Programming Language
https://ballerina.io/
Apache License 2.0
3.58k stars 738 forks source link

[Task]: Improve the caching of lang gradle build #43066

Open azinneera opened 2 months ago

azinneera commented 2 months ago

Description

Right now, the caching in the gradle build seems to be suboptimal. I could notice that some unchanged modules are building. For example, all the lang library builds are running even when no changes are done. This could be due to inputs and outputs of the build not being properly configured. We need to check and optimize this.

Describe your task(s)

No response

Related area

-> Other Area

Related issue(s) (optional)

No response

Suggested label(s) (optional)

No response

Suggested assignee(s) (optional)

No response

Shadow-Devil commented 2 months ago

Hi, I looked into it and for me the problem was that the jvmArgumentProviders inside the BallerinaLangLibBuildTask which is inherited from the JavaExec task is considered for up-to-date checking. image

To fix this, I used the same technique as in the Gradle docs, where they overwrite the getter method and mark it explicitly as @Interal to exclude it from up-to-date checking.

    @Override @Internal
    List<CommandLineArgumentProvider> getJvmArgumentProviders() {
        return super.getJvmArgumentProviders()
    }

Reference: https://docs.gradle.org/current/userguide/build_cache.html#using_annotations

I will create a PR where I include this fix.

azinneera commented 2 months ago

Thank you for looking into this @Shadow-Devil . We will review the PR.