mirror of
https://github.com/ysoftdevs/DependencyCheck.git
synced 2026-03-20 00:04:27 +01:00
cleaned up code duplication
Former-commit-id: 27896a50114fcee9f2aaeb21915b91b4a198f328
This commit is contained in:
@@ -604,38 +604,7 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence());
|
addMatchingValues(classes, trimmedDescription, dependency.getProductEvidence());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
extractLicense(pom, pomProperties, dependency);
|
||||||
//license
|
|
||||||
if (pom.getLicenses() != null) {
|
|
||||||
String license = null;
|
|
||||||
for (License lic : pom.getLicenses().getLicense()) {
|
|
||||||
String tmp = null;
|
|
||||||
if (lic.getName() != null) {
|
|
||||||
tmp = interpolateString(lic.getName(), pomProperties);
|
|
||||||
}
|
|
||||||
if (lic.getUrl() != null) {
|
|
||||||
if (tmp == null) {
|
|
||||||
tmp = interpolateString(lic.getUrl(), pomProperties);
|
|
||||||
} else {
|
|
||||||
tmp += ": " + interpolateString(lic.getUrl(), pomProperties);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (tmp == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (HTML_DETECTION_PATTERN.matcher(tmp).find()) {
|
|
||||||
tmp = Jsoup.parse(tmp).text();
|
|
||||||
}
|
|
||||||
if (license == null) {
|
|
||||||
license = tmp;
|
|
||||||
} else {
|
|
||||||
license += "\n" + tmp;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (license != null) {
|
|
||||||
dependency.setLicense(license);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return foundSomething;
|
return foundSomething;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1250,7 +1219,17 @@ public class JarAnalyzer extends AbstractAnalyzer implements Analyzer {
|
|||||||
addDescription(dependency, description, "pom", "description");
|
addDescription(dependency, description, "pom", "description");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
extractLicense(pom, pomProperties, dependency);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts the license information from the pom and adds it to the dependency.
|
||||||
|
*
|
||||||
|
* @param pom the pom object
|
||||||
|
* @param pomProperties the properties, used for string interpolation
|
||||||
|
* @param dependency the dependency to add license information too
|
||||||
|
*/
|
||||||
|
private void extractLicense(Model pom, Properties pomProperties, Dependency dependency) {
|
||||||
//license
|
//license
|
||||||
if (pom.getLicenses() != null) {
|
if (pom.getLicenses() != null) {
|
||||||
String license = null;
|
String license = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user