Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI][ANDR] Add Gradle plugin to check against non-permitted licenses #5

Merged
merged 7 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/android.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ jobs:
- name: Gradle capture-timber unit tests
working-directory: ./platform/jvm
run: ./gradlew capture-timber:testReleaseUnitTest --info
- name: Check Licenses for modules
working-directory: ./platform/jvm
run: ./gradlew replay:checkLicense common:checkLicense # capture:checkLicense doesn't work at the moment
- name: Instrumentation Tests
uses: reactivecircus/android-emulator-runner@f0d1ed2dcad93c7479e8b2f2226c83af54494915 # pin@v2.32
with:
Expand Down
23 changes: 23 additions & 0 deletions platform/jvm/allowed-licenses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"allowedLicenses": [
{
"moduleLicense": "Apache-2.0"
},
{
"moduleLicense": "MIT"
},
{
"moduleLicense": "ISC License",
},
{
"moduleLicense": null,
"moduleVersion": "unspecified",
"moduleName": "capture-sdk:common"
},
{
"moduleLicense": null,
"moduleVersion": "unspecified",
"moduleName": "capture-sdk:replay"
}
]
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ this is the list of allowed licenses

14 changes: 14 additions & 0 deletions platform/jvm/buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
plugins {
`kotlin-dsl`
}

repositories {
mavenCentral()
maven("https://plugins.gradle.org/m2/")
}

dependencies {
// Pulls in dependencies to be used across shared configurations via files in src/main/kotlin
// using precompiled script convention plugins: https://docs.gradle.org/current/userguide/sharing_build_logic_between_subprojects.html
implementation("com.github.jk1:gradle-license-report:2.9")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import com.github.jk1.license.filter.SpdxLicenseBundleNormalizer
import com.github.jk1.license.render.JsonReportRenderer

plugins {
id("com.github.jk1.dependency-license-report")
}

licenseReport {
configurations = arrayOf("releaseRuntimeClasspath")
allowedLicensesFile = project.rootProject.file("allowed-licenses.json")
renderers = arrayOf(JsonReportRenderer())
filters = arrayOf(SpdxLicenseBundleNormalizer())
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ here we centralize the plugin logic using gradle's precompiled convention plugins https://docs.gradle.org/current/userguide/custom_plugins.html

2 changes: 2 additions & 0 deletions platform/jvm/capture-apollo3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.detekt)

id("dependency-license-config")
}

group = "io.bitdrift"
Expand Down
2 changes: 2 additions & 0 deletions platform/jvm/capture-timber/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ plugins {
// Publish
alias(libs.plugins.dokka) // Must be applied here for publish plugin.
alias(libs.plugins.maven.publish)

id("dependency-license-config")
}

group = "io.bitdrift"
Expand Down
4 changes: 3 additions & 1 deletion platform/jvm/capture/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ plugins {
// Publish
alias(libs.plugins.dokka) // Must be applied here for publish plugin.
alias(libs.plugins.maven.publish)

id("dependency-license-config")
}

group = "io.bitdrift"
Expand All @@ -18,11 +20,11 @@ dependencies {
api(libs.kotlin.result.jvm)
api(libs.okhttp)

implementation(project(":common"))
implementation(libs.androidx.core)
implementation(libs.androidx.startup.runtime)
implementation(libs.jsr305)
implementation(libs.gson)
implementation("androidx.tracing:tracing-ktx:1.2.0")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unrelated clean-up


testImplementation(libs.junit)
testImplementation(libs.assertj.core)
Expand Down
2 changes: 2 additions & 0 deletions platform/jvm/common/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)

id("dependency-license-config")
}

android {
Expand Down
1 change: 1 addition & 0 deletions platform/jvm/gradle-test-app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ dependencies {

testImplementation("junit:junit:4.13.2")

androidTestImplementation(project(":common"))
androidTestImplementation("com.google.truth:truth:1.1.4")
androidTestImplementation("androidx.test:core:1.5.0")
androidTestImplementation("androidx.test:core-ktx:1.5.0")
Expand Down
5 changes: 3 additions & 2 deletions platform/jvm/replay/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.kotlin.android)

id("dependency-license-config")
}

dependencies {
api(project(":common"))

implementation(project(":common"))
implementation(libs.androidx.appcompat)
implementation(libs.androidx.ui)
implementation(libs.okhttp)
Expand Down
Loading