KEMBAR78
Fix AndroidLibrary Pack='false' ignoring jar exclusion from AAR packages by Copilot · Pull Request #10365 · dotnet/android · GitHub
Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 1, 2025

The CreateAar task was not respecting the Pack='false' metadata on AndroidLibrary items, causing jar files to be included in AAR packages even when explicitly marked for exclusion.

Problem

When using .NET binding projects with AndroidLibrary items set to Pack='false', developers expected the jar files to be excluded from the generated AAR package. However, the CreateAar task was ignoring this metadata and including all jar files regardless of the Pack setting.

This caused issues for developers who wanted to:

  • Reference binding projects without packaging the underlying jar files
  • Create modular architectures where jars are packaged separately
  • Avoid duplicate jar inclusion in complex dependency scenarios

Solution

Modified the jar processing loop in CreateAar.cs to:

  • Check the Pack metadata on each jar file item
  • Skip jars with Pack='false' using continue;
  • Add debug logging for transparency when jars are skipped
  • Preserve default behavior (include jars when Pack is unspecified or 'true')

Testing

Added comprehensive test AndroidLibraryPackFalseExcludesJarFromAar that:

  • Creates a binding project with both Pack='false' and default Pack jars
  • Verifies the AAR is generated successfully
  • Examines actual AAR contents to confirm Pack='false' jars are excluded
  • Confirms default behavior jars are still included

All existing binding and AAR generation tests continue to pass, ensuring no regressions.

Fixes #8504.


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot AI changed the title [WIP] AndroidLibrary Pack='false' adds .jar to NuGet package Fix AndroidLibrary Pack='false' ignoring jar exclusion from AAR packages Aug 1, 2025
Copilot AI requested a review from jonathanpeppers August 1, 2025 19:28
Copilot finished work on behalf of jonathanpeppers August 1, 2025 19:28
…se default CreateDllBuilder

Co-authored-by: jonathanpeppers <840039+jonathanpeppers@users.noreply.github.com>
Copilot finished work on behalf of jonathanpeppers August 1, 2025 19:57
@jonathanpeppers
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Member

@jonathanpeppers jonathanpeppers left a comment

Choose a reason for hiding this comment

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

New test is working:

image

@copilot take no action on this review.

@jonathanpeppers jonathanpeppers marked this pull request as ready for review August 4, 2025 13:10
@jonathanpeppers jonathanpeppers enabled auto-merge (squash) August 4, 2025 13:12
@jonathanpeppers jonathanpeppers merged commit dd00d48 into main Aug 4, 2025
60 checks passed
@jonathanpeppers jonathanpeppers deleted the copilot/fix-8504 branch August 4, 2025 14:02
@github-actions github-actions bot locked and limited conversation to collaborators Sep 4, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AndroidLibrary Pack='false' adds .jar to NuGet package

3 participants