Source:
private Multimap<String, IncludedDependency> parseModulesFromBuildResult(File buildResult) throws IOException { Multimap<String, IncludedDependency> result = ArrayListMultimap.create(); try (BufferedReader br = new BufferedReader(new FileReader(buildResult))) { String line; String currentShadeModule = null; String currentDependencyCopyModule = null; while ((line = br.readLine()) != null) { Matcher nextShadeModuleMatcher = SHADE_NEXT_MODULE_PATTERN.matcher(line); if (nextShadeModuleMatcher.find()) { currentShadeModule = nextShadeModuleMatcher.group(2); } Matcher nextDependencyCopyModuleMatcher = DEPENDENCY_COPY_NEXT_MODULE_PATTERN.matcher(line); if (nextDependencyCopyModuleMatcher.find()) { currentDependencyCopyModule = nextDependencyCopyModuleMatcher.group(1); } if (currentShadeModule != null) { Matcher includeMatcher = SHADE_INCLUDE_MODULE_PATTERN.matcher(line); if (includeMatcher.find()) { String groupId = includeMatcher.group(1); String artifactId = includeMatcher.group(2); String version = includeMatcher.group(3); if (!"org.apache.flink".equals(groupId)) { result.put(currentShadeModule, IncludedDependency.create(groupId, artifactId, version)); } } } if (currentDependencyCopyModule != null) { Matcher copyMatcher = DEPENDENCY_COPY_INCLUDE_MODULE_PATTERN.matcher(line); if (copyMatcher.find()) { String groupId = copyMatcher.group(1); String artifactId = copyMatcher.group(2); String version = copyMatcher.group(3); if (!"org.apache.flink".equals(groupId)) { result.put(currentDependencyCopyModule, IncludedDependency.create(groupId, artifactId, version)); } } } if (line.contains("Replacing original artifact with shaded artifact")) { currentShadeModule = null; } if (line.contains("Copying")) { currentDependencyCopyModule = null; } } } return result; }

Target:
private static Multimap<String, IncludedDependency> parseModulesFromBuildResult(File buildResult) throws IOException { Multimap<String, IncludedDependency> result = ArrayListMultimap.create(); try (Stream<String> lines = Files.lines(buildResult.toPath())) { String currentShadeModule = null; String currentDependencyCopyModule = null; for (String line : (Iterable<String>) lines::iterator) { Matcher nextShadeModuleMatcher = SHADE_NEXT_MODULE_PATTERN.matcher(line); if (nextShadeModuleMatcher.find()) { currentShadeModule = nextShadeModuleMatcher.group(2); } Matcher nextDependencyCopyModuleMatcher = DEPENDENCY_COPY_NEXT_MODULE_PATTERN.matcher(line); if (nextDependencyCopyModuleMatcher.find()) { currentDependencyCopyModule = nextDependencyCopyModuleMatcher.group(1); } if (currentShadeModule != null) { Matcher includeMatcher = SHADE_INCLUDE_MODULE_PATTERN.matcher(line); if (includeMatcher.find()) { String groupId = includeMatcher.group(1); String artifactId = includeMatcher.group(2); String version = includeMatcher.group(3); if (!"org.apache.flink".equals(groupId)) { result.put(currentShadeModule, IncludedDependency.create(groupId, artifactId, version)); } } } if (currentDependencyCopyModule != null) { Matcher copyMatcher = DEPENDENCY_COPY_INCLUDE_MODULE_PATTERN.matcher(line); if (copyMatcher.find()) { String groupId = copyMatcher.group(1); String artifactId = copyMatcher.group(2); String version = copyMatcher.group(3); if (!"org.apache.flink".equals(groupId)) { result.put(currentDependencyCopyModule, IncludedDependency.create(groupId, artifactId, version)); } } } if (line.contains("Replacing original artifact with shaded artifact")) { currentShadeModule = null; } if (line.contains("Copying")) { currentDependencyCopyModule = null; } } } return result; }