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

chore: Move Licensee configuration to convention plugin #122

Merged
merged 4 commits into from
Feb 29, 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
21 changes: 13 additions & 8 deletions build-logic/plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ dependencies {
compileOnly(libs.plugin.kotlin.android)
compileOnly(libs.plugin.kover)
compileOnly(libs.plugin.ktlint)
compileOnly(libs.plugin.licensee)
}

gradlePlugin {
Expand All @@ -45,14 +46,6 @@ gradlePlugin {
id = "amplify.android.api.validator"
implementationClass = "ApiValidatorConventionPlugin"
}
register("publishing") {
id = "amplify.android.publishing"
implementationClass = "PublishingConventionPlugin"
}
register("ktlint") {
id = "amplify.android.ktlint"
implementationClass = "KtLintConventionPlugin"
}
register("component") {
id = "amplify.android.ui.component"
implementationClass = "ComponentConventionPlugin"
Expand All @@ -61,5 +54,17 @@ gradlePlugin {
id = "amplify.android.kover"
implementationClass = "KoverConventionPlugin"
}
register("ktlint") {
id = "amplify.android.ktlint"
implementationClass = "KtLintConventionPlugin"
}
register("licenses") {
id = "amplify.android.licenses"
implementationClass = "LicensesConventionPlugin"
}
register("publishing") {
id = "amplify.android.publishing"
implementationClass = "PublishingConventionPlugin"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ComponentConventionPlugin : Plugin<Project> {
pluginManager.apply("amplify.android.publishing")
pluginManager.apply("amplify.android.kover")
pluginManager.apply("amplify.android.api.validator")
pluginManager.apply("amplify.android.licenses")

tasks.withType<KotlinCompile>().configureEach {
kotlinOptions {
Expand Down
66 changes: 66 additions & 0 deletions build-logic/plugins/src/main/kotlin/LicensesConventionPlugin.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure

/*
* Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License.
* A copy of the License is located at
*
* http://aws.amazon.com/apache2.0
*
* or in the "license" file accompanying this file. This file is distributed
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
* express or implied. See the License for the specific language governing
* permissions and limitations under the License.
*/

/**
* Applies and configures the [Licensee Plugin](https://github.com/cashapp/licensee) to ensure all our dependencies
* (and transitive dependencies) are using allowed licenses.
*/
class LicensesConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("app.cash.licensee")

extensions.configure<app.cash.licensee.LicenseeExtension> {
allow("Apache-2.0")
allow("MIT")

allowUrl("http://aws.amazon.com/apache2.0")
allowUrl("https://developer.android.com/studio/terms.html")

ignoreDependencies("javax.annotation", "javax.annotation-api") {
because("Transitive dependency for androidx.test.espresso:espresso-core")
}
ignoreDependencies("org.junit", "junit-bom") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit", "jupiter") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.jupiter", "junit-jupiter") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.jupiter", "junit-jupiter-params") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit", "junit-jupiter-params") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.platform", "junit-platform-commons") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.platform", "junit-platform-engine") {
because("Unit Testing Dependency")
}
ignoreDependencies("junit", "junit") {
because("Unit Testing Dependency")
}
}
}
}
}
54 changes: 1 addition & 53 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,59 +5,6 @@ buildscript {
google()
mavenCentral()
}
dependencies {
classpath("app.cash.licensee:licensee-gradle-plugin:1.7.0")
}
}

subprojects {
apply(plugin = "app.cash.licensee")
configure<app.cash.licensee.LicenseeExtension> {
allow("Apache-2.0")
allow("MIT")
allow("BSD-2-Clause")
allowDependency("org.bouncycastle", "bcprov-jdk15on", "1.70") {
"MIT License"
}
allowDependency("org.ow2.asm", "asm", "9.4") {
"3-Clause BSD License"
}
allowDependency("org.ow2.asm", "asm-analysis", "9.4")
allowDependency("org.ow2.asm", "asm-commons", "9.4")
allowDependency("org.ow2.asm", "asm-tree", "9.4")
allowDependency("org.ow2.asm", "asm-util", "9.4")
allowDependency("com.ibm.icu", "icu4j", "70.1")
allowUrl("http://aws.amazon.com/apache2.0")
allowUrl("https://developer.android.com/studio/terms.html")

ignoreDependencies("javax.annotation", "javax.annotation-api") {
"Transitive dependency for androidx.test.espresso:espresso-core"
}
ignoreDependencies("org.junit", "junit-bom") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit", "jupiter") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.jupiter", "junit-jupiter") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.jupiter", "junit-jupiter-params") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit", "junit-jupiter-params") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.platform", "junit-platform-commons") {
because("Unit Testing Dependency")
}
ignoreDependencies("org.junit.platform", "junit-platform-engine") {
because("Unit Testing Dependency")
}
ignoreDependencies("junit", "junit") {
because("Unit Testing Dependency")
}
}
}

plugins {
Expand All @@ -68,6 +15,7 @@ plugins {
alias(libs.plugins.kotlin.serialization) apply false
alias(libs.plugins.kover)
alias(libs.plugins.ktlint) apply false
alias(libs.plugins.licensee) apply false
}

tasks.register<Delete>("clean").configure {
Expand Down
9 changes: 6 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ binary-compatibility = "0.14.0"
cameraX = "1.2.0"
compose = "1.5.4"
coroutines = "1.7.3"
lifecycle = "2.4.0"
kotest = "5.7.1"
kotlin = "1.8.10"
ktlint = "11.0.0"
kover = "0.7.2"
kotest = "5.7.1"
ktlint = "11.0.0"
licensee = "1.7.0"
lifecycle = "2.4.0"
material3 = "1.1.2"
paparazzi = "1.2.0"
turbine = "1.0.0"
Expand Down Expand Up @@ -62,6 +63,7 @@ plugin-binary-compatibility = { module = "org.jetbrains.kotlinx:binary-compatibi
plugin-kotlin-android = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
plugin-kover = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover" }
plugin-ktlint = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" }
plugin-licensee = { module = "app.cash.licensee:app.cash.licensee.gradle.plugin", version.ref = "licensee" }

[bundles]
camera = ["androidx-camera-core", "androidx-camera-camera2", "androidx-camera-lifecycle"]
Expand All @@ -87,4 +89,5 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
licensee = { id = "app.cash.licensee", version.ref = "licensee" }
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
Loading