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 AGP 8 & Kotlin 1.9.10 #324

Merged
merged 18 commits into from
Jan 4, 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
10 changes: 10 additions & 0 deletions .github/workflows/build-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ jobs:
env:
DANGER_GITHUB_API_TOKEN: ${{ secrets.DANGER_GITHUB_API_TOKEN }}
steps:
- name: Configure JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 18
- name: Checkout the code
uses: actions/checkout@v2
- name: Install Ruby
Expand Down Expand Up @@ -42,6 +47,11 @@ jobs:
assemble_samples:
runs-on: ubuntu-latest
steps:
- name: Configure JDK
uses: actions/setup-java@v2
with:
distribution: 'zulu'
java-version: 18
- name: Checkout the code
uses: actions/checkout@v2
- name: Assemble Counter
Expand Down
67 changes: 65 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.api.dsl.CommonExtension
import com.android.build.api.dsl.LibraryExtension
import com.android.build.api.dsl.TestExtension

buildscript {

repositories {
Expand All @@ -20,22 +25,79 @@ buildscript {
apply(plugin = "com.github.ben-manes.versions")
apply(plugin = "org.jetbrains.dokka")
apply(from = "gradle/jacoco.gradle")
apply(from = "gradle/merge-reports.gradle")

allprojects {
repositories {
google()
mavenCentral()
}
}

subprojects {
val javaVersion = JavaVersion.VERSION_18

tasks.withType<org.jetbrains.dokka.gradle.DokkaTaskPartial>().configureEach {
dokkaSourceSets.named("main") {
jdkVersion.set(8)
jdkVersion.set(11)
skipDeprecated.set(true)
skipEmptyPackages.set(true)
reportUndocumented.set(false)
}
}

// Common android config
val commonAndroidConfig: CommonExtension<*, *, *, *, *>.() -> Unit = {
compileSdk = 34

compileOptions {
sourceCompatibility = javaVersion
targetCompatibility = javaVersion
}
}

// Android library config
pluginManager.withPlugin("com.android.library") {
with(extensions.getByType<LibraryExtension>()) {
commonAndroidConfig()
defaultConfig { minSdk = 21 }
}
}

// Android app config
pluginManager.withPlugin("com.android.application") {
with(extensions.getByType<ApplicationExtension>()) {
commonAndroidConfig()
defaultConfig {
minSdk = 21
//noinspection ExpiredTargetSdkVersion
targetSdk = 30
}
}
}

// Android test config
pluginManager.withPlugin("com.android.test") {
with(extensions.getByType<TestExtension>()) {
commonAndroidConfig()
defaultConfig {
// Using sdk 28 for robolectric tests.
minSdk = 28
//noinspection ExpiredTargetSdkVersion
targetSdk = 28
}
}
}

tasks.withType<JavaCompile>().configureEach {
sourceCompatibility = javaVersion.toString()
targetCompatibility = javaVersion.toString()
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().configureEach {
kotlinOptions {
jvmTarget = javaVersion.toString()
}
}
}

tasks.register("clean", Delete::class) {
Expand All @@ -53,3 +115,4 @@ tasks.register("install") {
dependsOn(publishTasks)
}

apply(from = "gradle/merge-reports.gradle")
27 changes: 6 additions & 21 deletions formula-android-compose/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,34 +9,17 @@ apply {
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
}
namespace = "com.instacart.formula.android.compose"

buildFeatures {
compose = true
}

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

composeOptions {
kotlinCompilerVersion = libs.versions.kotlin.get()
kotlinCompilerExtensionVersion = libs.versions.compose.get()
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

task<Jar>("sourcesJar") {
from(android.sourceSets["main"].java.srcDirs)
archiveClassifier.set("sources")
Expand All @@ -45,9 +28,11 @@ task<Jar>("sourcesJar") {
task<Javadoc>("javadoc") {
isFailOnError = false
source(android.sourceSets["main"].java.getSourceFiles())
classpath += project.files(android.bootClasspath.joinToString(separator = File.pathSeparator))
classpath += configurations.api
classpath += configurations.implementation
classpath = project.files(
android.bootClasspath.joinToString(separator = File.pathSeparator),
configurations.api,
configurations.implementation
)
}

task<Jar>("javadocJar") {
Expand Down
2 changes: 1 addition & 1 deletion formula-android-compose/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.instacart.formula.android.compose"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import com.instacart.formula.android.ViewFactory
import com.jakewharton.rxrelay3.BehaviorRelay


abstract class ComposeViewFactory<RenderModel> : ViewFactory<RenderModel> {
abstract class ComposeViewFactory<RenderModel : Any> : ViewFactory<RenderModel> {

override fun create(inflater: LayoutInflater, container: ViewGroup?): FeatureView<RenderModel> {
val view = ComposeView(inflater.context)
Expand Down
17 changes: 2 additions & 15 deletions formula-android-tests/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,14 @@ apply {
}

android {
compileSdk = 28
namespace = "com.instacart.formula"
defaultConfig {
applicationId = "com.instacart.formula.samples"
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = 28 // Using sdk 28 for robolectric tests.
applicationId = "com.instacart.formula"
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}

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

buildTypes {
release {
isMinifyEnabled = false
Expand All @@ -38,12 +31,6 @@ android {
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(project(":formula-rxjava3"))
implementation(project(":formula-android"))
Expand Down
3 changes: 1 addition & 2 deletions formula-android-tests/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.instacart.formula">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application android:allowBackup="true"
android:label="@string/app_name"
Expand Down
28 changes: 7 additions & 21 deletions formula-android/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,13 @@ apply {
}

android {
compileSdk = libs.versions.compileSdk.get().toInt()

defaultConfig {
minSdk = libs.versions.minSdk.get().toInt()
targetSdk = libs.versions.targetSdk.get().toInt()
}

compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
namespace = "com.instacart.formula.android"

testOptions {
unitTests.isReturnDefaultValues = true
}
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

task<Jar>("sourcesJar") {
from(android.sourceSets["main"].java.srcDirs)
archiveClassifier.set("sources")
Expand All @@ -42,9 +26,11 @@ task<Jar>("sourcesJar") {
task<Javadoc>("javadoc") {
isFailOnError = false
source(android.sourceSets["main"].java.getSourceFiles())
classpath += project.files(android.bootClasspath.joinToString(separator = File.pathSeparator))
classpath += configurations.api
classpath += configurations.implementation
classpath = project.files(
android.bootClasspath.joinToString(separator = File.pathSeparator),
configurations.api,
configurations.implementation
)
}

task<Jar>("javadocJar") {
Expand All @@ -70,7 +56,7 @@ dependencies {
testImplementation(libs.androidx.test.runner)
testImplementation(libs.espresso.core)
testImplementation(libs.truth)
testImplementation(libs.mockito.inline)
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.kotlin)
testImplementation(libs.kotlin.reflect)
}
2 changes: 1 addition & 1 deletion formula-android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<manifest package="com.instacart.formula.android"/>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"/>
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package com.instacart.formula

import com.google.common.truth.Truth.assertThat
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.spy
import com.nhaarman.mockito_kotlin.whenever
import org.junit.Test
import org.mockito.internal.stubbing.answers.CallsRealMethods
import org.mockito.kotlin.mock
import org.mockito.kotlin.whenever

class MockitoFormulaTest {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ import androidx.fragment.app.FragmentActivity
import androidx.lifecycle.Lifecycle
import com.instacart.formula.android.internal.ActivityStoreContextImpl
import com.jakewharton.rxrelay3.PublishRelay
import com.nhaarman.mockito_kotlin.mock
import com.nhaarman.mockito_kotlin.verify
import com.nhaarman.mockito_kotlin.verifyZeroInteractions
import com.nhaarman.mockito_kotlin.whenever
import io.reactivex.rxjava3.core.Observable
import kotlinx.parcelize.Parcelize
import org.junit.Before
import org.junit.Test
import org.mockito.kotlin.mock
import org.mockito.kotlin.verify
import org.mockito.kotlin.verifyNoInteractions
import org.mockito.kotlin.whenever

class ActivityStoreContextTest {
class FakeActivity : FragmentActivity() {
Expand Down Expand Up @@ -58,7 +58,7 @@ class ActivityStoreContextTest {
doSomething()
}

verifyZeroInteractions(activity)
verifyNoInteractions(activity)
}

@Test fun `send event success`() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package com.instacart.formula.android
import androidx.fragment.app.FragmentActivity
import com.google.common.truth.Truth.assertThat
import com.instacart.formula.android.internal.ActivityStoreFactory
import com.nhaarman.mockito_kotlin.mock
import org.junit.Test
import org.mockito.kotlin.mock

class ActivityStoreFactoryTest {

Expand Down
11 changes: 0 additions & 11 deletions formula-coroutines/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,6 @@ plugins {
id("kotlin")
}

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

dependencies {
implementation(libs.kotlin)
implementation(libs.coroutines)
Expand All @@ -18,10 +13,4 @@ dependencies {
testImplementation(libs.truth)
testImplementation(libs.junit)
testImplementation(libs.coroutines.test)
}

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
}
}
5 changes: 0 additions & 5 deletions formula-lint/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,6 @@ apply {
from("$rootDir/.buildscript/configure-signing.gradle")
}

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

dependencies {
compileOnly(libs.lint.api)
compileOnly(libs.lint.checks)
Expand Down
15 changes: 0 additions & 15 deletions formula-rxjava3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,6 @@ apply {
from("$rootDir/.buildscript/configure-signing.gradle")
}

repositories {
mavenCentral()
}

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

tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile>().all {
kotlinOptions {
jvmTarget = "1.8"
}
}

dependencies {
implementation(libs.kotlin)

Expand Down
Loading
Loading