@@ -38,9 +38,10 @@ private static InstrumentationPath parseInstrumentationPath(String filePath) {
3838 return null ;
3939 }
4040
41+ String normalized = normalizeSeparators (filePath );
4142 String instrumentationSegment = "/instrumentation/" ;
42- int startIndex = filePath .indexOf (instrumentationSegment ) + instrumentationSegment .length ();
43- String [] parts = filePath .substring (startIndex ).split ("/" );
43+ int startIndex = normalized .indexOf (instrumentationSegment ) + instrumentationSegment .length ();
44+ String [] parts = normalized .substring (startIndex ).split ("/" );
4445
4546 if (parts .length < 2 ) {
4647 return null ;
@@ -58,23 +59,28 @@ public static boolean isValidInstrumentationPath(String filePath) {
5859 if (filePath == null || filePath .isEmpty ()) {
5960 return false ;
6061 }
62+ String normalized = normalizeSeparators (filePath );
6163 String instrumentationSegment = "instrumentation/" ;
6264
63- if (!filePath .contains (instrumentationSegment )) {
65+ if (!normalized .contains (instrumentationSegment )) {
6466 return false ;
6567 }
6668
67- int javaagentCount = filePath .split ("/javaagent" , -1 ).length - 1 ;
69+ int javaagentCount = normalized .split ("/javaagent" , -1 ).length - 1 ;
6870 if (javaagentCount > 1 ) {
6971 return false ;
7072 }
7173
72- if (filePath .matches (
74+ if (normalized .matches (
7375 ".*(/test/|/testing|/build/|-common/|-common-|common-|/compile-stub/|-testing|bootstrap/src).*" )) {
7476 return false ;
7577 }
7678
77- return filePath .endsWith ("javaagent" ) || filePath .endsWith ("library" );
79+ return normalized .endsWith ("javaagent" ) || normalized .endsWith ("library" );
80+ }
81+
82+ private static String normalizeSeparators (String filePath ) {
83+ return filePath .replace ('\\' , '/' );
7884 }
7985
8086 public List <String > findBuildGradleFiles (String instrumentationDirectory ) {
@@ -85,7 +91,7 @@ public List<String> findBuildGradleFiles(String instrumentationDirectory) {
8591 .filter (
8692 path ->
8793 path .getFileName ().toString ().equals ("build.gradle.kts" )
88- && !path .toString ().contains ("/testing/" )
94+ && !normalizeSeparators ( path .toString () ).contains ("/testing/" )
8995 && !isInNestedInstrumentationModule (path , rootPath ))
9096 .map (Path ::toString )
9197 .collect (toList ());
@@ -105,13 +111,11 @@ public List<String> findBuildGradleFiles(String instrumentationDirectory) {
105111 */
106112 private static boolean isInNestedInstrumentationModule (Path filePath , Path rootPath ) {
107113 Path relativePath = rootPath .relativize (filePath );
108- String relativeStr = relativePath .toString ();
109-
110- String [] segments = relativeStr .split ("/" );
111114
112115 // Find the first javaagent or library segment
113- for (int i = 0 ; i < segments .length ; i ++) {
114- if (segments [i ].equals ("javaagent" ) || segments [i ].equals ("library" )) {
116+ for (int i = 0 ; i < relativePath .getNameCount (); i ++) {
117+ String segment = relativePath .getName (i ).toString ();
118+ if (segment .equals ("javaagent" ) || segment .equals ("library" )) {
115119 // If javaagent/library is not the first segment, it's a nested module
116120 return i > 0 ;
117121 }
0 commit comments