Skip to content

Commit e09034a

Browse files
New gradle plugin system
1 parent 3e5035f commit e09034a

File tree

9 files changed

+65
-71
lines changed

9 files changed

+65
-71
lines changed

app/build.gradle.kts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
import com.fragula2.gradle.BuildConst
1818

1919
plugins {
20-
id("com.android.application")
21-
id("kotlin-android")
22-
id("kotlin-parcelize")
23-
id("androidx.navigation.safeargs.kotlin")
20+
alias(libs.plugins.android.application)
21+
alias(libs.plugins.kotlin.android)
22+
alias(libs.plugins.android.navigation)
23+
alias(libs.plugins.kotlin.parcelize)
2424
id("stub-module")
2525
}
2626

benchmark/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
import com.fragula2.gradle.BuildConst
1818

1919
plugins {
20-
id("com.android.test")
21-
id("kotlin-android")
20+
alias(libs.plugins.android.test)
21+
alias(libs.plugins.kotlin.android)
2222
id("stub-module")
2323
}
2424

benchmark/src/main/kotlin/com/fragula2/benchmark/BaselineProfileBenchmark.kt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,12 @@
1616

1717
package com.fragula2.benchmark
1818

19-
import androidx.benchmark.macro.ExperimentalBaselineProfilesApi
2019
import androidx.benchmark.macro.junit4.BaselineProfileRule
2120
import androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner
2221
import org.junit.Rule
2322
import org.junit.Test
2423
import org.junit.runner.RunWith
2524

26-
@OptIn(ExperimentalBaselineProfilesApi::class)
2725
@RunWith(AndroidJUnit4ClassRunner::class)
2826
class BaselineProfileBenchmark {
2927

@@ -37,10 +35,7 @@ class BaselineProfileBenchmark {
3735
fun generateComposeProfile() = generate(AppVariant.COMPOSE)
3836

3937
private fun generate(appVariant: AppVariant) {
40-
baselineProfileRule.collectBaselineProfile(
41-
packageName = "com.fragula2.sample",
42-
) {
43-
pressHome()
38+
baselineProfileRule.collect("com.fragula2.sample") {
4439
startActivityAndWait(appVariant)
4540
}
4641
}

build-logic/convention/src/main/kotlin/com/fragula2/gradle/FragulaModulePlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FragulaModulePlugin : Plugin<Project> {
3030
with(target) {
3131
with(pluginManager) {
3232
apply("com.android.library")
33-
apply("kotlin-android")
33+
apply("org.jetbrains.kotlin.android")
3434
apply("binary-compatibility-validator")
3535
}
3636

build.gradle.kts

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,48 @@
1414
* limitations under the License.
1515
*/
1616

17-
buildscript {
18-
repositories {
19-
google()
20-
mavenCentral()
21-
}
22-
dependencies {
23-
classpath(libs.plugin.android)
24-
classpath(libs.plugin.kotlin)
25-
classpath(libs.plugin.safeargs)
26-
classpath(libs.plugin.validator)
17+
plugins {
18+
alias(libs.plugins.android.application) apply false
19+
alias(libs.plugins.android.library) apply false
20+
alias(libs.plugins.android.test) apply false
21+
alias(libs.plugins.android.navigation) apply false
22+
alias(libs.plugins.kotlin.android) apply false
23+
alias(libs.plugins.kotlin.parcelize) apply false
24+
alias(libs.plugins.kotlin.validator) apply false
25+
}
26+
27+
val ktlint: Configuration by configurations.creating
28+
29+
dependencies {
30+
ktlint(libs.ktlint) {
31+
attributes {
32+
attribute(Bundling.BUNDLING_ATTRIBUTE, objects.named(Bundling.EXTERNAL))
33+
}
2734
}
2835
}
2936

30-
tasks.register<Delete>("clean") {
31-
delete(rootProject.buildDir)
37+
tasks.register<JavaExec>("ktlint") {
38+
group = LifecycleBasePlugin.VERIFICATION_GROUP
39+
description = "Check Kotlin code style."
40+
classpath = ktlint
41+
mainClass.set("com.pinterest.ktlint.Main")
42+
args(
43+
"**/src/**/*.kt",
44+
"**.kts",
45+
"!**/build/**",
46+
)
3247
}
3348

34-
apply(from = "gradle/ktlint.gradle.kts")
49+
tasks.register<JavaExec>("ktlintFormat") {
50+
group = LifecycleBasePlugin.VERIFICATION_GROUP
51+
description = "Fix Kotlin code style deviations."
52+
classpath = ktlint
53+
mainClass.set("com.pinterest.ktlint.Main")
54+
jvmArgs("--add-opens=java.base/java.lang=ALL-UNNAMED")
55+
args(
56+
"-F",
57+
"**/src/**/*.kt",
58+
"**.kts",
59+
"!**/build/**",
60+
)
61+
}

gradle/ktlint.gradle.kts

Lines changed: 0 additions & 35 deletions
This file was deleted.

gradle/libs.versions.toml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,38 @@
11
[versions]
2-
agp = "8.1.1"
2+
agp = "8.1.4"
33
validator = "0.13.0"
4-
kotlin = "1.9.10"
4+
kotlin = "1.9.20"
55
core = "1.12.0"
6-
activity = "1.8.0"
6+
activity = "1.8.1"
77
fragment = "1.6.2"
88
profile-installer = "1.3.1"
99
appcompat = "1.6.1"
1010
material = "1.10.0"
11-
material-compose = "1.5.3"
1211
constraintlayout = "2.1.4"
1312
recyclerview = "1.3.2"
1413
coil = "2.5.0"
15-
compose = "1.5.3"
14+
compose = "1.5.4"
1615
accompanist = "0.30.1"
1716
lifecycle = "2.6.2"
1817
navigation = "2.7.5"
1918
junit = "4.13.2"
2019
junit-ext = "1.1.5"
2120
test-runner = "1.5.2"
22-
test-macrobenchmark = "1.2.0"
21+
test-macrobenchmark = "1.2.1"
2322
ktlint = "0.50.0"
2423

24+
[plugins]
25+
android-application = { id = "com.android.application", version.ref = "agp" }
26+
android-library = { id = "com.android.library", version.ref = "agp" }
27+
android-test = { id = "com.android.test", version.ref = "agp" }
28+
android-navigation = { id = "androidx.navigation.safeargs.kotlin", version.ref = "navigation" }
29+
kotlin-android = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
30+
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
31+
kotlin-validator = { id = "org.jetbrains.kotlinx.binary-compatibility-validator", version.ref = "validator" }
32+
2533
[libraries]
2634
plugin-android = { module = "com.android.tools.build:gradle", version.ref = "agp" }
2735
plugin-kotlin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", version.ref = "kotlin" }
28-
plugin-safeargs = { module = "androidx.navigation:navigation-safe-args-gradle-plugin", version.ref = "navigation" }
29-
plugin-validator = { module = "org.jetbrains.kotlinx:binary-compatibility-validator", version.ref = "validator" }
3036

3137
kotlin = { module = "org.jetbrains.kotlin:kotlin-stdlib", version.ref = "kotlin" }
3238
material = { module = "com.google.android.material:material", version.ref = "material" }
@@ -46,7 +52,7 @@ androidx-navigation = { module = "androidx.navigation:navigation-fragment-ktx",
4652

4753
compose-ui = { module = "androidx.compose.ui:ui", version.ref = "compose" }
4854
compose-foundation = { module = "androidx.compose.foundation:foundation", version.ref = "compose" }
49-
compose-material = { module = "androidx.compose.material:material", version.ref = "material-compose" }
55+
compose-material = { module = "androidx.compose.material:material", version.ref = "compose" }
5056
compose-activity = { module = "androidx.activity:activity-compose", version.ref = "activity" }
5157
compose-preview = { module = "androidx.compose.ui:ui-tooling-preview", version.ref = "compose" }
5258
compose-tooling = { module = "androidx.compose.ui:ui-tooling", version.ref = "compose" }
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists

settings.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pluginManagement {
1919
repositories {
2020
google()
2121
mavenCentral()
22+
gradlePluginPortal()
2223
}
2324
}
2425

0 commit comments

Comments
 (0)