@@ -20,9 +20,17 @@ abstract class CdlObject extends JsonObject {
2020 // performed and `.cds.json` files are stored in that base project directory. The
2121 // `$location` values in the generated JSON data are, therefore, relative to the
2222 // base directory of the project.
23+ //
24+ // Note: On Windows, `getAbsolutePath()` returns backslash-separated paths, but
25+ // `$location.file` values in `.cds.json` always use forward slashes (POSIX).
26+ // We normalize backslashes to forward slashes to ensure cross-platform compatibility.
2327 path =
24- locValue .getJsonFile ( ) .getParentContainer ( ) .getAbsolutePath ( ) .regexpReplaceAll ( "/$" , "" ) +
25- "/" + locValue .getPropValue ( "file" ) .getStringValue ( ) and
28+ locValue
29+ .getJsonFile ( )
30+ .getParentContainer ( )
31+ .getAbsolutePath ( )
32+ .replaceAll ( "\\" , "/" )
33+ .regexpReplaceAll ( "/$" , "" ) + "/" + locValue .getPropValue ( "file" ) .getStringValue ( ) and
2634 if
2735 not exists ( locValue .getPropValue ( "line" ) ) and
2836 not exists ( locValue .getPropValue ( "col" ) )
@@ -167,11 +175,15 @@ class CdlService extends CdlElement {
167175 exists ( JsonValue jsonFileLocation |
168176 jsonFileLocation = this .getPropValue ( "$location" ) .getPropValue ( "file" )
169177 |
170- result .getFile ( ) .getAbsolutePath ( ) .regexpReplaceAll ( "\\.[^.]+$" , ".cds" ) =
178+ // Normalize backslashes to forward slashes for cross-platform compatibility.
179+ // On Windows, `getAbsolutePath()` returns backslash-separated paths, but
180+ // `$location.file` values in `.cds.json` always use forward slashes (POSIX).
181+ result .getFile ( ) .getAbsolutePath ( ) .replaceAll ( "\\" , "/" ) .regexpReplaceAll ( "\\.[^.]+$" , ".cds" ) =
171182 jsonFileLocation
172183 .getJsonFile ( )
173184 .getParentContainer ( )
174185 .getAbsolutePath ( )
186+ .replaceAll ( "\\" , "/" )
175187 .regexpReplaceAll ( "/$" , "" ) + "/" + jsonFileLocation .getStringValue ( )
176188 )
177189 }
0 commit comments