File tree Expand file tree Collapse file tree 2 files changed +28
-2
lines changed
src/main/java/com/ibm/cldk/utils Expand file tree Collapse file tree 2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -274,14 +274,14 @@ public static void cleanLibraryDependencies() {
274274 Files .walk (libDownloadPath ).filter (Files ::isRegularFile ).map (Path ::toFile ).forEach (File ::delete );
275275 Files .delete (libDownloadPath );
276276 } catch (IOException e ) {
277- Log .error ( "Error deleting library dependency directory: " + e .getMessage ());
277+ Log .warn ( "Unable to fully delete library dependency directory: " + e .getMessage ());
278278 }
279279 }
280280 if (tempInitScript != null ) {
281281 try {
282282 Files .delete (tempInitScript );
283283 } catch (IOException e ) {
284- Log .error ("Error deleting temporary Gradle init script: " + e .getMessage ());
284+ Log .warn ("Error deleting temporary Gradle init script: " + e .getMessage ());
285285 }
286286 }
287287 }
Original file line number Diff line number Diff line change 77import java .util .List ;
88import java .util .stream .Collectors ;
99import java .util .stream .Stream ;
10+ import java .util .zip .ZipEntry ;
11+ import java .util .zip .ZipFile ;
1012
1113public class ProjectDirectoryScanner {
1214 public static List <Path > classFilesStream (String projectPath ) throws IOException {
@@ -37,6 +39,30 @@ public static List<Path> jarFilesStream(String projectPath) throws IOException {
3739 return null ;
3840 }
3941
42+ /**
43+ * Returns a stream of class files inside the jars and class files in the project.
44+ * @param projectPath
45+ * @return
46+ * @throws IOException
47+ */
48+ public static Stream <String > classesFromJarFileStream (String projectPath ) throws IOException {
49+ List <Path > jarPaths = jarFilesStream (projectPath );
50+
51+ if (jarPaths == null ) {
52+ return Stream .empty ();
53+ }
54+
55+ return jarPaths .stream ().flatMap (jarPath -> {
56+ try (ZipFile zip = new ZipFile (jarPath .toFile ())) {
57+ return zip .stream ()
58+ .filter (entry -> !entry .isDirectory () && entry .getName ().endsWith (".class" ))
59+ .map (ZipEntry ::getName );
60+ } catch (IOException e ) {
61+ return Stream .empty ();
62+ }
63+ });
64+ }
65+
4066 public static List <Path > sourceFilesStream (String projectPath ) throws IOException {
4167 Path projectDir = Paths .get (projectPath );
4268 Log .info ("Finding *.java files in " + projectDir );
You can’t perform that action at this time.
0 commit comments