Skip to content

Commit

Permalink
Update quickstart example with a bug fix.
Browse files Browse the repository at this point in the history
Signed-off-by: Rahul Krishna <[email protected]>
  • Loading branch information
rahlk committed Feb 3, 2025
1 parent 231e40a commit 86c5bca
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/ibm/cldk/utils/BuildProject.java
Original file line number Diff line number Diff line change
Expand Up @@ -274,14 +274,14 @@ public static void cleanLibraryDependencies() {
Files.walk(libDownloadPath).filter(Files::isRegularFile).map(Path::toFile).forEach(File::delete);
Files.delete(libDownloadPath);
} catch (IOException e) {
Log.error("Error deleting library dependency directory: " + e.getMessage());
Log.warn("Unable to fully delete library dependency directory: " + e.getMessage());
}
}
if (tempInitScript != null) {
try {
Files.delete(tempInitScript);
} catch (IOException e) {
Log.error("Error deleting temporary Gradle init script: " + e.getMessage());
Log.warn("Error deleting temporary Gradle init script: " + e.getMessage());
}
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/main/java/com/ibm/cldk/utils/ProjectDirectoryScanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

public class ProjectDirectoryScanner {
public static List<Path> classFilesStream(String projectPath) throws IOException {
Expand Down Expand Up @@ -37,6 +39,30 @@ public static List<Path> jarFilesStream(String projectPath) throws IOException {
return null;
}

/**
* Returns a stream of class files inside the jars and class files in the project.
* @param projectPath
* @return
* @throws IOException
*/
public static Stream<String> classesFromJarFileStream(String projectPath) throws IOException {
List<Path> jarPaths = jarFilesStream(projectPath);

if (jarPaths == null) {
return Stream.empty();
}

return jarPaths.stream().flatMap(jarPath -> {
try (ZipFile zip = new ZipFile(jarPath.toFile())) {
return zip.stream()
.filter(entry -> !entry.isDirectory() && entry.getName().endsWith(".class"))
.map(ZipEntry::getName);
} catch (IOException e) {
return Stream.empty();
}
});
}

public static List<Path> sourceFilesStream(String projectPath) throws IOException {
Path projectDir = Paths.get(projectPath);
Log.info("Finding *.java files in " + projectDir);
Expand Down

0 comments on commit 86c5bca

Please sign in to comment.