102102import static io .ballerina .projects .util .ProjectConstants .BAL_TOOL_JSON ;
103103import static io .ballerina .projects .util .ProjectConstants .BAL_TOOL_TOML ;
104104import static io .ballerina .projects .util .ProjectConstants .BLANG_SOURCE_EXT ;
105+ import static io .ballerina .projects .util .ProjectConstants .CLOUD_TOML ;
105106import static io .ballerina .projects .util .ProjectConstants .DEPENDENCIES_TOML ;
106107import static io .ballerina .projects .util .ProjectConstants .DEPENDENCY_GRAPH_JSON ;
107108import static io .ballerina .projects .util .ProjectConstants .EXEC_BACKUP_DIR_NAME ;
@@ -1340,7 +1341,11 @@ public static boolean isFilesModifiedSinceLastBuild(BuildJson buildJson, Project
13401341 if (isSettingsFileModified (buildJson )) {
13411342 return true ;
13421343 }
1343- if (isBallerinaTomlFileModified (buildJson , project )) {
1344+ if (isTomlFileModified (buildJson .getBallerinaTomlMetaInfo (),
1345+ project .sourceRoot ().resolve (BALLERINA_TOML ).toFile ())) {
1346+ return true ;
1347+ }
1348+ if (isTomlFileModified (buildJson .getCloudTomlMetaInfo (), project .sourceRoot ().resolve (CLOUD_TOML ).toFile ())) {
13441349 return true ;
13451350 }
13461351 if (isTestExecution ) {
@@ -1366,21 +1371,20 @@ public static DependencyGraph<BuildProject> resolveWorkspaceDependencies(
13661371 return projectDependencyGraph ;
13671372 }
13681373
1369- private static boolean isBallerinaTomlFileModified (BuildJson buildJson , Project project ) {
1374+ private static boolean isTomlFileModified (BuildJson .FileMetaInfo tomlFileMetaInfo , File tomlFile ) {
1375+ if (tomlFileMetaInfo == null ) {
1376+ // No Cloud.toml in the project
1377+ return tomlFile .exists ();
1378+ }
13701379 try {
1371- File ballerinaTomlFile = project .sourceRoot ().resolve (BALLERINA_TOML ).toFile ();
1372- if (ballerinaTomlFile .exists () && ballerinaTomlFile .isFile ()) {
1373- long lastModified = ballerinaTomlFile .lastModified ();
1374- long size = Files .size (ballerinaTomlFile .toPath ());
1375- BuildJson .FileMetaInfo ballerinaTomlFileMetaInfo = buildJson .getBallerinaTomlMetaInfo ();
1376- if (ballerinaTomlFileMetaInfo == null ) {
1377- return true ;
1378- }
1379- if (ballerinaTomlFileMetaInfo .getSize () == size &&
1380- ballerinaTomlFileMetaInfo .getLastModifiedTime () == lastModified ) {
1380+ if (tomlFile .exists () && tomlFile .isFile ()) {
1381+ long lastModified = tomlFile .lastModified ();
1382+ long size = Files .size (tomlFile .toPath ());
1383+ if (tomlFileMetaInfo .getSize () == size &&
1384+ tomlFileMetaInfo .getLastModifiedTime () == lastModified ) {
13811385 return false ;
13821386 }
1383- return !getSHA256Digest (ballerinaTomlFile ).equals (ballerinaTomlFileMetaInfo .getHash ());
1387+ return !getSHA256Digest (tomlFile ).equals (tomlFileMetaInfo .getHash ());
13841388 }
13851389 return true ;
13861390 } catch (IOException | NoSuchAlgorithmException e ) {
0 commit comments