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

Fix an issue that Android Instrumentation Test fails #895

Merged
merged 12 commits into from Aug 29, 2022
Merged

This file was deleted.

11 changes: 10 additions & 1 deletion modules/mockk-agent-android-dispatcher/build.gradle.kts
Expand Up @@ -3,15 +3,24 @@ import buildsrc.config.asProvider
import com.android.build.gradle.internal.tasks.DexMergingTask

plugins {
buildsrc.convention.`android-application`
id("com.android.application")
Copy link
Contributor Author

@kubode kubode Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed android-application.gradle.kts since it is not used except for android-dispatcher module.
Instead, I moved the contents of android-application.gradle.kts to this build.gradle.kts.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intentional that build config that is shareable is defined in buildSrc, even if it's only used in one place. It helps keep the build logic organised and consistent. It makes it easier to compare and contrast the Android Library config to the Android Application config, and easier to see if there's any special treatment that's needed in the subprojects. So I think this should be reverted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, I think it is better to remove android-application.gradle.kts.
:mockk-agent-android-dispatcher module is a very specific Android Application module that only extracts the final DEX file, and the build configuration is completely independent and non-reusable.
If we were to add an Android sample application module in the future and try to reuse the configuration with :mockk-agent-android-dispatcher module, it would add an unnecessary dependency to :mockk-agent-android-dispatcher module and cause the same problems that encountered in this PR.

Copy link
Contributor

@aSemy aSemy Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think the dependency on :mockk-agent-android-dispatcher should be removed from the buildSrc script

edit: I read your comment too quickly and my response doesn't make sense! I'll have another look

}

@Suppress("UnstableApiUsage")
android {
compileSdk = 32

defaultConfig {
minSdk = 26
targetSdk = 32
applicationId = "com.android.dexmaker.mockito.inline.dispatcher"
versionCode = 1
}

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

val androidClassesDexProvider by configurations.registering {
Expand Down
4 changes: 2 additions & 2 deletions modules/mockk-agent-android/build.gradle.kts
Expand Up @@ -12,6 +12,8 @@ description = "Android instrumented testing MockK inline mocking agent"
val mavenName: String by extra("MockK Android Agent")
val mavenDescription: String by extra("${project.description}")

val dispatcherJarResPath: Provider<Directory> = layout.buildDirectory.dir("generated/dispatcher-jar")

kubode marked this conversation as resolved.
Show resolved Hide resolved
@Suppress("UnstableApiUsage")
android {
externalNativeBuild {
Expand Down Expand Up @@ -60,8 +62,6 @@ dependencies {
androidClassesDex(projects.modules.mockkAgentAndroidDispatcher)
}

val dispatcherJarResPath: Provider<Directory> = layout.buildDirectory.dir("generated/dispatcher-jar")

val packageDispatcherJar by tasks.registering(Jar::class) {
group = LifecycleBasePlugin.BUILD_GROUP
from(androidClassesDex.asFileTree)
Expand Down