-
Notifications
You must be signed in to change notification settings - Fork 39
/
AndroidXProject.cshtml
210 lines (178 loc) · 9.14 KB
/
AndroidXProject.cshtml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
@using System
@using System.Linq
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>$(_DefaultTargetFrameworks)</TargetFrameworks>
<IsBindingProject>true</IsBindingProject>
<AssemblyName>@(Model.NuGetPackageId)</AssemblyName>
<AndroidUseIntermediateDesignerFile>false</AndroidUseIntermediateDesignerFile>
<RootNamespace>@(Model.NuGetPackageId.Replace("Xamarin.", ""))</RootNamespace>
<!--
No warnings for:
- CS0618: 'member' is obsolete: 'text'
- CS0109: The member 'member' does not hide an inherited member. The new keyword is not required
- CS0114: 'function1' hides inherited member 'function2'. To make the current method override that implementation, add the override keyword. Otherwise add the new keyword.
- 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
-->
<NoWarn>0618;0109;0114;0628;0108;0809;1572</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];
}
}
<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>
<PackageLicenseExpression>MIT AND Apache-2.0</PackageLicenseExpression>
<PackageIcon>icon.png</PackageIcon>
<PackageVersion>@(Model.NuGetVersion)$(PackageVersionSuffix)</PackageVersion>
<!-- Include symbol files (*.pdb) in the built .nupkg -->
<AllowedOutputExtensionsInPackageBuildOutputFolder>$(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb</AllowedOutputExtensionsInPackageBuildOutputFolder>
</PropertyGroup>
<ItemGroup>
<None Include="@(Model.NuGetPackageId).targets" Pack="True" PackagePath="@@(AndroidXNuGetTargetFolders)" />
<None Include="..\..\LICENSE.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=".\readme.md" Pack="True" PackagePath="readme.md" />
</ItemGroup>
@if (@Model.MavenArtifacts.Count > 0) {
<ItemGroup>
@foreach (var art in @Model.MavenArtifacts) {
if (art.ProguardFile != null) {
<None Include="..\..\@(art.ProguardFile)" Pack="True" PackagePath="proguard/" />
}
}
</ItemGroup>
}
<ItemGroup>
<!-- Include AssemblyInfo.cs -->
<Compile Include="..\..\source\AssemblyInfo.cs" />
<!-- Include any Additions .cs file(s) -->
<Compile Include="..\..\source\@(Model.MavenGroupId)\@(Model.Name)\Additions\*.cs">
<Link>Additions/%(RecursiveDir)/%(Filename)%(Extension)</Link>
</Compile>
<!-- Include common metadata file -->
<TransformFile Include="..\..\source\Metadata.common.xml" >
<Link>Transforms/Metadata.common.xml</Link>
</TransformFile>
<!-- Include any transform file(s) that are not TargetFramework specific -->
<TransformFile Include="..\..\source\@(Model.MavenGroupId)\@(Model.Name)\Transforms\*.xml" Exclude="$(DefaultTransformExcludes)">
<Link>Transforms/%(RecursiveDir)/%(Filename)%(Extension)</Link>
</TransformFile>
<!-- Include any TargetFramework specific transform file(s) for this TF -->
<TransformFile Include="..\..\source\@(Model.MavenGroupId)\@(Model.Name)\Transforms\*.$(TargetFramework).xml">
<Link>Transforms/%(RecursiveDir)/%(Filename)%(Extension)</Link>
</TransformFile>
</ItemGroup>
<ItemGroup>
@foreach (var art in @Model.MavenArtifacts) {
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) {
<ItemGroup>
@foreach (var art in @Model.MavenArtifacts)
{
if (art.MavenArtifactPackaging == "aar")
{
<InputJar
Condition="Exists('..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId)\classes.jar')"
Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId)\classes.jar" />
<!-- For those artifacts with lib/ folder -->
<InputJar
Condition="Exists('..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId)\libs\')"
Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId)\libs\*.jar"
/>
}
else
{
<InputJar Include="..\..\externals\@(art.MavenGroupId)\@(art.MavenArtifactId).jar" />
}
}
</ItemGroup>
}
<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)" />
}
}
</ItemGroup>
<ItemGroup>
<!-- PackageReference -->
@foreach (var dep in @Model.NuGetDependencies) {
if (!dep.IsProjectReference) {
<PackageReference Include="@(dep.NuGetPackageId)" Version="@GetVersionString(dep.MavenArtifact.MavenArtifactVersion, dep.NuGetVersion)" 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>