in build-tools/src/main/java/co/elastic/otel/android/compilation/tools/tasks/subprojects/PomLicensesCollectorTask.java [102:129]
private List<ArtifactLicense> extractLicenses(List<ResolvedArtifactResult> pomArtifacts) throws ParserConfigurationException, SAXException, IOException {
Map<String, String> manualMappedLicenses = getManualMappedLicenses();
List<ArtifactLicense> artifactLicenses = new ArrayList<>();
List<String> notFoundLicenses = new ArrayList<>();
for (ResolvedArtifactResult pomArtifact : pomArtifacts) {
String displayName = pomArtifact.getId().getComponentIdentifier().getDisplayName();
System.out.println("Searching license for " + displayName);
String licenseId;
if (manualMappedLicenses.containsKey(displayName)) {
licenseId = manualMappedLicenses.get(displayName);
} else {
licenseId = findLicenseId(pomArtifact.getFile());
}
System.out.println("Finished searching license for " + displayName + ", found: " + licenseId);
if (licenseId != null) {
artifactLicenses.add(new ArtifactLicense(displayName, licenseId));
} else {
notFoundLicenses.add(displayName);
}
}
if (!notFoundLicenses.isEmpty()) {
throw new RuntimeException("Could not find a license in the POM file for: " + notFoundLicenses);
}
return artifactLicenses;
}