This repository was archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathAndroidXTargets.cshtml
66 lines (61 loc) · 2.14 KB
/
AndroidXTargets.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
<?xml version="1.0" encoding="utf-8"?>
@using System.Linq
@using System.IO
@using System.Xml.Linq
@functions
{
public static string GetTargetFrameworkVersion() { return "monoandroid90"; }
public static void RemoveXmlns(XElement e)
{
e.Name = e.Name.LocalName;
foreach (var node in e.DescendantNodes())
{
var n = node as XElement;
if (n != null)
RemoveXmlns(n);
}
}
}
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
@if (@Model.MavenArtifacts.Count > 0) {
<ItemGroup>
@foreach (var art in @Model.MavenArtifacts) {
if (art.ProguardFile != null) {
<ProguardConfiguration Include="$(MSBuildThisFileDirectory)..\..\proguard\@(GetTargetFrameworkVersion())\proguard.txt">
<AndroidXSkipAndroidXMigration>true</AndroidXSkipAndroidXMigration>
</ProguardConfiguration>
}
}
</ItemGroup>
}
<ItemGroup>
@foreach (var art in @Model.MavenArtifacts) {
if ($"{art.MavenGroupId}.{art.MavenArtifactId}" == "androidx.multidex.multidex") {
// multidex is a special case that only includes the aar conditionally
continue;
}
if (art.MavenArtifactPackaging == "aar") {
<AndroidAarLibrary Include="$(MSBuildThisFileDirectory)..\..\aar\@(art.MavenGroupId).@(art.MavenArtifactId).aar">
<AndroidXSkipAndroidXMigration>true</AndroidXSkipAndroidXMigration>
</AndroidAarLibrary>
} else {
<AndroidJavaLibrary Include="$(MSBuildThisFileDirectory)..\..\jar\@(art.MavenGroupId).@(art.MavenArtifactId).jar">
<AndroidXSkipAndroidXMigration>true</AndroidXSkipAndroidXMigration>
</AndroidJavaLibrary>
}
}
</ItemGroup>
@{
string mergeTargets = Path.Combine(Model.Config.BasePath, "source", Model.MavenGroupId, Model.Name, "merge.targets");
if (File.Exists(mergeTargets)) {
XDocument xmlTargets = XDocument.Load(mergeTargets);
XNamespace nsChild = xmlTargets.Root.Name.Namespace;
@Raw("\r\n\r\n");
foreach (var xelem in xmlTargets.Element (nsChild + "Project").Elements ()) {
RemoveXmlns(xelem);
@Raw("\r\n" + xelem.ToString());
}
@Raw("\r\n\r\n");
}
}
</Project>