in build-tools/src/main/java/co/elastic/otel/android/compilation/tools/tasks/subprojects/NoticeFilesCollectorTask.java [91:112]
private boolean extractNoticeFromJar(ResolvedArtifactResult jarArtifact) {
try {
ZipFile zipFile = new ZipFile(jarArtifact.getFile());
Enumeration<? extends ZipEntry> entries = zipFile.entries();
while (entries.hasMoreElements()) {
ZipEntry zipEntry = entries.nextElement();
if (NOTICE_FILE_NAME_PATTERN.matcher(zipEntry.getName()).matches()) {
String fileName = jarArtifact.getId().getComponentIdentifier().getDisplayName().replaceAll(":", "..");
File outputFile = getOutputDir().file(fileName).get().getAsFile();
InputStream inputStream = zipFile.getInputStream(zipEntry);
Files.copy(inputStream, outputFile.toPath());
inputStream.close();
zipFile.close();
return true;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
return false;
}