Skip to content

Commit 86c5bca

Browse files
committed
Update quickstart example with a bug fix.
Signed-off-by: Rahul Krishna <i.m.ralk@gmail.com>
1 parent 231e40a commit 86c5bca

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/main/java/com/ibm/cldk/utils/BuildProject.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff 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
}

src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import java.util.List;
88
import java.util.stream.Collectors;
99
import java.util.stream.Stream;
10+
import java.util.zip.ZipEntry;
11+
import java.util.zip.ZipFile;
1012

1113
public 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);

0 commit comments

Comments
 (0)