зеркало из https://github.com/xamarin/AndroidX.git
Begin streamlining default template. (#932)
Begin streamlining and updating the default project template. There are two goals here: - Modernize appearance and metadata by removing "Xamarin" branding and verbiage, shifting more towards ".NET for Android" branding. - Begin making the default project template more generic and configurable via `config.json`. The desire here is to reduce maintenance burden by making the default template flexible enough that library-specific templates (like `kotlin` or `tink`) are no longer required. (Currently we maintain 46 template sets across AndroidX and GPS repos, the majority of which only have minor differences.)
This commit is contained in:
Родитель
0835812542
Коммит
646527a687
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 2.1 KiB |
Двоичные данные
icons/Xamarin.AndroidX_1024x1024.png
Двоичные данные
icons/Xamarin.AndroidX_1024x1024.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 40 KiB |
Двоичные данные
icons/Xamarin.AndroidX_128x128.png
Двоичные данные
icons/Xamarin.AndroidX_128x128.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 4.8 KiB |
Двоичные данные
icons/Xamarin.AndroidX_nuget.png
Двоичные данные
icons/Xamarin.AndroidX_nuget.png
Двоичный файл не отображается.
До Ширина: | Высота: | Размер: 4.8 KiB |
|
@ -62,6 +62,14 @@ if (nu_diffs.Any()) {
|
|||
input.CopyTo(output);
|
||||
Console.WriteLine();
|
||||
}
|
||||
|
||||
// Delete the individual file because it makes the assembly diffs hard to find
|
||||
System.IO.File.Delete(file.FullPath);
|
||||
|
||||
var dir = System.IO.Path.GetDirectoryName(file.FullPath);
|
||||
|
||||
if (System.IO.Directory.GetFileSystemEntries(dir).Length == 0)
|
||||
System.IO.Directory.Delete(dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
@using System
|
||||
@model AndroidBinderator.BindingProjectModel
|
||||
@using System
|
||||
@using System.Linq
|
||||
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<!-- Build properties -->
|
||||
<PropertyGroup>
|
||||
<TargetFrameworks>$(_DefaultTargetFrameworks)</TargetFrameworks>
|
||||
<IsBindingProject>true</IsBindingProject>
|
||||
<AssemblyName>@(Model.NuGetPackageId)</AssemblyName>
|
||||
<AssemblyName>@Model.GetAssemblyName()</AssemblyName>
|
||||
<AndroidUseIntermediateDesignerFile>false</AndroidUseIntermediateDesignerFile>
|
||||
<RootNamespace>@(Model.NuGetPackageId.Replace("Xamarin.", ""))</RootNamespace>
|
||||
<RootNamespace>@Model.GetRootNamespace()</RootNamespace>
|
||||
|
||||
<!--
|
||||
No warnings for:
|
||||
|
@ -17,42 +19,22 @@
|
|||
- CS0628: 'member' : new protected member declared in sealed class
|
||||
- CS0108: 'member1' hides inherited member 'member2'. Use the new keyword if hiding was intended.
|
||||
- CS0809: Obsolete member 'member' overrides non-obsolete member 'member'
|
||||
- CS1572: XML comment has a param tag for '', but there is no parameter by that name
|
||||
- CS1572: XML comment has a param tag for '', but there is no parameter by that name
|
||||
- XAOBS001: While this member is 'public', Google considers it internal API and reserves the right to modify or delete it in the future. Use at your own risk.
|
||||
-->
|
||||
<NoWarn>0618;0109;0114;0628;0108;0809;1572</NoWarn>
|
||||
<NoWarn>0618;0109;0114;0628;0108;0809;1572;XAOBS001</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
@{
|
||||
string[] artifact_version_parts = Model.NuGetVersion
|
||||
.Split(new string[] { "-" }, StringSplitOptions.None);
|
||||
string artifact_version = null;
|
||||
|
||||
string artifact_version_release = artifact_version_parts[0];
|
||||
string[] artifact_version_release_parts = artifact_version_release.Split(new string[] { "." }, StringSplitOptions.None);
|
||||
artifact_version = string.Join(".", artifact_version_release_parts, 0, 3);
|
||||
|
||||
if (artifact_version_parts.Length == 1)
|
||||
{
|
||||
// release
|
||||
}
|
||||
if (artifact_version_parts.Length == 2)
|
||||
{
|
||||
artifact_version += "-" + artifact_version_parts[1];
|
||||
}
|
||||
|
||||
// Whether to bind the Java .jar/.aar
|
||||
var bind_native_lib = Model.NuGetPackageId != "Xamarin.AndroidX.DataStore.Core.Jvm";
|
||||
|
||||
// Whether to include the Java .jar/.aar
|
||||
var include_native_lib = Model.NuGetPackageId != "Xamarin.AndroidX.DataStore.Core.Jvm";
|
||||
}
|
||||
|
||||
<!-- NuGet package properties -->
|
||||
<PropertyGroup>
|
||||
<PackageId>@(Model.NuGetPackageId)</PackageId>
|
||||
<Title>.NET for Android (formerly Xamarin.Android) AndroidX - @(Model.Name)</Title>
|
||||
<Summary>.NET for Android (formerly Xamarin.Android) bindings for AndroidX - @(Model.Name)</Summary>
|
||||
<Description>.NET for Android (formerly Xamarin.Android) bindings for AndroidX library '@(Model.MavenGroupId):@(Model.Name)'.</Description>
|
||||
<PackageTags>.NET for Android Xamarin AndroidX Xamarin.AndroidX Support Google @(Model.Name) artifact=@(Model.MavenGroupId):@(Model.Name) artifact_versioned=@(Model.MavenGroupId):@(Model.Name):@(artifact_version)</PackageTags>
|
||||
<Title>.NET for Android bindings for the Android Java library '@(Model.MavenGroupId):@(Model.Name)'.</Title>
|
||||
<Description>
|
||||
$(Title)@(Model.NuGetPackageId.StartsWith("Xamarin.AndroidX.Compose") ? " Note this package only adds the Java library to the application. C# bindings are not provided." : string.Empty)
|
||||
|
||||
@(!string.IsNullOrWhiteSpace(Model.MavenDescription) ? $"Library description: {Model.MavenDescription}" : string.Empty)
|
||||
</Description>
|
||||
<PackageTags>xamarin artifact=@(Model.MavenGroupId):@(Model.Name) artifact_versioned=@(Model.MavenGroupId):@(Model.Name):@(Model.GetArtifactVersion())</PackageTags>
|
||||
<PackageLicenseExpression>MIT AND Apache-2.0</PackageLicenseExpression>
|
||||
<PackageIcon>icon.png</PackageIcon>
|
||||
<PackageVersion>@(Model.NuGetVersion)$(PackageVersionSuffix)</PackageVersion>
|
||||
|
@ -60,16 +42,18 @@
|
|||
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
|
||||
</PropertyGroup>
|
||||
|
||||
<!-- Packaging files -->
|
||||
<ItemGroup>
|
||||
@if (include_native_lib) {
|
||||
@if (Model.ShouldIncludeArtifact) {
|
||||
<None Include="@(Model.NuGetPackageId).targets" Pack="True" PackagePath="@@(AndroidXNuGetTargetFolders)" />
|
||||
}
|
||||
<None Include="..\..\source\PackageLicense.md" Pack="True" PackagePath="LICENSE.md" />
|
||||
<None Include="..\..\External-Dependency-Info.txt" Pack="True" PackagePath="THIRD-PARTY-NOTICES.txt" />
|
||||
<None Include="..\..\icons\Xamarin.AndroidX_nuget.png" Pack="True" PackagePath="icon.png" />
|
||||
<None Include="..\..\build\icon.png" Pack="True" PackagePath="icon.png" />
|
||||
<None Include=".\readme.md" Pack="True" PackagePath="readme.md" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Proguard files -->
|
||||
@if (@Model.MavenArtifacts.Count > 0) {
|
||||
<ItemGroup>
|
||||
@foreach (var art in @Model.MavenArtifacts) {
|
||||
|
@ -80,6 +64,7 @@
|
|||
</ItemGroup>
|
||||
}
|
||||
|
||||
<!-- Binding compilation files -->
|
||||
<ItemGroup>
|
||||
<!-- Include AssemblyInfo.cs -->
|
||||
<Compile Include="..\..\source\AssemblyInfo.cs" />
|
||||
|
@ -105,26 +90,12 @@
|
|||
</TransformFile>
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
@foreach (var art in @Model.MavenArtifacts) {
|
||||
if (!bind_native_lib) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (art.MavenArtifactPackaging == "aar") {
|
||||
<None Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId).aar" Pack="True" PackagePath="aar\@(art.MavenGroupId).@(art.MavenArtifactId).aar" />
|
||||
} else {
|
||||
<None Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId).jar" Pack="True" PackagePath="jar\@(art.MavenGroupId).@(art.MavenArtifactId).jar" />
|
||||
}
|
||||
}
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@if (@Model.MavenArtifacts.Count > 0) {
|
||||
<!-- Java artifacts to bind -->
|
||||
<ItemGroup>
|
||||
@foreach (var art in @Model.MavenArtifacts)
|
||||
{
|
||||
if (!include_native_lib) {
|
||||
if (!Model.ShouldBindArtifact) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -147,81 +118,37 @@
|
|||
</ItemGroup>
|
||||
}
|
||||
|
||||
<!-- Java artifacts to include in the NuGet package -->
|
||||
<ItemGroup>
|
||||
@foreach (var art in @Model.MavenArtifacts) {
|
||||
if (!Model.ShouldIncludeArtifact) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (art.MavenArtifactPackaging == "aar") {
|
||||
<None Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId).aar" Pack="True" PackagePath="aar\@(art.MavenGroupId).@(art.MavenArtifactId).aar" />
|
||||
} else {
|
||||
<None Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId).jar" Pack="True" PackagePath="jar\@(art.MavenGroupId).@(art.MavenArtifactId).jar" />
|
||||
}
|
||||
}
|
||||
</ItemGroup>
|
||||
|
||||
<!-- ProjectReferences -->
|
||||
<ItemGroup>
|
||||
<!-- ProjectReference -->
|
||||
@foreach (var dep in @Model.NuGetDependencies) {
|
||||
if (dep.IsProjectReference) {
|
||||
<ProjectReference Include="..\..\generated\@(dep.MavenArtifact.MavenGroupId).@(dep.MavenArtifact.MavenArtifactId)\@(dep.MavenArtifact.MavenGroupId).@(dep.MavenArtifact.MavenArtifactId).csproj" PrivateAssets="none" PackageVersion="@GetProjectVersionString(dep.MavenArtifact.MavenArtifactVersion, dep.NuGetVersion)" />
|
||||
<ProjectReference Include="..\..\generated\@(dep.MavenArtifact.MavenGroupId).@(dep.MavenArtifact.MavenArtifactId)\@(dep.MavenArtifact.MavenGroupId).@(dep.MavenArtifact.MavenArtifactId).csproj" PrivateAssets="none" PackageVersion="@dep.GetProjectVersionString()" />
|
||||
}
|
||||
}
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<!-- PackageReferences -->
|
||||
<ItemGroup>
|
||||
<!-- PackageReference -->
|
||||
@foreach (var dep in @Model.NuGetDependencies) {
|
||||
if (!dep.IsProjectReference) {
|
||||
<PackageReference Include="@(dep.NuGetPackageId)" Version="@GetVersionString(dep.MavenArtifact.MavenArtifactVersion, dep.NuGetVersion)" PrivateAssets="none" />
|
||||
<PackageReference Include="@(dep.NuGetPackageId)" Version="@dep.GetPackageVersionString()" PrivateAssets="none" />
|
||||
}
|
||||
}
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Compose nuget package details until Compose support is implemented -->
|
||||
@if (@Model.NuGetPackageId.StartsWith("Xamarin.AndroidX.Compose"))
|
||||
{
|
||||
<PropertyGroup>
|
||||
<Summary>.NET for Android (formerly Xamarin.Android) bindings for AndroidX - @(Model.Name) (bindings without managed callable wrappers (C#) and are only used for including Java files)</Summary>
|
||||
<Description>.NET for Android (formerly Xamarin.Android) bindings for AndroidX - @(Model.Name) (bindings without managed callable wrappers (C#) and are only used for including Java files) artifact=@(Model.MavenGroupId):@(Model.Name) artifact_versioned=@(Model.MavenGroupId):@(Model.Name):@(artifact_version)</Description>
|
||||
</PropertyGroup>
|
||||
}
|
||||
|
||||
@{
|
||||
string GetProjectVersionString (string mavenVersion, string nugetVersion)
|
||||
{
|
||||
var adjusted_string = GetVersionString (mavenVersion, nugetVersion);
|
||||
|
||||
// If nothing changed, return empty string
|
||||
if (adjusted_string == nugetVersion)
|
||||
return null;
|
||||
|
||||
return adjusted_string;
|
||||
}
|
||||
|
||||
string GetVersionString (string mavenVersion, string nugetVersion)
|
||||
{
|
||||
// If this isn't an exact version we don't use this code
|
||||
if (!mavenVersion.StartsWith ('[') || !mavenVersion.EndsWith (']') || mavenVersion.Contains (','))
|
||||
return nugetVersion;
|
||||
|
||||
// An exact version is requested like "1.2.0", however we want to let the revision (4th NuGet number) float,
|
||||
// so that our updates that don't change the Java artifact can still be used.
|
||||
// That is, if the POM specifies "1.2.0" and the dependency NuGet is already "1.2.0.4", we want to allow:
|
||||
// 1.2.0.4 >= x < 1.2.1
|
||||
// NuGet expresses that as "[1.2.0.4, 1.2.1)", so that's what we need to create.
|
||||
var lower_bound = nugetVersion;
|
||||
|
||||
var nuget_first = 0;
|
||||
var nuget_second = 0;
|
||||
var nuget_third = 0;
|
||||
|
||||
var nuget_parts = nugetVersion.Split ('.');
|
||||
|
||||
if (nuget_parts.Length > 0 && int.TryParse (nuget_parts [0], out var p1))
|
||||
nuget_first = p1;
|
||||
|
||||
if (nuget_parts.Length > 1 && int.TryParse (nuget_parts [1], out var p2))
|
||||
nuget_second = p2;
|
||||
|
||||
if (nuget_parts.Length > 2 && int.TryParse (nuget_parts [2], out var p3))
|
||||
nuget_third = p3;
|
||||
|
||||
// Bump the third number
|
||||
nuget_third++;
|
||||
|
||||
var upper_bound = $"{nuget_first}.{nuget_second}.{nuget_third}";
|
||||
|
||||
// Put it all together
|
||||
return $"[{lower_bound}, {upper_bound})";
|
||||
}
|
||||
}
|
||||
</Project>
|
|
@ -49,7 +49,7 @@
|
|||
|
||||
<ItemGroup>
|
||||
<None Include="..\..\..\source\PackageLicense.md" Pack="True" PackagePath="LICENSE.md" />
|
||||
<None Include="..\..\..\icons\Xamarin.AndroidX_nuget.png" Pack="True" PackagePath="icon.png" />
|
||||
<None Include="..\..\..\build\icon.png" Pack="True" PackagePath="icon.png" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using MavenNet.Models;
|
||||
|
@ -8,6 +9,8 @@ namespace AndroidBinderator
|
|||
{
|
||||
public static class Extensions
|
||||
{
|
||||
public static bool HasValue ([NotNullWhen (true)] this string? str) => !string.IsNullOrWhiteSpace (str);
|
||||
|
||||
public static string OrEmpty (this string? value) => value ?? string.Empty;
|
||||
|
||||
public static string GroupAndArtifactId (this Dependency dependency) => $"{dependency.GroupId}.{dependency.ArtifactId}";
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace AndroidBinderator
|
||||
{
|
||||
|
@ -39,6 +40,26 @@ namespace AndroidBinderator
|
|||
public List<MavenArtifactLicense> Licenses { get; } = new List<MavenArtifactLicense> ();
|
||||
|
||||
public List<MavenArtifactDeveloper> Developers { get; } = new List<MavenArtifactDeveloper> ();
|
||||
|
||||
public string GetAssemblyName () => AssemblyName.HasValue () ? AssemblyName : NuGetPackageId ?? string.Empty;
|
||||
|
||||
public string GetArtifactVersion () => MavenArtifacts.FirstOrDefault ()?.MavenArtifactVersion ?? string.Empty;
|
||||
|
||||
public string GetRootNamespace ()
|
||||
{
|
||||
if (Metadata.TryGetValue ("rootNamespace", out var rootNamespace))
|
||||
return rootNamespace;
|
||||
|
||||
return NuGetPackageId!.Replace ("Xamarin.", "");
|
||||
}
|
||||
|
||||
// TODO: Move this to config.json
|
||||
// Whether to bind the Java .jar/.aar
|
||||
public bool ShouldBindArtifact => NuGetPackageId != "Xamarin.AndroidX.DataStore.Core.Jvm";
|
||||
|
||||
// TODO: Move this to config.json
|
||||
// Whether to include the Java .jar/.aar in the NuGet package
|
||||
public bool ShouldIncludeArtifact => NuGetPackageId != "Xamarin.AndroidX.DataStore.Core.Jvm";
|
||||
}
|
||||
|
||||
public class MavenArtifactLicense
|
||||
|
|
|
@ -19,5 +19,59 @@ namespace AndroidBinderator
|
|||
public MavenArtifactModel? MavenArtifact { get; set; }
|
||||
|
||||
public Dictionary<string, string> Metadata { get; set; } = new Dictionary<string, string>();
|
||||
|
||||
// Gets the version string needed for a NuGet package dependency, which we adjust to allow floating revisions
|
||||
public string GetPackageVersionString ()
|
||||
{
|
||||
var mavenVersion = MavenArtifact!.MavenArtifactVersion!;
|
||||
var nugetVersion = NuGetVersion!;
|
||||
|
||||
// If this isn't an exact version we don't use this code
|
||||
if (!mavenVersion.StartsWith ('[') || !mavenVersion.EndsWith (']') || mavenVersion.Contains (','))
|
||||
return nugetVersion;
|
||||
|
||||
// An exact version is requested like "1.2.0", however we want to let the revision (4th NuGet number) float,
|
||||
// so that our updates that don't change the Java artifact can still be used.
|
||||
// That is, if the POM specifies "1.2.0" and the dependency NuGet is already "1.2.0.4", we want to allow:
|
||||
// 1.2.0.4 >= x < 1.2.1
|
||||
// NuGet expresses that as "[1.2.0.4, 1.2.1)", so that's what we need to create.
|
||||
var lower_bound = nugetVersion;
|
||||
|
||||
var nuget_first = 0;
|
||||
var nuget_second = 0;
|
||||
var nuget_third = 0;
|
||||
|
||||
var nuget_parts = nugetVersion.Split ('.');
|
||||
|
||||
if (nuget_parts.Length > 0 && int.TryParse (nuget_parts [0], out var p1))
|
||||
nuget_first = p1;
|
||||
|
||||
if (nuget_parts.Length > 1 && int.TryParse (nuget_parts [1], out var p2))
|
||||
nuget_second = p2;
|
||||
|
||||
if (nuget_parts.Length > 2 && int.TryParse (nuget_parts [2], out var p3))
|
||||
nuget_third = p3;
|
||||
|
||||
// Bump the third number
|
||||
nuget_third++;
|
||||
|
||||
var upper_bound = $"{nuget_first}.{nuget_second}.{nuget_third}";
|
||||
|
||||
// Put it all together
|
||||
return $"[{lower_bound}, {upper_bound})";
|
||||
}
|
||||
|
||||
// Gets the version string needed for a project dependency, which we adjust to allow floating revisions
|
||||
public string? GetProjectVersionString ()
|
||||
{
|
||||
var nugetVersion = NuGetVersion!;
|
||||
var adjusted_string = GetPackageVersionString ();
|
||||
|
||||
// If nothing changed, return empty string
|
||||
if (adjusted_string == nugetVersion)
|
||||
return null;
|
||||
|
||||
return adjusted_string;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче