jpobst / Prototype.Android.MavenBindings

Prototype of MSBuild tasks to facilitate binding of Java libraries from Maven repositories
MIT License
5 stars 3 forks source link

Build is not Respecting `Bind="false"` attribute #12

Open jasells-bloomerang opened 1 month ago

jasells-bloomerang commented 1 month ago

I know this is marked as no longer maintained due to being integrated in .Net9 build system, however, hopefully @jpobst is still monitoring and can let me know if it is fixed in .Net9, or not. (I have played with the pre-release, but not in this scenario, only a single native import/include)

The issue seems to only arise when I have multiple includes, like:

<!--<AndroidLibrary Update="Jars\ktor-http-jvm-2.3.2.jar" Bind="false" Pack="true" />-->
<AndroidMavenLibrary Include="io.ktor:ktor-http-jvm" Version="2.3.2" Repository="Central" VerifyDependencies="true" Bind="false" />
<!--<AndroidLibrary Update="Jars\ktor-utils-jvm-2.3.2.jar" Bind="false" Pack="true" />-->
<AndroidMavenLibrary Include="io.ktor:ktor-utils-jvm" Version="2.3.2" Repository="Central" VerifyDependencies="true" Bind="false" />

You can see the "standard" .Net8/7 build nodes commented, which correctly skip the binding step. When using this package, the binding step runs, giving me errors in C#-generated code, unless I use x-path in Metadata.xml to force-remove all the types in the native lib to "skip" the binding step. Ktor is a "framework" of ~12 libs, so I'd like to just make a single .nupkg in this case as a "roll-up" per version.

luckily... I already built a little xml parser/generator to read the generated Api.xml and then generate the Metadata.xml file for me since I was doing this pre-.Net7/6 and the AndroidLibrary upgrade.

Hopefully, this will at least help to get a fix in the .Net9 system?

jpobst commented 1 month ago

This seems to compile fine on .NET 9 P3 and does not produce any generated C# binding code:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net9.0-android</TargetFramework>
    <SupportedOSPlatformVersion>21</SupportedOSPlatformVersion>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <IsTrimmable>true</IsTrimmable>
  </PropertyGroup>

  <ItemGroup>
    <AndroidMavenLibrary Include="io.ktor:ktor-http-jvm" Version="2.3.2" Repository="Central" VerifyDependencies="false" Bind="false" />
    <AndroidMavenLibrary Include="io.ktor:ktor-utils-jvm" Version="2.3.2" Repository="Central" VerifyDependencies="false" Bind="false" />
  </ItemGroup>
</Project>
jasells commented 1 month ago

@jpobst

Ok, once I completed migrating all my native artifacts to use the <AndroidMavenLibrary> the code-gen stopped. I think I had some .jars still in the local /Jars/ directory that I had migrated to use <AndroidMavenLibrary> or just the fact that I had a mix of <AndroidLibrary> and <AndroidMavenLibrary> nodes was confusing the build system?

Here's a link to the branch now successfully building w/o binding, using .Net8 SDK! https://xdevapps.visualstudio.com/DefaultCollection/Android%20bindings/_git/XDev.IO.Ktor.Core?version=GBdev-net8

TY for this tool, it has saved me so much time!