Skip to content

Commit

Permalink
[licensing] add excludes/includes properties to DSL. Fixes #417
Browse files Browse the repository at this point in the history
  • Loading branch information
aalmiray committed Nov 12, 2020
1 parent f753704 commit 5298871
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ Configures aggregate license reports on the root project.
config {
licensing {
enabled
includes
excludes
excludedSourceSets
licenses {
inherits
Expand All @@ -44,6 +46,8 @@ config {
|===
| Name | Type | Required | Default Value | Description
| enabled | boolean | no | true | Disables `org.kordamp.gradle.licensing` plugin if `false`
| includes | Set<String> | no | [] |
| excludes | Set<String> | no | [] |
| excludedSourceSets | Set<String> | no | [] |
| licenses | LicenseSet | yes | | This block maps to the `<licenses>` block in POM. +
At least one nested `license` block must be defined.
Expand Down Expand Up @@ -169,6 +173,10 @@ mapping.java:: 'SLASHSTAR_STYLE'
mapping.groovy:: 'SLASHSTAR_STYLE'
mapping.kt:: 'SLASHSTAR_STYLE'
mapping.scala:: 'SLASHSTAR_STYLE'
mapping.gradle:: 'SLASHSTAR_STYLE'
mapping.kts:: 'SLASHSTAR_STYLE'
mapping.yml:: 'SCRIPT_STYLE'
mapping.toml:: 'SCRIPT_STYLE'

The following extra properties become available to license templates

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Licensing extends AbstractFeature {
static final String PLUGIN_ID = 'org.kordamp.gradle.licensing'

final LicenseSetImpl licenses
Set<String> excludes = new LinkedHashSet<>()
Set<String> includes = new LinkedHashSet<>()
final Set<String> excludedSourceSets = new LinkedHashSet<>()

Licensing(ProjectConfigurationExtension config, Project project) {
Expand All @@ -60,6 +62,8 @@ class Licensing extends AbstractFeature {

map.excludedSourceSets = excludedSourceSets
map.licenses = licenses.toMap()
map.excludes = excludes
map.includes = includes

new LinkedHashMap<>('licensing': map)
}
Expand All @@ -72,6 +76,14 @@ class Licensing extends AbstractFeature {
ConfigureUtil.configure(action, licenses)
}

void include(String str) {
includes << str
}

void exclude(String str) {
excludes << str
}

void excludeSourceSet(String s) {
if (isNotBlank(s)) {
excludedSourceSets << s
Expand All @@ -82,6 +94,8 @@ class Licensing extends AbstractFeature {
AbstractFeature.merge(o1, o2)
CollectionUtils.merge(o1.excludedSourceSets, o2?.excludedSourceSets)
LicenseSetImpl.merge(o1.@licenses, o2?.@licenses)
o1.excludes = CollectionUtils.merge(o1.excludes, o2.excludes, false)
o1.includes = CollectionUtils.merge(o1.includes, o2.includes, false)
}

List<String> validate(ProjectConfigurationExtension extension) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,12 +312,16 @@ class LicensingPlugin extends AbstractKordampPlugin {
author = config.info.getAuthors().join(', ')
license = lic.licenseId?.spdx()
}
licenseExtension.exclude '**/*.tpl'
licenseExtension.exclude '**/*.png'
licenseExtension.exclude '**/*.gif'
licenseExtension.exclude '**/*.jpg'
licenseExtension.exclude '**/*.jpeg'
licenseExtension.exclude '**/*.json'
licenseExtension.exclude 'META-INF/services/*'
licenseExtension.exclude 'META-INF/maven/*'
licenseExtension.excludes config.licensing.excludes
licenseExtension.includes config.licensing.includes

project.tasks.withType(LicenseCheck, new Action<LicenseCheck>() {
@Override
Expand Down

0 comments on commit 5298871

Please sign in to comment.