@@ -10,7 +10,9 @@ pub enum AspectError {
1010 Utf8Error ( #[ from] std:: string:: FromUtf8Error ) ,
1111}
1212
13- const ASPECT_DIR_NAME : & str = ".bazel-jdt/aspects" ;
13+ fn aspect_dir_name ( ) -> String {
14+ crate :: internal_config:: aspects_dir ( )
15+ }
1416const VERSION_FILE : & str = ".version" ;
1517
1618const ASPECT_BUILD : & str = "" ;
@@ -113,7 +115,8 @@ pub fn version_hash(bazel_major: u32) -> String {
113115/// what's already on disk. Returns the workspace-relative Bazel aspect label.
114116pub fn extract_if_needed ( workspace_root : & Path , bazel_path : & str ) -> Result < String , AspectError > {
115117 let bazel_major = detect_bazel_major_version ( bazel_path) ;
116- let aspect_dir = workspace_root. join ( ASPECT_DIR_NAME ) ;
118+ let dir_name = aspect_dir_name ( ) ;
119+ let aspect_dir = workspace_root. join ( & dir_name) ;
117120 let version_path = aspect_dir. join ( VERSION_FILE ) ;
118121 let current_hash = version_hash ( bazel_major) ;
119122
@@ -146,7 +149,7 @@ pub fn extract_if_needed(workspace_root: &Path, bazel_path: &str) -> Result<Stri
146149
147150 let label = format ! (
148151 "//{}:intellij_info_bundled.bzl%intellij_info_aspect" ,
149- ASPECT_DIR_NAME
152+ dir_name
150153 ) ;
151154 Ok ( label)
152155}
@@ -156,18 +159,20 @@ pub fn extract_if_needed(workspace_root: &Path, bazel_path: &str) -> Result<Stri
156159pub fn check_bazelignore ( workspace_root : & Path ) -> Option < String > {
157160 let bazelignore_path = workspace_root. join ( ".bazelignore" ) ;
158161 let contents = fs:: read_to_string ( & bazelignore_path) . ok ( ) ?;
162+ let base_dir = crate :: internal_config:: base_dir ( ) ;
163+ let dir_name = aspect_dir_name ( ) ;
159164
160165 for line in contents. lines ( ) {
161166 let line = line. trim ( ) ;
162167 if line. is_empty ( ) || line. starts_with ( '#' ) {
163168 continue ;
164169 }
165- if line == ".bazel-jdt" || line == ".bazel-jdt/" || line == ".bazel-jdt /**" || line == "/" {
170+ if line == base_dir || line == format ! ( "{}/" , base_dir ) || line == format ! ( "{} /**", base_dir ) || line == "/" {
166171 return Some ( format ! (
167172 "Aspect directory '{}' is covered by .bazelignore \
168173 (pattern: '{}') — aspects may not be found by Bazel. \
169174 Please remove this pattern from .bazelignore.",
170- ASPECT_DIR_NAME , line
175+ dir_name , line
171176 ) ) ;
172177 }
173178 }
@@ -201,9 +206,9 @@ mod tests {
201206 let label = extract_if_needed ( tmp. path ( ) , "bazel" ) . unwrap ( ) ;
202207
203208 assert ! ( label. contains( "intellij_info_bundled.bzl%intellij_info_aspect" ) ) ;
204- assert ! ( label. starts_with( "//.bazel-jdt/aspects :intellij_info_bundled.bzl" ) ) ;
209+ assert ! ( label. starts_with( & format! ( "//{} :intellij_info_bundled.bzl" , aspect_dir_name ( ) ) ) ) ;
205210
206- let aspect_dir = tmp. path ( ) . join ( ASPECT_DIR_NAME ) ;
211+ let aspect_dir = tmp. path ( ) . join ( aspect_dir_name ( ) ) ;
207212 assert ! ( aspect_dir. join( "BUILD" ) . exists( ) ) ;
208213 assert ! ( aspect_dir. join( "intellij_info_bundled.bzl" ) . exists( ) ) ;
209214 assert ! ( aspect_dir. join( "intellij_info_impl_bundled.bzl" ) . exists( ) ) ;
@@ -223,7 +228,7 @@ mod tests {
223228 let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
224229 extract_if_needed ( tmp. path ( ) , "bazel" ) . unwrap ( ) ;
225230
226- let version_path = tmp. path ( ) . join ( ASPECT_DIR_NAME ) . join ( VERSION_FILE ) ;
231+ let version_path = tmp. path ( ) . join ( aspect_dir_name ( ) ) . join ( VERSION_FILE ) ;
227232 std:: thread:: sleep ( std:: time:: Duration :: from_millis ( 10 ) ) ;
228233
229234 extract_if_needed ( tmp. path ( ) , "bazel" ) . unwrap ( ) ;
@@ -235,7 +240,7 @@ mod tests {
235240 #[ test]
236241 fn test_extract_updates_when_version_differs ( ) {
237242 let tmp = tempfile:: tempdir ( ) . unwrap ( ) ;
238- let aspect_dir = tmp. path ( ) . join ( ASPECT_DIR_NAME ) ;
243+ let aspect_dir = tmp. path ( ) . join ( aspect_dir_name ( ) ) ;
239244
240245 extract_if_needed ( tmp. path ( ) , "bazel" ) . unwrap ( ) ;
241246
0 commit comments