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

Upgrade to Kotlin 2.0.20 and move to build-logic for Gradle #1802

Merged
merged 7 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ captures
.idea/deploymentTargetDropDown.xml
.idea/misc.xml
.idea/androidTestResultsUserPreferences.xml
.idea/deploymentTargetSelector.xml
gradle.xml
*.iml

Expand All @@ -42,3 +43,6 @@ package-list-coil-base
docs-gen
site
*.bak

# Lint reports
lint-report.*
22 changes: 13 additions & 9 deletions .idea/deploymentTargetSelector.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 17 additions & 0 deletions .idea/runConfigurations.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 2 additions & 5 deletions adaptive/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@ package com.google.accompanist.adaptive {
property public final int VerticalFoldsOnly;
}

public final class RowColumnImplKt {
}

public final class SplitResult {
ctor public SplitResult(androidx.compose.foundation.gestures.Orientation gapOrientation, androidx.compose.ui.geometry.Rect gapBounds);
method public androidx.compose.ui.geometry.Rect getGapBounds();
Expand All @@ -41,11 +38,11 @@ package com.google.accompanist.adaptive {
}

public final class TwoPaneKt {
method public static com.google.accompanist.adaptive.TwoPaneStrategy HorizontalTwoPaneStrategy(float splitFraction, optional float gapWidth);
method public static com.google.accompanist.adaptive.TwoPaneStrategy HorizontalTwoPaneStrategy(float splitOffset, optional boolean offsetFromStart, optional float gapWidth);
method public static com.google.accompanist.adaptive.TwoPaneStrategy HorizontalTwoPaneStrategy(float splitFraction, optional float gapWidth);
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);
method public static com.google.accompanist.adaptive.TwoPaneStrategy VerticalTwoPaneStrategy(float splitFraction, optional float gapHeight);
method public static com.google.accompanist.adaptive.TwoPaneStrategy VerticalTwoPaneStrategy(float splitOffset, optional boolean offsetFromTop, optional float gapHeight);
method public static com.google.accompanist.adaptive.TwoPaneStrategy VerticalTwoPaneStrategy(float splitFraction, optional float gapHeight);
}

public fun interface TwoPaneStrategy {
Expand Down
63 changes: 3 additions & 60 deletions adaptive/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -16,65 +16,14 @@
@file:Suppress("UnstableApiUsage")

plugins {
id(libs.plugins.android.library.get().pluginId)
id(libs.plugins.android.kotlin.get().pluginId)
id(libs.plugins.jetbrains.dokka.get().pluginId)
id(libs.plugins.gradle.metalava.get().pluginId)
id(libs.plugins.vanniktech.maven.publish.get().pluginId)
}

kotlin {
explicitApi()
alias(libs.plugins.accompanist.android.library)
alias(libs.plugins.accompanist.android.library.compose)
alias(libs.plugins.accompanist.android.library.published)
}

android {
namespace = "com.google.accompanist.adaptive"

compileSdk = 34

defaultConfig {
minSdk = 21
// targetSdkVersion has no effect for libraries. This is only used for the test APK
targetSdk = 33
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}

buildFeatures {
buildConfig = false
compose = true
}

composeOptions {
kotlinCompilerExtensionVersion = libs.versions.composeCompiler.get()
}

lint {
textReport = true
textOutput = File("stdout")
// We run a full lint analysis as build part in CI, so skip vital checks for assemble tasks
checkReleaseBuilds = false
}

packagingOptions {
// Some of the META-INF files conflict with coroutines-test. Exclude them to enable
// our test APK to build (has no effect on our AARs)
resources {
excludes += listOf("/META-INF/AL2.0", "/META-INF/LGPL2.1")
}
}

testOptions {
unitTests {
isIncludeAndroidResources = true
}
animationsDisabled = true
}

sourceSets {
named("test") {
java.srcDirs("src/sharedTest/kotlin")
Expand All @@ -87,12 +36,6 @@ android {
}
}

metalava {
sourcePaths.setFrom("src/main")
filename.set("api/current.api")
reportLintsAsErrors.set(true)
}

dependencies {
api(libs.compose.foundation.foundation)
api(libs.compose.ui.ui)
Expand Down
73 changes: 73 additions & 0 deletions build-logic/convention/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Copyright 2022 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.
*/

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

plugins {
`kotlin-dsl`
}

group = "com.google.accompanist.buildlogic"

java {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}

kotlin {
compilerOptions {
jvmTarget = JvmTarget.JVM_17
}
}

dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.android.tools.common)
compileOnly(libs.compose.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.metalavaGradle)
implementation(libs.truth)
}

tasks {
validatePlugins {
enableStricterValidation = true
failOnWarning = true
}
}

gradlePlugin {
plugins {
register("androidLibrary") {
id = "accompanist.android.library"
implementationClass = "AndroidLibraryConventionPlugin"
}
register("androidLibraryCompose") {
id = "accompanist.android.library.compose"
implementationClass = "AndroidLibraryComposeConventionPlugin"
}
register("androidLint") {
id = "accompanist.android.lint"
implementationClass = "AndroidLintConventionPlugin"
}
register("androidLibraryPublished") {
id = "accompanist.android.library.published"
implementationClass = "AndroidLibraryPublishedConventionPlugin"
}
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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.
*/

import com.android.build.gradle.LibraryExtension
import com.google.accompanist.configureAndroidCompose
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.getByType

class AndroidLibraryComposeConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
apply(plugin = "com.android.library")
apply(plugin = "org.jetbrains.kotlin.plugin.compose")

val extension = extensions.getByType<LibraryExtension>()
configureAndroidCompose(extension)
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.
*/

import com.android.build.gradle.LibraryExtension
import com.google.accompanist.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.kotlin

class AndroidLibraryConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply("com.android.library")
apply("org.jetbrains.kotlin.android")
}

extensions.configure<LibraryExtension> {
configureKotlinAndroid(this)
defaultConfig.targetSdk = 35
defaultConfig.testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"

buildFeatures.buildConfig = false

testOptions.animationsDisabled = true
// The resource prefix is derived from the module name,
// so resources inside ":core:module1" must be prefixed with "core_module1_"
resourcePrefix = path.split("""\W""".toRegex()).drop(1).distinct().joinToString(separator = "_").lowercase() + "_"
bentrengrove marked this conversation as resolved.
Show resolved Hide resolved
}

dependencies {
add("androidTestImplementation", kotlin("test"))
add("testImplementation", kotlin("test"))
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
bentrengrove marked this conversation as resolved.
Show resolved Hide resolved
* 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.
*/

import me.tylerbwong.gradle.metalava.extension.MetalavaExtension
import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.kotlin.dsl.apply
import org.gradle.kotlin.dsl.configure

class AndroidLibraryPublishedConventionPlugin : Plugin<Project> {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
apply(AndroidLintConventionPlugin::class)

apply("me.tylerbwong.gradle.metalava")
apply("org.jetbrains.dokka")
apply("com.vanniktech.maven.publish")
}

extensions.configure<MetalavaExtension> {
sourcePaths.setFrom("src/main")
filename.set("api/current.api")
reportLintsAsErrors.set(true)
}
}
}
}
Loading
Loading