Skip to content

Commit

Permalink
jk1#322 introduce unionParentPomLicensesWhenLicenseNotFound property …
Browse files Browse the repository at this point in the history
…to allow to disable parent merging completely.
  • Loading branch information
AlexanderBartash committed Oct 10, 2024
1 parent 59c1388 commit ec09def
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ licenseReport {
// Defaults to: true
unionParentPomLicenses = false
// If we didn't find a license in the root pom, by default, then parent pom always applies (if it has one),
// even if unionParentPomLicenses is false. This property allows to disable that as well.
unionParentPomLicensesWhenLicenseNotFound = false
// Set output directory for the report data.
// Defaults to ${project.buildDir}/reports/dependency-license.
outputDir = project.layout.buildDirectory.dir("licenses").get().asFile.path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class LicenseReportExtension {
public static final String[] ALL = []

public boolean unionParentPomLicenses
public boolean unionParentPomLicensesWhenLicenseNotFound
public String outputDir
public Project[] projects
public ReportRenderer[] renderers
Expand All @@ -44,6 +45,7 @@ class LicenseReportExtension {

LicenseReportExtension(Project project) {
unionParentPomLicenses = true
unionParentPomLicensesWhenLicenseNotFound = true
outputDir = project.layout.buildDirectory.dir("reports/dependency-license").get().asFile.absolutePath
projects = [project] + project.subprojects
renderers = new SimpleHtmlReportRenderer()
Expand Down
18 changes: 10 additions & 8 deletions src/main/groovy/com/github/jk1/license/reader/PomReader.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -251,14 +251,16 @@ class PomReader {
}
}
// If we didn't find a license in the root pom, then parent pom always applies (if it has one)
if ( !pomData.licenses ) {
childPoms.each { pom ->
pom.licenses?.license?.each { GPathResult license ->
LOGGER.debug("Processing license: ${license.name.text()}")
pomData.licenses << new License(
name: license.name?.text(),
url: license.url?.text()
)
if (config.unionParentPomLicensesWhenLicenseNotFound) {
if (!pomData.licenses) {
childPoms.each { pom ->
pom.licenses?.license?.each { GPathResult license ->
LOGGER.debug("Processing license: ${license.name.text()}")
pomData.licenses << new License(
name: license.name?.text(),
url: license.url?.text()
)
}
}
}
}
Expand Down

0 comments on commit ec09def

Please sign in to comment.