takahirom / roborazzi

Make JVM Android integration test visible 🤖📸
https://takahirom.github.io/roborazzi/
Apache License 2.0
708 stars 34 forks source link

Gradle Isolated Projects Support #497

Open trevjonez opened 2 weeks ago

trevjonez commented 2 weeks ago

I am starting to work thru issues coming from constraints imposed by the Isolated Projects feature coming in gradle. The razzi plugin seems to have some property lookups that are likely easily fixed by using some alternative APIs.

Project `:analytics:impl` cannot dynamically look up a property in the parent project `:analytics`
        - Exception at `io.github.takahirom.roborazzi.RoborazziPlugin.apply$configureRoborazziTasks(RoborazziPlugin.kt:221)`
org.gradle.api.InvalidUserCodeException: Project ':analytics:impl' cannot dynamically look up a property in the parent project ':analytics'
    at org.gradle.api.internal.project.DefaultProject.getProperties(DefaultProject.java:1235)
    at io.github.takahirom.roborazzi.RoborazziPlugin.apply$configureRoborazziTasks(RoborazziPlugin.kt:221)
    at io.github.takahirom.roborazzi.RoborazziPlugin.apply$configureRoborazziTasks$default(RoborazziPlugin.kt:137)
    at io.github.takahirom.roborazzi.RoborazziPlugin$apply$configureComponents$1.invoke(RoborazziPlugin.kt:467)
    at io.github.takahirom.roborazzi.RoborazziPlugin$apply$configureComponents$1.invoke(RoborazziPlugin.kt:454)
    at com.android.build.api.extension.impl.AndroidComponentsExtensionImpl$onVariants$1.execute(AndroidComponentsExtensionImpl.kt:75)
    at com.android.build.api.extension.impl.AndroidComponentsExtensionImpl$onVariants$1.execute(AndroidComponentsExtensionImpl.kt:74)
    at com.android.build.api.extension.impl.OperationsRegistrar.executeOperations(OperationsRegistrar.kt:60)

https://github.com/takahirom/roborazzi/blob/2e4b3eb9a77f2ca85bef581fc12a55364df2f0bd/include-build/roborazzi-gradle-plugin/src/main/java/io/github/takahirom/roborazzi/RoborazziPlugin.kt#L221

It seems the typical project level properties lookups will walk the project tree causing a break. I believe it should be safe to migrate that lookup to using the providers api.

providers.gradlePropertiesPrefixedBy("roborazzi").get().etc()

There may be other issues still but this seems to be all I can get from the issue report as things are today.

takahirom commented 2 weeks ago

I was able to fix the problem related to this issue. I believe this doesn't affect the user's project, but there are some allProjects{} configurations and some setups for Roborazzi. Therefore, I haven't been able to check if the test passes yet.

313 problems were found storing the configuration cache, 78 of which seem unique.
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': Project ':roborazzi' cannot access 'Project.configurations' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': Project ':roborazzi' cannot access 'Project.plugins' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': Project ':roborazzi' cannot access 'Project.tasks' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': Project ':roborazzi' cannot access 'android' extension on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': Project ':roborazzi' cannot access 'java' extension on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': Project ':roborazzi' cannot access 'libs' extension on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 18: Project ':roborazzi' cannot access 'libs' extension on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 19: Project ':roborazzi' cannot access 'libs' extension on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 24: Project ':roborazzi' cannot access 'Project.plugins' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 32: Project ':roborazzi' cannot access 'Project.plugins' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 41: Project ':roborazzi' cannot access 'Project.tasks' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 46: Project ':roborazzi' cannot access 'Project.tasks' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 57: Project ':roborazzi' cannot access 'Project.plugins' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/build.gradle': line 87: Project ':roborazzi' cannot access 'Project.configurations' functionality on subprojects via 'allprojects'
- Build file '/Users/xxxxxx/git/roborazzi/include-build/build.gradle': Project ':roborazzi:include-build' cannot access 'Project.plugins' functionality on subprojects via 'allprojects'
takahirom commented 2 weeks ago

I created an issue for this subtask. https://github.com/takahirom/roborazzi/issues/500

takahirom commented 2 weeks ago

@trevjonez I've released a version that uses gradlePropertiesPrefixedBy. Could you check it again? https://github.com/takahirom/roborazzi/releases/tag/1.28.0

trevjonez commented 2 weeks ago

Just ran it again as far as it can go and the report no longer has anything from it in razzi.

Down to primarily KSP/Hilt as the two big sources of issue now.

Might be good to leave this open a bit longer so people that are able to get further in the build have a place to dump additional info?