Skip to content

Commit

Permalink
add new tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanck committed Jan 16, 2025
1 parent 29b1b3d commit 06578fe
Showing 1 changed file with 31 additions and 11 deletions.
42 changes: 31 additions & 11 deletions license.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,37 @@

apply plugin: "com.github.jk1.dependency-license-report"

check.dependsOn generateLicenseReport
tasks.register('compareLicenseReport') {
doLast {
File licenseFile = new File("${projectDir}/build/reports/dependency-license/LICENSE")
File currentLicenseFile = new File("${projectDir}/LICENSE")
if (licenseFile.text != currentLicenseFile.text) {
throw new RuntimeException("License file has changed");
}

File noticeFile = new File("${projectDir}/build/reports/dependency-license/NOTICE")
File currentNoticeFile = new File("${projectDir}/NOTICE")
if (noticeFile.text != currentNoticeFile.text) {
throw new RuntimeException("Notice file has changed");
}
}
}

tasks.register('updateLicenseReport') {
doLast {
File licenseFile = new File("${projectDir}/LICENSE")
File currentLicenseFile = new File("${projectDir}/build/reports/dependency-license/LICENSE")
currentLicenseFile.text = licenseFile.text

File noticeFile = new File("${projectDir}/NOTICE")
File currentNoticeFile = new File("${projectDir}/build/reports/dependency-license/NOTICE")
currentNoticeFile.text = noticeFile.text
}
}

updateLicenseReport.dependsOn generateLicenseReport
compareLicenseReport.dependsOn generateLicenseReport
check.dependsOn compareLicenseReport

import com.github.jk1.license.render.ReportRenderer
import com.github.jk1.license.ImportedModuleData
Expand Down Expand Up @@ -64,16 +94,6 @@ class IcebergReportRenderer implements ReportRenderer {
noticeFile << "\nNotice: $notice\n\n"
noticeFile << "\n--------------------------------------------------------------------------------\n\n"
}

File currentLicenseFile = new File(data.project.projectDir, 'LICENSE')
if (licenseFile.text != currentLicenseFile.text) {
throw new RuntimeException("License file has changed");
}

File currentNoticeFile = new File(data.project.projectDir, 'NOTICE')
if (noticeFile.text != currentNoticeFile.text) {
throw new RuntimeException("Notice file has changed");
}
}

private void printDependencies(ProjectData data) {
Expand Down

0 comments on commit 06578fe

Please sign in to comment.