Fix Bind=false binding dependencies - #12381
Conversation
Treat Bind=false JAR and AAR inputs as reference-only dependencies so their types resolve during binding generation without generating managed bindings for them. Preserve packaging metadata and process source and reference inputs through single task invocations. Fixes #10481 Fixes #10668 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e7acc46-f300-4f95-802f-96c02ef45817
There was a problem hiding this comment.
Pull request overview
This PR fixes binding-library dependency handling when Bind=false is used, ensuring those JAR/AAR dependencies are packaged appropriately while still participating in generator type resolution (without generating bindings for the dependency types themselves). The changes span MSBuild target plumbing, build tasks, the class-parse tool, and the Java.Interop generator pipeline, with added regression-focused test coverage.
Changes:
- Add “reference-only” Java API flow:
class-parseemits a reference API XML, andgeneratorconsumes it (--java-reference) to keep dependency types resolvable without binding them. - Extend AAR extraction to handle both bound and reference library categories (and clean stale reference outputs).
- Add tests covering reference argument wiring, packaging behavior, generator type resolution, and stale-output cleanup.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/ExtractJarsFromAarTests.cs | Adds a task test ensuring bound + reference AAR extraction and stale reference cleanup. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Tasks/AndroidDotnetToolTests.cs | Adds a test validating ClassParse writes --reference* arguments to the response file. |
| src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/BindingBuildTest.cs | Adds/updates integration tests for NuGet packaging and generator resolution with Bind=false inputs. |
| src/Xamarin.Android.Build.Tasks/Tasks/Generator.cs | Plumbs JavaReferenceApiXml into generator invocation via --java-reference. |
| src/Xamarin.Android.Build.Tasks/Tasks/ExtractJarsFromAar.cs | Adds reference extraction output dirs + reference library handling and cleanup. |
| src/Xamarin.Android.Build.Tasks/Tasks/ClassParse.cs | Adds response-file arguments for reference jars + reference API output. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.Core.targets | Adds reference-jar item ingestion from extracted reference libs and cleans new intermediates. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.Bindings.ClassParse.targets | Wires reference jars/output into ClassParse and passes reference API into BindingsGenerator. |
| src/Xamarin.Android.Build.Tasks/MSBuild/Xamarin/Android/Xamarin.Android.AvailableItems.targets | Introduces ReferenceJar and _AndroidReferenceLibraryProjectZip categorization from @(AndroidLibrary). |
| src/Xamarin.Android.Build.Tasks/Microsoft.Android.Sdk/targets/Microsoft.Android.Sdk.AndroidLibraries.targets | Updates _ExtractAar to extract both bound and reference categories with correct dependencies/inputs. |
| external/Java.Interop/tools/generator/Java.Interop.Tools.Generator.Transformation/JavaTypeResolutionFixups.cs | Allows fixup to consider reference-only Java API XML types during resolution. |
| external/Java.Interop/tools/generator/CodeGeneratorOptions.cs | Adds --java-reference option plumbing into generator options. |
| external/Java.Interop/tools/generator/CodeGenerator.cs | Loads reference-only Java API XML and adds reference types into the generator’s type table. |
| external/Java.Interop/tools/class-parse/Program.cs | Adds --reference + --reference-output support and deletes stale reference output when no refs are provided. |
Resolve relative class-parse output paths safely and include the conditional reference API in incremental target outputs. Cover regeneration when the reference API file is missing. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e7acc46-f300-4f95-802f-96c02ef45817
|
/review |
|
✅ Android PR Reviewer completed successfully!
|
There was a problem hiding this comment.
⚠️ Needs Changes
Found 2 errors:
- The reference API item is lost when
_ExportJarToXmlis incrementally skipped, so a later generator-only rebuild can regress the behavior this PR adds. - The new task failure uses an uncoded, non-localized diagnostic.
The overall separation of bound and reference-only inputs is well structured, and the focused JAR/AAR, CoreCLR/NativeAOT, packaging, stale-output, and task coverage is strong. CI is green across all 44 checks.
Generated by Android PR Reviewer for #12381 · gpt56 · 149 AIC · ⌖ 8.93 AIC · ⊞ 28.2K
Comment /review to run again
Populate the reference API item in the inputs helper and make reference extraction output directories required task inputs, avoiding a new uncoded product diagnostic. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 5e7acc46-f300-4f95-802f-96c02ef45817
Summary
BindandPackmetadata while categorizing binding dependenciesBind=falseJAR dependencies in binding NuGet/generated AAR outputsBind=falseJAR and AAR types as reference-only generator inputs without generating bindings for themClassParseandExtractJarsFromAartask invocationsFixes #10481
Fixes #10668
Validation
Xamarin.Android.Build.Tests.csprojbuildgenerator-Tests: 489 passedBindFalseAndroidLibraryResolvesGeneratorTypes: 4 passedAndroidLibraryPackMetadataIsPreservedInNuGet: 2 passedBuildAarBindingLibraryStandalone: 2 passedClassParseandExtractJarsFromAartask tests: 5 passed