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

Merge android and library plugins #1519

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
dcf8122
Remove old Application and Library compose plugins.
Jaehwa-Noh Jun 29, 2024
12f4bcb
Create new AndroidComposeConventionPlugin.
Jaehwa-Noh Jun 29, 2024
b45f714
Merge two android and library compose plugins.
Jaehwa-Noh Jun 29, 2024
37bef79
Add org.jetbrains.kotlin.plugin.compose plugin.
Jaehwa-Noh Jun 29, 2024
126a63c
Replace to merged plugin nowinandroid.android.compose.
Jaehwa-Noh Jun 29, 2024
48056b7
Replace apply to pluginManager.apply.
Jaehwa-Noh Jun 29, 2024
aa2750c
Change instruction TODO text.
Jaehwa-Noh Jun 29, 2024
c801932
Remove old Jacoco plugins.
Jaehwa-Noh Jun 29, 2024
20f0ad5
Merge application and library jacoco plugins.
Jaehwa-Noh Jun 29, 2024
d147de3
Merge application and library jacoco plugins.
Jaehwa-Noh Jun 29, 2024
4260c93
Replace library and application jacoco to merged jacoco plugins.
Jaehwa-Noh Jun 29, 2024
8f64823
Add explicit extension type.
Jaehwa-Noh Jun 29, 2024
eeac016
Update build-logic/convention/src/main/kotlin/AndroidComposeConventio…
Jaehwa-Noh Jul 2, 2024
6687ec6
Update core/testing/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
40623e0
Update core/ui/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
20e8322
Update feature/bookmarks/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
aeb9b47
Update feature/foryou/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
f4543c4
Update feature/search/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
bf9c90e
Update feature/settings/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
6fa8f0d
Update feature/topic/build.gradle.kts
Jaehwa-Noh Jul 2, 2024
362b000
Update build-logic/convention/src/main/kotlin/AndroidJacocoConvention…
Jaehwa-Noh Jul 2, 2024
2d06641
Refactor `when` block and remove side effect.
Jaehwa-Noh Jul 3, 2024
1858bc3
Update feature/interests/build.gradle.kts
Jaehwa-Noh Jul 3, 2024
39991d2
Merge branch 'refs/heads/android-remote-main' into merge-android-and-…
Jaehwa-Noh Jul 4, 2024
b2d3131
Refector when blocks
dturner Jul 5, 2024
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
2 changes: 1 addition & 1 deletion app-nia-catalog/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import com.google.samples.apps.nowinandroid.NiaFlavor
*/
plugins {
alias(libs.plugins.nowinandroid.android.application)
alias(libs.plugins.nowinandroid.android.application.compose)
alias(libs.plugins.nowinandroid.android.compose)
}

android {
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ import com.google.samples.apps.nowinandroid.NiaBuildType

plugins {
alias(libs.plugins.nowinandroid.android.application)
alias(libs.plugins.nowinandroid.android.application.compose)
alias(libs.plugins.nowinandroid.android.compose)
alias(libs.plugins.nowinandroid.android.application.flavors)
alias(libs.plugins.nowinandroid.android.application.jacoco)
alias(libs.plugins.nowinandroid.android.jacoco)
alias(libs.plugins.nowinandroid.android.hilt)
alias(libs.plugins.nowinandroid.android.application.firebase)
id("com.google.android.gms.oss-licenses-plugin")
Expand Down
21 changes: 6 additions & 15 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
*/

import org.jetbrains.kotlin.gradle.dsl.JvmTarget
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile

plugins {
`kotlin-dsl`
Expand Down Expand Up @@ -57,21 +56,17 @@ tasks {

gradlePlugin {
plugins {
register("androidApplicationCompose") {
id = "nowinandroid.android.application.compose"
implementationClass = "AndroidApplicationComposeConventionPlugin"
register("androidCompose") {
id = "nowinandroid.android.compose"
implementationClass = "AndroidComposeConventionPlugin"
}
register("androidApplication") {
id = "nowinandroid.android.application"
implementationClass = "AndroidApplicationConventionPlugin"
}
register("androidApplicationJacoco") {
id = "nowinandroid.android.application.jacoco"
implementationClass = "AndroidApplicationJacocoConventionPlugin"
}
register("androidLibraryCompose") {
id = "nowinandroid.android.library.compose"
implementationClass = "AndroidLibraryComposeConventionPlugin"
register("androidJacoco") {
id = "nowinandroid.android.jacoco"
implementationClass = "AndroidJacocoConventionPlugin"
}
register("androidLibrary") {
id = "nowinandroid.android.library"
Expand All @@ -81,10 +76,6 @@ gradlePlugin {
id = "nowinandroid.android.feature"
implementationClass = "AndroidFeatureConventionPlugin"
}
register("androidLibraryJacoco") {
id = "nowinandroid.android.library.jacoco"
implementationClass = "AndroidLibraryJacocoConventionPlugin"
}
register("androidTest") {
id = "nowinandroid.android.test"
implementationClass = "AndroidTestConventionPlugin"
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import com.google.samples.apps.nowinandroid.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.the

/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.
*/

class AndroidComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("org.jetbrains.kotlin.plugin.compose")
val extension: CommonExtension<*, *, *, *, *, *> = when {
pluginManager.hasPlugin("com.android.application") -> the<ApplicationExtension>()
pluginManager.hasPlugin("com.android.library") -> the<LibraryExtension>()
else -> TODO("Need to apply nowinandroid.android.application or nowinandroid.android.library firstly.")
Jaehwa-Noh marked this conversation as resolved.
Show resolved Hide resolved
}
configureAndroidCompose(extension)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.variant.AndroidComponentsExtension
import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.gradle.internal.dsl.BaseAppModuleExtension
import com.google.samples.apps.nowinandroid.configureJacoco
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.the

/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License 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.
*/

class AndroidJacocoConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
pluginManager.apply("jacoco")

val jacocoExtension: AndroidComponentsExtension<*, *, *>
val androidExtension: CommonExtension<*, *, *, *, *, *> = when {
dturner marked this conversation as resolved.
Show resolved Hide resolved
pluginManager.hasPlugin("com.android.application") -> {
jacocoExtension = the<ApplicationAndroidComponentsExtension>()
the<BaseAppModuleExtension>()
}

pluginManager.hasPlugin("com.android.library") -> {
jacocoExtension = the<LibraryAndroidComponentsExtension>()
the<LibraryExtension>()
}

else -> TODO("Need to apply nowinandroid.android.application or nowinandroid.android.library firstly.")
Jaehwa-Noh marked this conversation as resolved.
Show resolved Hide resolved
}

androidExtension.buildTypes.configureEach {
enableAndroidTestCoverage = true
enableUnitTestCoverage = true
}

configureJacoco(jacocoExtension)
}
}
}

This file was deleted.

This file was deleted.

2 changes: 1 addition & 1 deletion core/analytics/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.compose)
alias(libs.plugins.nowinandroid.android.compose)
alias(libs.plugins.nowinandroid.android.hilt)
}

Expand Down
4 changes: 2 additions & 2 deletions core/common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.nowinandroid.android.jacoco)
alias(libs.plugins.nowinandroid.android.hilt)
}

Expand All @@ -26,4 +26,4 @@ android {
dependencies {
testImplementation(libs.kotlinx.coroutines.test)
testImplementation(libs.turbine)
}
}
2 changes: 1 addition & 1 deletion core/data/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.nowinandroid.android.jacoco)
alias(libs.plugins.nowinandroid.android.hilt)
id("kotlinx-serialization")
}
Expand Down
2 changes: 1 addition & 1 deletion core/database/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.nowinandroid.android.jacoco)
alias(libs.plugins.nowinandroid.android.hilt)
alias(libs.plugins.nowinandroid.android.room)
}
Expand Down
2 changes: 1 addition & 1 deletion core/datastore/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.nowinandroid.android.jacoco)
alias(libs.plugins.nowinandroid.android.hilt)
}

Expand Down
4 changes: 2 additions & 2 deletions core/designsystem/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.compose)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.nowinandroid.android.compose)
alias(libs.plugins.nowinandroid.android.jacoco)
alias(libs.plugins.roborazzi)
}

Expand Down
4 changes: 2 additions & 2 deletions core/domain/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
plugins {
alias(libs.plugins.nowinandroid.android.library)
alias(libs.plugins.nowinandroid.android.library.jacoco)
alias(libs.plugins.nowinandroid.android.jacoco)
id("com.google.devtools.ksp")
}

Expand All @@ -30,4 +30,4 @@ dependencies {
implementation(libs.javax.inject)

testImplementation(projects.core.testing)
}
}
Loading
Loading