Skip to content

Commit 1354652

Browse files
mattcreasertjleing
andauthored
chore: Move Licensee configuration to convention plugin (#122)
Co-authored-by: Thomas Leing <[email protected]>
1 parent 30ddf71 commit 1354652

File tree

5 files changed

+87
-64
lines changed

5 files changed

+87
-64
lines changed

build-logic/plugins/build.gradle.kts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ dependencies {
3333
compileOnly(libs.plugin.kotlin.android)
3434
compileOnly(libs.plugin.kover)
3535
compileOnly(libs.plugin.ktlint)
36+
compileOnly(libs.plugin.licensee)
3637
}
3738

3839
gradlePlugin {
@@ -45,14 +46,6 @@ gradlePlugin {
4546
id = "amplify.android.api.validator"
4647
implementationClass = "ApiValidatorConventionPlugin"
4748
}
48-
register("publishing") {
49-
id = "amplify.android.publishing"
50-
implementationClass = "PublishingConventionPlugin"
51-
}
52-
register("ktlint") {
53-
id = "amplify.android.ktlint"
54-
implementationClass = "KtLintConventionPlugin"
55-
}
5649
register("component") {
5750
id = "amplify.android.ui.component"
5851
implementationClass = "ComponentConventionPlugin"
@@ -61,5 +54,17 @@ gradlePlugin {
6154
id = "amplify.android.kover"
6255
implementationClass = "KoverConventionPlugin"
6356
}
57+
register("ktlint") {
58+
id = "amplify.android.ktlint"
59+
implementationClass = "KtLintConventionPlugin"
60+
}
61+
register("licenses") {
62+
id = "amplify.android.licenses"
63+
implementationClass = "LicensesConventionPlugin"
64+
}
65+
register("publishing") {
66+
id = "amplify.android.publishing"
67+
implementationClass = "PublishingConventionPlugin"
68+
}
6469
}
6570
}

build-logic/plugins/src/main/kotlin/ComponentConventionPlugin.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class ComponentConventionPlugin : Plugin<Project> {
3333
pluginManager.apply("amplify.android.publishing")
3434
pluginManager.apply("amplify.android.kover")
3535
pluginManager.apply("amplify.android.api.validator")
36+
pluginManager.apply("amplify.android.licenses")
3637

3738
tasks.withType<KotlinCompile>().configureEach {
3839
kotlinOptions {
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import org.gradle.api.Plugin
2+
import org.gradle.api.Project
3+
import org.gradle.kotlin.dsl.configure
4+
5+
/*
6+
* Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved.
7+
*
8+
* Licensed under the Apache License, Version 2.0 (the "License").
9+
* You may not use this file except in compliance with the License.
10+
* A copy of the License is located at
11+
*
12+
* http://aws.amazon.com/apache2.0
13+
*
14+
* or in the "license" file accompanying this file. This file is distributed
15+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
16+
* express or implied. See the License for the specific language governing
17+
* permissions and limitations under the License.
18+
*/
19+
20+
/**
21+
* Applies and configures the [Licensee Plugin](https://github.com/cashapp/licensee) to ensure all our dependencies
22+
* (and transitive dependencies) are using allowed licenses.
23+
*/
24+
class LicensesConventionPlugin : Plugin<Project> {
25+
override fun apply(target: Project) {
26+
with(target) {
27+
pluginManager.apply("app.cash.licensee")
28+
29+
extensions.configure<app.cash.licensee.LicenseeExtension> {
30+
allow("Apache-2.0")
31+
allow("MIT")
32+
33+
allowUrl("http://aws.amazon.com/apache2.0")
34+
allowUrl("https://developer.android.com/studio/terms.html")
35+
36+
ignoreDependencies("javax.annotation", "javax.annotation-api") {
37+
because("Transitive dependency for androidx.test.espresso:espresso-core")
38+
}
39+
ignoreDependencies("org.junit", "junit-bom") {
40+
because("Unit Testing Dependency")
41+
}
42+
ignoreDependencies("org.junit", "jupiter") {
43+
because("Unit Testing Dependency")
44+
}
45+
ignoreDependencies("org.junit.jupiter", "junit-jupiter") {
46+
because("Unit Testing Dependency")
47+
}
48+
ignoreDependencies("org.junit.jupiter", "junit-jupiter-params") {
49+
because("Unit Testing Dependency")
50+
}
51+
ignoreDependencies("org.junit", "junit-jupiter-params") {
52+
because("Unit Testing Dependency")
53+
}
54+
ignoreDependencies("org.junit.platform", "junit-platform-commons") {
55+
because("Unit Testing Dependency")
56+
}
57+
ignoreDependencies("org.junit.platform", "junit-platform-engine") {
58+
because("Unit Testing Dependency")
59+
}
60+
ignoreDependencies("junit", "junit") {
61+
because("Unit Testing Dependency")
62+
}
63+
}
64+
}
65+
}
66+
}

build.gradle.kts

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -5,59 +5,6 @@ buildscript {
55
google()
66
mavenCentral()
77
}
8-
dependencies {
9-
classpath("app.cash.licensee:licensee-gradle-plugin:1.7.0")
10-
}
11-
}
12-
13-
subprojects {
14-
apply(plugin = "app.cash.licensee")
15-
configure<app.cash.licensee.LicenseeExtension> {
16-
allow("Apache-2.0")
17-
allow("MIT")
18-
allow("BSD-2-Clause")
19-
allowDependency("org.bouncycastle", "bcprov-jdk15on", "1.70") {
20-
"MIT License"
21-
}
22-
allowDependency("org.ow2.asm", "asm", "9.4") {
23-
"3-Clause BSD License"
24-
}
25-
allowDependency("org.ow2.asm", "asm-analysis", "9.4")
26-
allowDependency("org.ow2.asm", "asm-commons", "9.4")
27-
allowDependency("org.ow2.asm", "asm-tree", "9.4")
28-
allowDependency("org.ow2.asm", "asm-util", "9.4")
29-
allowDependency("com.ibm.icu", "icu4j", "70.1")
30-
allowUrl("http://aws.amazon.com/apache2.0")
31-
allowUrl("https://developer.android.com/studio/terms.html")
32-
33-
ignoreDependencies("javax.annotation", "javax.annotation-api") {
34-
"Transitive dependency for androidx.test.espresso:espresso-core"
35-
}
36-
ignoreDependencies("org.junit", "junit-bom") {
37-
because("Unit Testing Dependency")
38-
}
39-
ignoreDependencies("org.junit", "jupiter") {
40-
because("Unit Testing Dependency")
41-
}
42-
ignoreDependencies("org.junit.jupiter", "junit-jupiter") {
43-
because("Unit Testing Dependency")
44-
}
45-
ignoreDependencies("org.junit.jupiter", "junit-jupiter-params") {
46-
because("Unit Testing Dependency")
47-
}
48-
ignoreDependencies("org.junit", "junit-jupiter-params") {
49-
because("Unit Testing Dependency")
50-
}
51-
ignoreDependencies("org.junit.platform", "junit-platform-commons") {
52-
because("Unit Testing Dependency")
53-
}
54-
ignoreDependencies("org.junit.platform", "junit-platform-engine") {
55-
because("Unit Testing Dependency")
56-
}
57-
ignoreDependencies("junit", "junit") {
58-
because("Unit Testing Dependency")
59-
}
60-
}
618
}
629

6310
plugins {
@@ -68,6 +15,7 @@ plugins {
6815
alias(libs.plugins.kotlin.serialization) apply false
6916
alias(libs.plugins.kover)
7017
alias(libs.plugins.ktlint) apply false
18+
alias(libs.plugins.licensee) apply false
7119
}
7220

7321
tasks.register<Delete>("clean").configure {

gradle/libs.versions.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@ binary-compatibility = "0.14.0"
55
cameraX = "1.2.0"
66
compose = "1.5.4"
77
coroutines = "1.7.3"
8-
lifecycle = "2.4.0"
8+
kotest = "5.7.1"
99
kotlin = "1.8.10"
10-
ktlint = "11.0.0"
1110
kover = "0.7.2"
12-
kotest = "5.7.1"
11+
ktlint = "11.0.0"
12+
licensee = "1.7.0"
13+
lifecycle = "2.4.0"
1314
material3 = "1.1.2"
1415
paparazzi = "1.2.0"
1516
turbine = "1.0.0"
@@ -62,6 +63,7 @@ plugin-binary-compatibility = { module = "org.jetbrains.kotlinx:binary-compatibi
6263
plugin-kotlin-android = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
6364
plugin-kover = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover" }
6465
plugin-ktlint = { module = "org.jlleitschuh.gradle:ktlint-gradle", version.ref = "ktlint" }
66+
plugin-licensee = { module = "app.cash.licensee:app.cash.licensee.gradle.plugin", version.ref = "licensee" }
6567

6668
[bundles]
6769
camera = ["androidx-camera-core", "androidx-camera-camera2", "androidx-camera-lifecycle"]
@@ -87,4 +89,5 @@ kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
8789
kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", version.ref = "kotlin" }
8890
kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" }
8991
ktlint = { id = "org.jlleitschuh.gradle.ktlint", version.ref = "ktlint" }
92+
licensee = { id = "app.cash.licensee", version.ref = "licensee" }
9093
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }

0 commit comments

Comments
 (0)