Skip to content

Fix Bind=false binding dependencies - #12381

Open
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-fix-bind-false-dependencies
Open

Fix Bind=false binding dependencies#12381
jonathanpeppers wants to merge 3 commits into
mainfrom
jonathanpeppers-fix-bind-false-dependencies

Conversation

@jonathanpeppers

Copy link
Copy Markdown
Member

Summary

  • preserve Bind and Pack metadata while categorizing binding dependencies
  • package Bind=false JAR dependencies in binding NuGet/generated AAR outputs
  • expose Bind=false JAR and AAR types as reference-only generator inputs without generating bindings for them
  • process bound and reference inputs through single ClassParse and ExtractJarsFromAar task invocations
  • add focused packaging, generator-resolution, task argument, and stale-output regression coverage

Fixes #10481
Fixes #10668

Validation

  • Xamarin.Android.Build.Tests.csproj build
  • generator-Tests: 489 passed
  • BindFalseAndroidLibraryResolvesGeneratorTypes: 4 passed
  • AndroidLibraryPackMetadataIsPreservedInNuGet: 2 passed
  • BuildAarBindingLibraryStandalone: 2 passed
  • focused ClassParse and ExtractJarsFromAar task tests: 5 passed

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
Copilot AI lite review requested due to automatic review settings August 13, 2026 21:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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-parse emits a reference API XML, and generator consumes 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.

Comment thread src/Xamarin.Android.Build.Tasks/Tasks/ClassParse.cs
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
@jonathanpeppers

Copy link
Copy Markdown
Member Author

/review

@github-actions

github-actions Bot commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Android PR Reviewer completed successfully!

Generated by Android PR Reviewer for #12381

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Needs Changes

Found 2 errors:

  • The reference API item is lost when _ExportJarToXml is 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

Comment thread src/Xamarin.Android.Build.Tasks/Tasks/ExtractJarsFromAar.cs Outdated
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants