@@ -5,8 +5,11 @@ plugins {
55 id " de.marcphilipp.nexus-publish" version " 0.3.0"
66 id " com.github.johnrengelman.shadow" version " 5.2.0"
77 id " org.cyclonedx.bom" version " 1.8.2"
8+ id ' com.github.jk1.dependency-license-report' version ' 1.17'
89}
910
11+ import com.github.jk1.license.render.TextReportRenderer
12+
1013if (project. hasProperty(' isTagTriggered' )) {
1114 version = getAbbreviatedGitVersion()
1215} else {
@@ -29,6 +32,10 @@ spotless {
2932 }
3033}
3134
35+ licenseReport {
36+ renderers = [new TextReportRenderer (' THIRD-PARTY-LICENSE.txt' )]
37+ }
38+
3239cyclonedxBom {
3340 // includeConfigs is the list of configuration names to include when generating the BOM (leave empty to include every configuration), regex is supported
3441 includeConfigs = [" runtimeClasspath" ]
@@ -102,8 +109,6 @@ allprojects {
102109 testCompile group : ' org.mockito' , name : ' mockito-junit-jupiter' , version : mockitoVersion
103110 }
104111
105- // ant.lifecycleLogLevel = AntBuilder.AntMessagePriority.VERBOSE
106-
107112 compileJava {
108113 doLast {
109114 ant. taskdef(resource : " org/aspectj/tools/ant/taskdefs/aspectjTaskdefs.properties" ,
@@ -214,12 +219,30 @@ task runCallbackWithBadRefreshToken(type: JavaExec) {
214219}
215220
216221jar {
222+ // Add the THIRD-PARTY-LICENSE to our jar
223+ // Note that in order for this to work, the file must be present
224+ // To generate it, run generateLicenseReport. However, ':generateLicenseReport' has a dependecy on `:jar`
225+ // which makes it impossible to generate and bundle the THIRD-PARTY-LICENSE in one pass.
226+ from(' build/reports/dependency-license/THIRD-PARTY-LICENSE.txt' ) {
227+ into ' META-INF/licenses'
228+ }
229+
217230 manifest {
218231 attributes(' Implementation-Title' : project. name,
219232 ' Implementation-Version' : project. version)
220233 }
221234}
222235
236+ shadowJar {
237+ // Add the THIRD-PARTY-LICENSE to our jar
238+ // Note that in order for this to work, the file must be present
239+ // To generate it, run generateLicenseReport. However, ':generateLicenseReport' has a dependecy on `:jar`
240+ // which makes it impossible to generate and bundle the THIRD-PARTY-LICENSE in one pass.
241+ from(' build/reports/dependency-license/THIRD-PARTY-LICENSE.txt' ) {
242+ into ' META-INF/licenses'
243+ }
244+ }
245+
223246dependencies {
224247 integrationTestImplementation " org.yaml:snakeyaml:$snakeYamlVersion "
225248 api " org.mongodb:mongodb-driver-sync:$mongodbDriverVersion "
0 commit comments