-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into improve-media-source
- Loading branch information
Showing
28 changed files
with
387 additions
and
393 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../gradle.properties |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
|
||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
group = "ch.srgssr.pillarbox.gradle" | ||
|
||
java { | ||
sourceCompatibility = JavaVersion.VERSION_17 | ||
targetCompatibility = JavaVersion.VERSION_17 | ||
} | ||
|
||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = JavaVersion.VERSION_17.majorVersion | ||
} | ||
} | ||
|
||
dependencies { | ||
compileOnly(libs.android.gradle.api) | ||
compileOnly(libs.kotlinx.kover.gradle) | ||
compileOnly(libs.kotlin.gradle.plugin) | ||
} | ||
|
||
tasks { | ||
validatePlugins { | ||
enableStricterValidation = true | ||
failOnWarning = true | ||
} | ||
} | ||
|
||
gradlePlugin { | ||
plugins { | ||
register("PillarboxAndroidApplication") { | ||
id = "ch.srgssr.pillarbox.gradle.android_application" | ||
implementationClass = "ch.srgssr.pillarbox.gradle.PillarboxAndroidApplicationPlugin" | ||
} | ||
|
||
register("PillarboxAndroidLibrary") { | ||
id = "ch.srgssr.pillarbox.gradle.android_library" | ||
implementationClass = "ch.srgssr.pillarbox.gradle.PillarboxAndroidLibraryPlugin" | ||
} | ||
|
||
register("PillarboxAndroidLibraryCompose") { | ||
id = "ch.srgssr.pillarbox.gradle.android_library_compose" | ||
implementationClass = "ch.srgssr.pillarbox.gradle.PillarboxAndroidLibraryComposePlugin" | ||
} | ||
|
||
register("PillarboxAndroidLibraryLint") { | ||
id = "ch.srgssr.pillarbox.gradle.android_library_lint" | ||
implementationClass = "ch.srgssr.pillarbox.gradle.PillarboxAndroidLibraryLintPlugin" | ||
} | ||
|
||
register("PillarboxAndroidLibraryPublishing") { | ||
id = "ch.srgssr.pillarbox.gradle.android_library_publishing" | ||
implementationClass = "ch.srgssr.pillarbox.gradle.PillarboxAndroidLibraryPublishingPlugin" | ||
} | ||
|
||
register("PillarboxAndroidLibraryTestedModule") { | ||
id = "ch.srgssr.pillarbox.gradle.android_library_tested_module" | ||
implementationClass = "ch.srgssr.pillarbox.gradle.PillarboxAndroidLibraryTestedModulePlugin" | ||
} | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...gic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidApplicationPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle | ||
|
||
import ch.srgssr.pillarbox.gradle.internal.AppConfig | ||
import ch.srgssr.pillarbox.gradle.internal.VersionConfig | ||
import ch.srgssr.pillarbox.gradle.internal.configureAndroidLintModule | ||
import ch.srgssr.pillarbox.gradle.internal.configureAndroidModule | ||
import ch.srgssr.pillarbox.gradle.internal.configureComposeModule | ||
import ch.srgssr.pillarbox.gradle.internal.configureKotlinModule | ||
import com.android.build.api.dsl.ApplicationExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
import org.gradle.kotlin.dsl.extra | ||
|
||
/** | ||
* Custom Gradle plugin to configure an Android library module for Pillarbox. | ||
*/ | ||
class PillarboxAndroidApplicationPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
pluginManager.apply("com.android.application") | ||
pluginManager.apply("org.jetbrains.kotlin.android") | ||
|
||
extensions.configure<ApplicationExtension> { | ||
configureAndroidLintModule(this) | ||
configureAndroidModule(this) | ||
configureComposeModule(this) | ||
|
||
defaultConfig { | ||
applicationId = namespace | ||
targetSdk = AppConfig.targetSdk | ||
versionCode = VersionConfig.versionCode() | ||
versionName = VersionConfig.versionName() | ||
vectorDrawables.useSupportLibrary = true | ||
} | ||
|
||
signingConfigs { | ||
create("release") { | ||
val password = System.getenv("DEMO_KEY_PASSWORD") ?: extra.properties["pillarbox.keystore.password"] as String? | ||
|
||
storeFile = file("./demo.keystore") | ||
storePassword = password | ||
keyAlias = "demo" | ||
keyPassword = password | ||
} | ||
} | ||
|
||
buildTypes { | ||
debug { | ||
applicationIdSuffix = ".debug" | ||
versionNameSuffix = "-debug" | ||
} | ||
|
||
release { | ||
signingConfig = signingConfigs.getByName("release") | ||
isMinifyEnabled = false | ||
isDebuggable = true | ||
|
||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
} | ||
|
||
configureKotlinModule() | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
.../plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryComposePlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle | ||
|
||
import ch.srgssr.pillarbox.gradle.internal.configureComposeModule | ||
import com.android.build.api.dsl.LibraryExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
/** | ||
* Custom Gradle plugin to configure Compose in an Android library module for Pillarbox. | ||
*/ | ||
class PillarboxAndroidLibraryComposePlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
pluginManager.apply("com.android.library") | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureComposeModule(this) | ||
} | ||
} | ||
} |
24 changes: 24 additions & 0 deletions
24
...gic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryLintPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle | ||
|
||
import ch.srgssr.pillarbox.gradle.internal.configureAndroidLintModule | ||
import com.android.build.api.dsl.LibraryExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
/** | ||
* Custom Gradle plugin to configure Lint in an Android library module for Pillarbox. | ||
*/ | ||
class PillarboxAndroidLibraryLintPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
pluginManager.apply("com.android.library") | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureAndroidLintModule(this) | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...d-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/PillarboxAndroidLibraryPlugin.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle | ||
|
||
import ch.srgssr.pillarbox.gradle.internal.configureAndroidModule | ||
import ch.srgssr.pillarbox.gradle.internal.configureKotlinModule | ||
import com.android.build.api.dsl.LibraryExtension | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.configure | ||
|
||
/** | ||
* Custom Gradle plugin to configure an Android library module for Pillarbox. | ||
*/ | ||
class PillarboxAndroidLibraryPlugin : Plugin<Project> { | ||
override fun apply(target: Project) = with(target) { | ||
pluginManager.apply("com.android.library") | ||
pluginManager.apply("org.jetbrains.kotlin.android") | ||
|
||
extensions.configure<LibraryExtension> { | ||
configureAndroidModule(this) | ||
|
||
defaultConfig { | ||
consumerProguardFiles("consumer-rules.pro") | ||
} | ||
|
||
buildTypes { | ||
release { | ||
isMinifyEnabled = false | ||
|
||
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") | ||
} | ||
} | ||
} | ||
|
||
configureKotlinModule() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/internal/AppConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle.internal | ||
|
||
import org.gradle.api.JavaVersion | ||
|
||
internal object AppConfig { | ||
internal const val minSdk = 21 | ||
internal const val targetSdk = 34 | ||
internal const val compileSdk = 34 | ||
internal const val androidXComposeCompiler = "1.5.10" | ||
|
||
// When changing this value, don't forget to also update the Detekt config in the root `build.gradle.kts` file | ||
internal val javaVersion = JavaVersion.VERSION_17 | ||
} |
58 changes: 58 additions & 0 deletions
58
build-logic/plugins/src/main/java/ch/srgssr/pillarbox/gradle/internal/ProjectExtensions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.gradle.internal | ||
|
||
import com.android.build.api.dsl.CommonExtension | ||
import org.gradle.api.Project | ||
import org.gradle.kotlin.dsl.withType | ||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile | ||
|
||
internal fun Project.configureAndroidModule(extension: CommonExtension<*, *, *, *, *, *>) = with(extension) { | ||
namespace = "ch.srgssr.pillarbox." + name.removePrefix("pillarbox-").replace('-', '.') | ||
compileSdk = AppConfig.compileSdk | ||
|
||
defaultConfig { | ||
minSdk = AppConfig.minSdk | ||
} | ||
|
||
compileOptions { | ||
sourceCompatibility = AppConfig.javaVersion | ||
targetCompatibility = AppConfig.javaVersion | ||
} | ||
|
||
buildFeatures { | ||
resValues = false | ||
shaders = false | ||
} | ||
} | ||
|
||
internal fun configureComposeModule(extension: CommonExtension<*, *, *, *, *, *>) = with(extension) { | ||
buildFeatures { | ||
compose = true | ||
} | ||
|
||
composeOptions { | ||
kotlinCompilerExtensionVersion = AppConfig.androidXComposeCompiler | ||
} | ||
} | ||
|
||
internal fun Project.configureKotlinModule() { | ||
tasks.withType<KotlinCompile>().configureEach { | ||
kotlinOptions { | ||
jvmTarget = AppConfig.javaVersion.majorVersion | ||
} | ||
} | ||
} | ||
|
||
internal fun Project.configureAndroidLintModule(extension: CommonExtension<*, *, *, *, *, *>) = with(extension) { | ||
lint { | ||
abortOnError = true | ||
checkAllWarnings = true | ||
checkDependencies = true | ||
sarifReport = true | ||
sarifOutput = file("${rootProject.rootDir}/build/reports/android-lint/$name.sarif") | ||
disable.add("LogConditional") | ||
} | ||
} |
Oops, something went wrong.