-
Notifications
You must be signed in to change notification settings - Fork 768
Reuse executable when no-change in project #44151
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
base: master
Are you sure you want to change the base?
Reuse executable when no-change in project #44151
Conversation
if (CommandUtil.isFilesModifiedSinceLastBuild(buildJson, project)) { | ||
return true; | ||
} | ||
if (isRebuildForCurrCmd()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AFAIU, this method checks if there are any additional flags, and if that is the case, we rebuild. Can't we rename the method to reflect that?
if (isRebuildForCurrCmd()) { | ||
return true; | ||
} | ||
return !CommandUtil.isPrevCurrCmdCompatible(project.buildOptions(), buildJson.getBuildOptions()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return !CommandUtil.isPrevCurrCmdCompatible(project.buildOptions(), buildJson.getBuildOptions()); | |
return !CommandUtil.isPrevAndCurrCmdCompatible(project.buildOptions(), buildJson.getBuildOptions()); |
if (isProjectFilesModified(buildJson, project)) { | ||
return true; | ||
} | ||
if (isSettingsFileModified(buildJson)) { | ||
return true; | ||
} | ||
return isExecutableModified(buildJson, project); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (isProjectFilesModified(buildJson, project)) { | |
return true; | |
} | |
if (isSettingsFileModified(buildJson)) { | |
return true; | |
} | |
return isExecutableModified(buildJson, project); | |
return isProjectFilesModified(buildJson, project) || isSettingsFileModified(buildJson) || isExecutableModified(buildJson, project); |
98912f8
to
b6a190b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses issue #44136 by reusing the executable when no changes occur in the project. Key changes include:
- Adding new fields and getters/setters in BuildJson to record build metadata.
- Updating BuildOptions, command implementations, and various tasks to support skipping rebuilds when no modifications are detected.
- Enhancing test coverage for build/test scenarios and adjusting task execution logic (e.g. skipTask flag).
Reviewed Changes
Copilot reviewed 26 out of 27 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
compiler/ballerina-lang/src/main/java/io/ballerina/projects/internal/model/BuildJson.java | Added new metadata fields and associated accessors. |
compiler/ballerina-lang/src/main/java/io/ballerina/projects/BuildOptions.java | Introduced a new method to retrieve locking mode. |
cli/ballerina-cli/… | Updated multiple test and command files to support skipping rebuilds and reusing executable output. |
cli/ballerina-cli/src/main/java/io/ballerina/cli/task/* | Introduced and propagated a skipTask flag to control task execution. |
cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/* | Adjusted rebuild detection and task execution logic based on file changes. |
cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/CommandUtil.java | Added SHA-256 digest computation and file modification checks for build fingerprinting. |
Comments suppressed due to low confidence (1)
cli/ballerina-cli/src/main/java/io/ballerina/cli/cmd/RunCommand.java:343
- [nitpick] It would be beneficial to add inline documentation for the isRebuildForCurrCmd() method explaining the rationale behind each condition to improve future maintainability.
}
|
||
public static String getSHA256Digest(File fileToEvaluate) throws NoSuchAlgorithmException, IOException { | ||
MessageDigest digest = MessageDigest.getInstance(SHA_256); | ||
byte[] fileBytes = Files.readAllBytes(fileToEvaluate.toPath()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider using a buffered stream (e.g., DigestInputStream) to compute the SHA-256 digest for large files instead of reading the entire file into memory.
Copilot uses AI. Check for mistakes.
if (!project.buildOptions().nativeImage()) { | ||
this.out.println("Generating executable"); | ||
this.out.println("Generating executable" + (skipTask ? "(skipped)" : "")); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The repeated pattern of checking 'skipTask' and printing '(skipped)' is seen in multiple tasks; consider abstracting this logic into a helper function to reduce duplication and improve readability.
Copilot uses AI. Check for mistakes.
eb9d49d
to
6618e4c
Compare
6618e4c
to
303d917
Compare
ee7841f
to
b5e0483
Compare
Purpose
Fixes #44136
Approach
Samples
Consecutive



bal build
,bal run
,bal test
Remarks
Check List