Repository navigation
fix(build): declare buildMetadata's real inputs - #2095
Merged
Merged
Conversation
… type buildMetadata registered the compiled-class directories as inputs only if they already existed at configuration time. Its outputs live in app/src/main/assets/metadata, outside build/, so after `rm -rf app/build` the task had no class inputs, was considered UP-TO-DATE and was skipped: the APK shipped stale metadata and newly added Java/Kotlin classes were undefined from JS. It also declared the whole intermediates/javac and tmp/kotlin-classes directories, covering every variant. Assembling a variant other than project.ext.selectedBuildType (e.g. assembleRelease without -Prelease) with that variant's classes already present failed Gradle's validation: "Task ':app:buildMetadata' uses this output of task ':app:compileReleaseJavaWithJavac' without declaring an explicit or implicit dependency". Declare, lazily and unconditionally, exactly the directories the task's doFirst reads: intermediates/javac/<selectedBuildType> and tmp/kotlin-classes/<selectedBuildType> of every subproject. The app's own compile tasks were already dependencies; order after the other subprojects' compile tasks of the selected build type with mustRunAfter so library-only builds are not pulled into an app build.
|
Caution Review failedThe pull request is closed.
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. |
…sing file
buildMetadata declared inputs.files("mdg-java-dependencies.txt"), which
resolves against the app project directory where no such file exists;
the list lives in build-tools/. Adding, removing or replacing a
dependency jar (an App_Resources/Android/libs jar, a plugin jar, or an
updated AAR) therefore never re-ran the generator unless the app's own
classes also changed, and the APK kept stale metadata for the library.
Pointing the input at the real file is not enough: collectAllJars
rewrites it every build and buildMetadata's doFirst appends the class
directories to it, so the task would be fingerprinting a file it
mutates. Instead, declare the jar files the list names (".jar" lines
only; the class directories are already the compiledClasses input),
resolved through a provider so the list is read after collectAllJars
has written it.
edusperoni
marked this pull request as ready for review
November 8, 2026 21:01
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes how the
buildMetadatatask intest-app/app/build.gradledeclares its inputs. That file is copied into the app template, so this affects every app's build.Stale metadata after a clean build. The task registered the compiled-class directories as inputs only if they already existed at configuration time. Its outputs live in
app/src/main/assets/metadata, outsidebuild/. So afterrm -rf app/build(a clean build with existing metadata) the task had no class inputs, was considered UP-TO-DATE, and was skipped. The APK then shipped stale metadata, and newly added Java/Kotlin classes wereundefinedfrom JS.Validation failure when assembling the non-selected variant. The task declared the whole
intermediates/javacandtmp/kotlin-classesdirectories, covering every variant. Assembling a variant other thanselectedBuildTypewhile that variant's classes already existed (for exampleassembleReleasewithout-Prelease) failed with:The fix: declare, lazily and unconditionally, exactly the directories the task's
doFirstreads:intermediates/javac/<selectedBuildType>andtmp/kotlin-classes/<selectedBuildType>of every subproject.mustRunAfter). Unrelated library modules are never pulled into an app build, and nofinalizedByhooks are added.Dependency jars weren't inputs either.
inputs.files("$MDG_JAVA_DEPENDENCIES")resolved toapp/mdg-java-dependencies.txt, a path that doesn't exist; the real list is underbuild-tools/. So changing a dependency jar alone (a plugin update, or a jar inApp_Resources/Android/libs) didn't re-run the task. Pointing at the right file isn't enough:collectAllJarsrewrites that list on every build, andbuildMetadata's owndoFirstappends the class directories to it, so the task would be watching a file it mutates. The second commit instead fingerprints the jar files the list names, filtered to.jarentries. The list is read through a provider, so it is current:collectAllJarsalways runs first.Verification
All runs used
-Pabis=arm64-v8a -PuseKotlin=true. "Count" isgrep -a -c <class>ontreeStringsStream.dat.Debug:
rm -rf app/build, buildRelease (
-Preleasewith signing props): clean build passes, a second no-clean build is UP-TO-DATE and passes, and a new class after a clean build is present.Non-selected variant:
:app:mergeReleaseAssetswithout-Prelease, with release classes present, now passes the validation.Dry runs: debug and release task graphs have no cycles and order the compile tasks before
buildMetadata.:runtime:assembleReleasepulls in no:app:tasks.Dependency jars: a probe jar added under
App_Resources/Android/libsre-runs the task and shows up in metadata. Replacing it with a new version re-runs it again, and removing it re-runs it and drops the class. Two or three consecutive no-change builds stay UP-TO-DATE, so the appended class folders never cause reruns. Release: the first build runs the task, and the next two are UP-TO-DATE.Notes
Does your pull request have unit tests?
No. This is build wiring, verified by the build matrix above.