Fixed
Status Update
Comments
je...@google.com <je...@google.com>
je...@google.com <je...@google.com> #2
Hi,
I'm not sure I get what you were expecting and what was the outcome.
Even if the build directory is moved, AGP can still just fetch everything from cache since none of the input files changed.
Can you please share the steps to reproduce the issue and what you were expecting?
da...@spotify.com <da...@spotify.com> #3
Hi,
If I have a build output folder called "build" and I run :app:generateReleaseUnitTestConfig, there will be a properties file generated in
app/build/intermediates/unit_test_config_directory/releaseUnitTest/out/com/android/tools/test_config.properties
Its contents are going to be
#Generated by the Android Gradle plugin
android_custom_package=com.app
android_merged_assets=build/intermediates/merged_assets/release/out
android_merged_manifest=build/intermediates/merged_manifests/release/../../library_manifest/release/AndroidManifest.xml
android_resource_apk=build/intermediates/apk_for_local_test/releaseUnitTest/packageReleaseUnitTestForUnitTest/apk-for-local-test.ap_
If I then rename the build output folder to "newbuild" (through buildDir='newbuild' in the Gradle scripts) and rerun :app:generateReleaseUnitTestConfig, it will use a cached result put in
app/newbuild/intermediates/unit_test_config_directory/releaseUnitTest/out/com/android/tools/test_config.properties
but it will still contain the same contents as before. The problem is that when you then run e.g. Robolectric tests, it will look for the test resources in a build folder that no longer exists (since they now reside in "newbuild"), and tests will fail.
If I have a build output folder called "build" and I run :app:generateReleaseUnitTestConfig, there will be a properties file generated in
app/build/intermediates/unit_test_config_directory/releaseUnitTest/out/com/android/tools/test_config.properties
Its contents are going to be
#Generated by the Android Gradle plugin
android_custom_package=
android_merged_assets=build/intermediates/merged_assets/release/out
android_merged_manifest=build/intermediates/merged_manifests/release/../../library_manifest/release/AndroidManifest.xml
android_resource_apk=build/intermediates/apk_for_local_test/releaseUnitTest/packageReleaseUnitTestForUnitTest/apk-for-local-test.ap_
If I then rename the build output folder to "newbuild" (through buildDir='newbuild' in the Gradle scripts) and rerun :app:generateReleaseUnitTestConfig, it will use a cached result put in
app/newbuild/intermediates/unit_test_config_directory/releaseUnitTest/out/com/android/tools/test_config.properties
but it will still contain the same contents as before. The problem is that when you then run e.g. Robolectric tests, it will look for the test resources in a build folder that no longer exists (since they now reside in "newbuild"), and tests will fail.
je...@google.com <je...@google.com> #4
Can you please provide a toy project where I can reproduce the issue?
da...@spotify.com <da...@spotify.com> #5
Sure thing, I believe this should do the trick. Check build.gradle header for reproduction instructions.
Description
As a workaround, this works nicely:
tasks.withType(GenerateTestConfig).configureEach {
String relativeBuildDir = projectDir.toPath().relativize(buildDir.toPath()).toString()
it.inputs.property('buildDir', relativeBuildDir)
}
Gradle version: 6.0.1
Android Plugin Version: 3.5.3
Module Compile Sdk Version: N/A
Module Build Tools Version: N/A
Android SDK Tools version: N/A