- 
                Notifications
    
You must be signed in to change notification settings  - Fork 561
 
Description
The current binding infrastructure is "janky":
- "Somehow obtain" a 
.aaror.jarfile to bind. - Add it to a Binding project, and set the appropriate build action, e.g. 
@(LibraryProjectZip)or@(EmbeddedJar). - Build it.
 
In practice, (1) and (3) can be incredibly annoying. (At least for @jonpryor, it's not always obvious where to obtain the files referenced by a Maven artifact, and (3) is full of peril.)
(3) will remain "out of scope" for this vision; fixing (3) involves ensuring that generator can always emit compilable output, and that we expand the Java constructs that generator supports.  We should absolutely do this, but addressing these deficits involves finding the "less-than-ideal" constructs, filing issues for them, and fixing them.
Which leaves (1) and (2): can anything be done there?
Artifact Retrieval & Binding
Instead of a .aar or .jar file as being the "primary starting point", can we instead have a Maven artifact ID be the primary point?
Then, given a set of Maven artifact IDs:
- Specify the Maven IDs.
 - Obtain the entire dependency graph for the maven artifacts.
 - Find existing bindings for everything within (1).
 - For any dependencies not already bound, bind them.
 
Specify the Maven IDs
How should the Maven IDs be specified? What's the "user interface"?
Obtain Maven Dependency Graph
I believe @moljac has code to do this, as part of Binderator: https://github.com/xamarin/XamarinComponents/tree/master/Util/Xamarin.AndroidBinderator
Find existing bindings
It appears that NuGet.org allows searching arbitrary package metadata. If we ensure that all new NuGet packages contain NuGet.org-searchable package metadata containing the Maven artifact ID & version, then it should be possible to find existing bindings.
@moljac is working on this.
Bind unbound packages
For any maven artifacts in the dependency graph which haven't been bound, presumably including the "root" dependencies, we should bind them.
Proposal: Item Group?
We can imagine using an MSBuild item group to specify the "root" maven IDs, either directly:
<MavenArtifact Include="androidx.car" ArtifactId="car" Version="1.0.0-alpha7" />or by using a file (file format? Gradle? JSON? XML?) to contain the information.
Implicit in this idea is that these are like @(PackageReference) item group: the containing .csproj can have as many of them as desired, which in turn means that the .csproj could emit "many" output assemblies (dozens?), one per bound library as well as the "intentioned" output assembly.
Additionally, how would @(TransformFile) (e.g. metadata.xml) work in such an environment?  All @(TransformFile)s apply to all unbound artifacts?
Proposal: dotnet new?
Instead of using an item group, add a new tool, e.g.
dotnet new maven-binding --group-id androidx.car --artifact-id car --version 1.0.0-alpha7
This command would in turn emit a solution, with one .csproj project per unbound artifact.  This "answers" the @(TransformFile) question: each project uses has its own set of @(TransformFile)s.
Less well defined is this: how does one update an existing "binding solution"?  Changing the root artifact version will "ripple" across the entire solution; is it possible to update such a directory tree in-place?  Or would we need to re-invoke the dotnet new maven-binding command into a new directory, and require the user manually copy over any required @(TransformFile)s & partial classes and such?