diff --git a/.github/workflows/build-common.yml b/.github/workflows/build-common.yml index 3e2f57d8bb..f9b1f519c5 100644 --- a/.github/workflows/build-common.yml +++ b/.github/workflows/build-common.yml @@ -64,16 +64,15 @@ jobs: run: | # add any untracked folders that may have been added by generateLicenseReport git add licenses - # there's always going to one line difference due to the timestamp included in the report - if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]] + if git diff --cached --quiet licenses then echo "Licenses are up-to-date." else echo "Licenses are not up-to-date, please run './gradlew generateLicenseReport' locally and commit." echo - echo "$(git diff --cached --stat licenses)" + git diff --cached --stat licenses echo - echo "$(git diff --cached licenses)" + git diff --cached licenses exit 1 fi diff --git a/.github/workflows/pull-request-helper.yml b/.github/workflows/pull-request-helper.yml index b26be60ece..9b5cddfbc1 100644 --- a/.github/workflows/pull-request-helper.yml +++ b/.github/workflows/pull-request-helper.yml @@ -44,11 +44,7 @@ jobs: run: | ./gradlew generateLicenseReport git add licenses - # there's always going to one line difference due to the timestamp included in the report - if [[ $(git diff --cached --shortstat licenses) == " 1 file changed, 1 insertion(+), 1 deletion(-)" ]] - then - git reset HEAD licenses - git checkout -- licenses + if git diff --cached --quiet; then exit 0 # success fi git commit -m "./gradlew generateLicenseReport" diff --git a/agent/agent/build.gradle.kts b/agent/agent/build.gradle.kts index 2b581da58b..af183ae0f4 100644 --- a/agent/agent/build.gradle.kts +++ b/agent/agent/build.gradle.kts @@ -1,6 +1,7 @@ import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar import com.github.jk1.license.filter.LicenseBundleNormalizer import com.github.jk1.license.render.InventoryMarkdownReportRenderer +import java.nio.charset.StandardCharsets plugins { id("com.github.jk1.dependency-license-report") @@ -169,6 +170,22 @@ tasks { named("generateLicenseReport").configure { dependsOn(cleanLicenses) finalizedBy(":spotlessApply") + doLast { + val reportFile = rootProject.file("licenses/more-licenses.md") + if (reportFile.exists()) { + val reportContents = reportFile.readText(StandardCharsets.UTF_8) + val normalizedReportContents = + reportContents.replace( + Regex( + """(?m)(^## Dependency License Report\r?\n)_\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}[^\r\n]*_\r?\n""" + ), + "$1", + ) + if (normalizedReportContents != reportContents) { + reportFile.writeText(normalizedReportContents, StandardCharsets.UTF_8) + } + } + } // disable licence report generation unless this task is explicitly run // the files produced by this task are used by other tasks without declaring them as dependency // which gradle considers an error diff --git a/licenses/more-licenses.md b/licenses/more-licenses.md index 1db73bfc19..7a64a6bd82 100644 --- a/licenses/more-licenses.md +++ b/licenses/more-licenses.md @@ -1,7 +1,6 @@ # agent ## Dependency License Report -_2026-07-29 22:55:05 UTC_ ## Apache License, Version 2.0 **1** **Group:** `com.fasterxml.jackson.core` **Name:** `jackson-annotations` **Version:** `2.22`