private Collection < String > findTargetFolders ( String folderPath ) { logger . debug ( "Scanning target folder {}" , folderPath ) ; Cli cli = new Cli ( ) ; List < String > lines ; List < String > targetFolders = new LinkedList <> ( ) ; lines = cli . runCmd ( folderPath , cli . getCommandParams ( SBT , TARGET ) ) ; if ( lines != null && ! lines . isEmpty ( ) ) { for ( String line : lines ) { if ( DependencyCollector . isWindows ( ) ) { if ( line . endsWith ( TARGET ) && line . contains ( fileSeparator ) ) { String [ ] split = line . split ( windowsPattern ) ; targetFolders . add ( split [ 1 ] ) ; } } else { if ( line . contains ( TARGET ) && line . contains ( fileSeparator ) ) { Matcher matcher = linuxPattern . matcher ( line ) ; if ( matcher . find ( ) ) { targetFolders . add ( matcher . group ( 0 ) ) ; } } } } for ( int i = 0 ; i < targetFolders . size ( ) ; i ++ ) { String targetFolder = targetFolders . get ( i ) ; Path path = Paths . get ( targetFolder ) ; if ( ! Files . exists ( path ) ) { targetFolders . remove ( targetFolder ) ; logger . warn ( "The target folder {} path doesn't exist" , sbtTargetFolder ) ; } } } return targetFolders ; }
Trying to get all the paths of target folders