Skip to content

Commit ebd1567

Browse files
authored
Merge pull request #1802 from google/ben/buildlogic
Upgrade to Kotlin 2.0.20 and move to build-logic for Gradle
2 parents bb1d0e7 + 0689837 commit ebd1567

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+594
-553
lines changed

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ captures
1818
.idea/deploymentTargetDropDown.xml
1919
.idea/misc.xml
2020
.idea/androidTestResultsUserPreferences.xml
21+
.idea/deploymentTargetSelector.xml
2122
gradle.xml
2223
*.iml
2324

@@ -42,3 +43,6 @@ package-list-coil-base
4243
docs-gen
4344
site
4445
*.bak
46+
47+
# Lint reports
48+
lint-report.*

.idea/deploymentTargetSelector.xml

+13-9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/kotlinc.xml

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/runConfigurations.xml

+17
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

adaptive/api/current.api

+2-5
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ package com.google.accompanist.adaptive {
2929
property public final int VerticalFoldsOnly;
3030
}
3131

32-
public final class RowColumnImplKt {
33-
}
34-
3532
public final class SplitResult {
3633
ctor public SplitResult(androidx.compose.foundation.gestures.Orientation gapOrientation, androidx.compose.ui.geometry.Rect gapBounds);
3734
method public androidx.compose.ui.geometry.Rect getGapBounds();
@@ -41,11 +38,11 @@ package com.google.accompanist.adaptive {
4138
}
4239

4340
public final class TwoPaneKt {
44-
method public static com.google.accompanist.adaptive.TwoPaneStrategy HorizontalTwoPaneStrategy(float splitFraction, optional float gapWidth);
4541
method public static com.google.accompanist.adaptive.TwoPaneStrategy HorizontalTwoPaneStrategy(float splitOffset, optional boolean offsetFromStart, optional float gapWidth);
42+
method public static com.google.accompanist.adaptive.TwoPaneStrategy HorizontalTwoPaneStrategy(float splitFraction, optional float gapWidth);
4643
method @androidx.compose.runtime.Composable public static void TwoPane(kotlin.jvm.functions.Function0<kotlin.Unit> first, kotlin.jvm.functions.Function0<kotlin.Unit> second, com.google.accompanist.adaptive.TwoPaneStrategy strategy, java.util.List<? extends androidx.window.layout.DisplayFeature> displayFeatures, optional androidx.compose.ui.Modifier modifier, optional int foldAwareConfiguration);
47-
method public static com.google.accompanist.adaptive.TwoPaneStrategy VerticalTwoPaneStrategy(float splitFraction, optional float gapHeight);
4844
method public static com.google.accompanist.adaptive.TwoPaneStrategy VerticalTwoPaneStrategy(float splitOffset, optional boolean offsetFromTop, optional float gapHeight);
45+
method public static com.google.accompanist.adaptive.TwoPaneStrategy VerticalTwoPaneStrategy(float splitFraction, optional float gapHeight);
4946
}
5047

5148
public fun interface TwoPaneStrategy {

adaptive/build.gradle.kts

+3-60
Original file line numberDiff line numberDiff line change
@@ -16,65 +16,14 @@
1616
@file:Suppress("UnstableApiUsage")
1717

1818
plugins {
19-
id(libs.plugins.android.library.get().pluginId)
20-
id(libs.plugins.android.kotlin.get().pluginId)
21-
id(libs.plugins.jetbrains.dokka.get().pluginId)
22-
id(libs.plugins.gradle.metalava.get().pluginId)
23-
id(libs.plugins.vanniktech.maven.publish.get().pluginId)
24-
}
25-
26-
kotlin {
27-
explicitApi()
19+
alias(libs.plugins.accompanist.android.library)
20+
alias(libs.plugins.accompanist.android.library.compose)
21+
alias(libs.plugins.accompanist.android.library.published)
2822
}
2923

3024
android {
3125
namespace = "com.google.accompanist.adaptive"
3226

33-
compileSdk = 34
34-
35-
defaultConfig {
36-
minSdk = 21
37-
// targetSdkVersion has no effect for libraries. This is only used for the test APK
38-
targetSdk = 33
39-
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
40-
}
41-
42-
compileOptions {
43-
sourceCompatibility = JavaVersion.VERSION_1_8
44-
targetCompatibility = JavaVersion.VERSION_1_8
45-
}
46-
47-
buildFeatures {
48-
buildConfig = false
49-
compose = true
50-
}
51-
52-
composeOptions {
53-
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
54-
}
55-
56-
lint {
57-
textReport = true
58-
textOutput = File("stdout")
59-
// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks
60-
checkReleaseBuilds = false
61-
}
62-
63-
packagingOptions {
64-
// Some of the META-INF files conflict with coroutines-test. Exclude them to enable
65-
// our test APK to build (has no effect on our AARs)
66-
resources {
67-
excludes += listOf("/META-INF/AL2.0", "/META-INF/LGPL2.1")
68-
}
69-
}
70-
71-
testOptions {
72-
unitTests {
73-
isIncludeAndroidResources = true
74-
}
75-
animationsDisabled = true
76-
}
77-
7827
sourceSets {
7928
named("test") {
8029
java.srcDirs("src/sharedTest/kotlin")
@@ -87,12 +36,6 @@ android {
8736
}
8837
}
8938

90-
metalava {
91-
sourcePaths.setFrom("src/main")
92-
filename.set("api/current.api")
93-
reportLintsAsErrors.set(true)
94-
}
95-
9639
dependencies {
9740
api(libs.compose.foundation.foundation)
9841
api(libs.compose.ui.ui)
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright 2022 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
18+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
19+
20+
plugins {
21+
`kotlin-dsl`
22+
}
23+
24+
group = "com.google.accompanist.buildlogic"
25+
26+
java {
27+
sourceCompatibility = JavaVersion.VERSION_17
28+
targetCompatibility = JavaVersion.VERSION_17
29+
}
30+
31+
kotlin {
32+
compilerOptions {
33+
jvmTarget = JvmTarget.JVM_17
34+
}
35+
}
36+
37+
dependencies {
38+
compileOnly(libs.android.gradlePlugin)
39+
compileOnly(libs.android.tools.common)
40+
compileOnly(libs.compose.gradlePlugin)
41+
compileOnly(libs.kotlin.gradlePlugin)
42+
compileOnly(libs.metalavaGradle)
43+
implementation(libs.truth)
44+
}
45+
46+
tasks {
47+
validatePlugins {
48+
enableStricterValidation = true
49+
failOnWarning = true
50+
}
51+
}
52+
53+
gradlePlugin {
54+
plugins {
55+
register("androidLibrary") {
56+
id = "accompanist.android.library"
57+
implementationClass = "AndroidLibraryConventionPlugin"
58+
}
59+
register("androidLibraryCompose") {
60+
id = "accompanist.android.library.compose"
61+
implementationClass = "AndroidLibraryComposeConventionPlugin"
62+
}
63+
register("androidLint") {
64+
id = "accompanist.android.lint"
65+
implementationClass = "AndroidLintConventionPlugin"
66+
}
67+
register("androidLibraryPublished") {
68+
id = "accompanist.android.library.published"
69+
implementationClass = "AndroidLibraryPublishedConventionPlugin"
70+
}
71+
}
72+
}
73+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.android.build.gradle.LibraryExtension
18+
import com.google.accompanist.configureAndroidCompose
19+
import org.gradle.api.Plugin
20+
import org.gradle.api.Project
21+
import org.gradle.kotlin.dsl.apply
22+
import org.gradle.kotlin.dsl.getByType
23+
24+
class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
25+
override fun apply(target: Project) {
26+
with(target) {
27+
apply(plugin = "com.android.library")
28+
apply(plugin = "org.jetbrains.kotlin.plugin.compose")
29+
30+
val extension = extensions.getByType<LibraryExtension>()
31+
configureAndroidCompose(extension)
32+
}
33+
}
34+
35+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import com.android.build.gradle.LibraryExtension
18+
import com.google.accompanist.configureKotlinAndroid
19+
import org.gradle.api.Plugin
20+
import org.gradle.api.Project
21+
import org.gradle.kotlin.dsl.configure
22+
import org.gradle.kotlin.dsl.dependencies
23+
import org.gradle.kotlin.dsl.kotlin
24+
25+
class AndroidLibraryConventionPlugin : Plugin<Project> {
26+
override fun apply(target: Project) {
27+
with(target) {
28+
with(pluginManager) {
29+
apply("com.android.library")
30+
apply("org.jetbrains.kotlin.android")
31+
}
32+
33+
extensions.configure<LibraryExtension> {
34+
configureKotlinAndroid(this)
35+
defaultConfig.targetSdk = 35
36+
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
37+
38+
buildFeatures.buildConfig = false
39+
40+
testOptions.animationsDisabled = true
41+
// The resource prefix is derived from the module name,
42+
// so resources inside ":core:module1" must be prefixed with "core_module1_"
43+
resourcePrefix = path.split("""\W""".toRegex()).drop(1).distinct().joinToString(separator = "_").lowercase() + "_"
44+
}
45+
46+
dependencies {
47+
add("androidTestImplementation", kotlin("test"))
48+
add("testImplementation", kotlin("test"))
49+
}
50+
}
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/*
2+
* Copyright 2024 The Android Open Source Project
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import me.tylerbwong.gradle.metalava.extension.MetalavaExtension
18+
import org.gradle.api.Plugin
19+
import org.gradle.api.Project
20+
import org.gradle.kotlin.dsl.apply
21+
import org.gradle.kotlin.dsl.configure
22+
23+
class AndroidLibraryPublishedConventionPlugin : Plugin<Project> {
24+
override fun apply(target: Project) {
25+
with(target) {
26+
with(pluginManager) {
27+
apply(AndroidLintConventionPlugin::class)
28+
29+
apply("me.tylerbwong.gradle.metalava")
30+
apply("org.jetbrains.dokka")
31+
apply("com.vanniktech.maven.publish")
32+
}
33+
34+
extensions.configure<MetalavaExtension> {
35+
sourcePaths.setFrom("src/main")
36+
filename.set("api/current.api")
37+
reportLintsAsErrors.set(true)
38+
}
39+
}
40+
}
41+
}

0 commit comments

Comments
 (0)