Skip to content

Commit

Permalink
🔨 Build: verify on check that all dependencies have compatible licenses
Browse files Browse the repository at this point in the history
  • Loading branch information
berlix committed Jul 2, 2024
1 parent e873042 commit 97e21a2
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on: push

jobs:
Build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04

steps:
- name: Set up JDK 11
Expand All @@ -14,12 +14,12 @@ jobs:

- uses: actions/checkout@v2

- name: Lint and test
run: ./gradlew ktlintCheck ktlintTestSourceSetCheck ktlintAndroidTestSourceSetCheck lintDebug testDebugUnitTest --stacktrace
- name: Lint and check
run: ./gradlew check ktlintCheck ktlintTestSourceSetCheck ktlintAndroidTestSourceSetCheck lintDebug testDebugUnitTest --stacktrace

- name: Publish test reports
- name: Publish reports
uses: actions/upload-artifact@v1
with:
name: test-reports
name: reports
path: sample-learning-app/build/reports
if: ${{ failure() }}
24 changes: 24 additions & 0 deletions sample-learning-app/allowed-licenses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"allowedLicenses": [
{ "moduleLicense": "MIT" },
{ "moduleLicense": "MIT License" },
{ "moduleLicense": "The MIT License" },

{ "moduleLicense": "BSD-2-Clause" },
{ "moduleLicense": "BSD 2-Clause" },
{ "moduleLicense": "The BSD 2-Clause License" },

{ "moduleLicense": "BSD-3-Clause" },
{ "moduleLicense": "BSD 3-Clause" },
{ "moduleLicense": "The BSD 3-Clause License" },

{ "moduleLicense": "Apache-2.0" },
{ "moduleLicense": "Apache 2.0" },
{ "moduleLicense": "The Apache Software License, Version 2.0" },
{ "moduleLicense": "The Apache License, Version 2.0" },
{ "moduleLicense": "Apache License, Version 2.0" },

{ "moduleLicense": "Zlib" },
{ "moduleLicense": "zlib License" }
]
}
16 changes: 16 additions & 0 deletions sample-learning-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ plugins {
id("org.jetbrains.kotlin.kapt")
id("dagger.hilt.android.plugin")
id("org.jlleitschuh.gradle.ktlint") version Versions.ktlintGradle
id("com.github.jk1.dependency-license-report") version "2.8"
}

val version = getAppVersion()
Expand Down Expand Up @@ -74,6 +75,21 @@ android {
}
}

licenseReport {
configurations = arrayOf("releaseRuntimeClasspath")
allowedLicensesFile = File("$projectDir/allowed-licenses.json")
}

tasks.named("checkLicense") {
// The checkLicense task does not declare this input itself, so we do it here. This ensures
// that a modification of the file causes the checkLicense task to be re-evaluated.
inputs.file("$projectDir/allowed-licenses.json")
}

tasks.named("check") {
dependsOn("checkLicense")
}

dependencies {
implementation("androidx.core:core-ktx:1.8.0")
implementation("androidx.appcompat:appcompat:1.4.2")
Expand Down

0 comments on commit 97e21a2

Please sign in to comment.