Skip to content
This repository was archived by the owner on Jun 20, 2023. It is now read-only.

Commit d17c2ab

Browse files
committed
Merge branch 'xamarin-build-download' into v25.0.0
2 parents f352010 + 9867459 commit d17c2ab

File tree

147 files changed

+699
-497
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+699
-497
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ output/
1515
*.xcuserstate
1616
*.xcuserstate
1717
*.csproj.user
18+
*/nuget/*.targets
19+
1820

1921
Resource.designer.cs
2022
component.yaml

animated-vector-drawable/component/component.template.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@ samples:
3838
- Xamarin.Android.Support.Vector.Drawable
3939
removeNodes:
4040
- "//xNS:Import[contains (@Project, 'Xamarin.Android.Support.Vector.Drawable.targets')]"
41+
- "//xNS:Import[contains (@Project, 'generated.targets')]"
4142
local-nuget-repo: ../../output
4243
no_build: true

animated-vector-drawable/nuget/Xamarin.Android.Support.Animated.Vector.Drawable.nuspec

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,14 @@
1313
<licenseUrl>https://github.com/xamarin/AndroidSupportComponents/blob/master/LICENSE.md</licenseUrl>
1414
<iconUrl>https://raw.githubusercontent.com/xamarin/GooglePlayServicesComponents/master/icons/animated-vector-drawable_128x128.png</iconUrl>
1515
<dependencies>
16+
<dependency id="Xamarin.Build.Download" version="0.3.0" />
17+
1618
<dependency id="Xamarin.Android.Support.Vector.Drawable" version="[$version$]"/>
1719
</dependencies>
1820
</metadata>
1921
<files>
22+
<file src="animated-vector-drawable/nuget/Xamarin.Android.Support.Animated.Vector.Drawable.targets" target="build" />
23+
2024
<file src="output/Xamarin.Android.Support.Animated.Vector.Drawable.dll" target="lib/MonoAndroid70" />
2125
</files>
2226
</package>

animated-vector-drawable/samples/VectorDrawableSample/VectorDrawableSample.csproj

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.props" Condition="Exists('..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -51,6 +52,7 @@
5152
<None Include="Resources\AboutResources.txt" />
5253
<None Include="Properties\AndroidManifest.xml" />
5354
<None Include="Assets\AboutAssets.txt" />
55+
<None Include="packages.config" />
5456
</ItemGroup>
5557
<ItemGroup>
5658
<AndroidResource Include="Resources\layout\Main.axml" />
@@ -101,5 +103,7 @@
101103
</ProjectReference>
102104
</ItemGroup>
103105
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.CSharp.targets" />
104-
<Import Project="..\..\..\vector-drawable\buildtask\bin\Release\Xamarin.Android.Support.Vector.Drawable.targets" />
105-
</Project>
106+
<Import Project="..\..\..\vector-drawable\buildtask\bin\Release\Xamarin.Android.Support.Tasks.VectorDrawable.targets" />
107+
<Import Project="..\..\..\generated.targets" />
108+
<Import Project="..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.targets" Condition="Exists('..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.targets')" />
109+
</Project>
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Xamarin.Build.Download" version="0.3.0" targetFramework="monoandroid70" />
4+
</packages>

animated-vector-drawable/source/Animated-Vector-Drawable.csproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="..\..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.props" Condition="Exists('..\..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.props')" />
34
<PropertyGroup>
45
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
56
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
@@ -78,7 +79,12 @@
7879
</InputJar>
7980
</ItemGroup>
8081
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Android\Xamarin.Android.Bindings.targets" />
82+
<Import Project="..\..\generated.targets" />
8183
<ItemGroup>
8284
<Folder Include="Additions\" />
8385
</ItemGroup>
86+
<ItemGroup>
87+
<None Include="packages.config" />
88+
</ItemGroup>
89+
<Import Project="..\..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.targets" Condition="Exists('..\..\packages\Xamarin.Build.Download.0.3.0\build\Xamarin.Build.Download.targets')" />
8490
</Project>

animated-vector-drawable/source/Properties/AssemblyInfo.cs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,3 @@
2020
// if desired. See the Mono documentation for more information about signing.
2121
//[assembly: AssemblyDelaySign(false)]
2222
//[assembly: AssemblyKeyFile("")]
23-
24-
// GridLayout-v7
25-
[assembly: Java.Interop.JavaLibraryReference ("classes.jar",
26-
PackageName = __SupportConsts.PackageName,
27-
SourceUrl = __SupportConsts.Url,
28-
EmbeddedArchive = __Consts.AarPath,
29-
Version = __SupportConsts.Version,
30-
Sha1sum = __SupportConsts.Sha1sum)]
31-
// GridLayout-v7 resources
32-
[assembly: Android.IncludeAndroidResourcesFromAttribute ("./",
33-
PackageName = __SupportConsts.PackageName,
34-
SourceUrl = __SupportConsts.Url,
35-
EmbeddedArchive = __Consts.AarPath,
36-
Version = __SupportConsts.Version,
37-
Sha1sum = __SupportConsts.Sha1sum)]
38-
39-
static class __Consts {
40-
public const string AarPath = "m2repository/com/android/support/animated-vector-drawable/" + __SupportConsts.AarVersion + "/animated-vector-drawable-" + __SupportConsts.AarVersion + ".aar";
41-
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="Xamarin.Build.Download" version="0.3.0" targetFramework="monoandroid70" />
4+
</packages>

build.cake

Lines changed: 125 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ var AAR_VERSION = "25.0.0";
1818
// FROM: https://dl.google.com/android/repository/addon.xml
1919
// FROM: https://dl.google.com/android/repository/addon2-1.xml
2020
var M2_REPOSITORY_URL = "https://dl-ssl.google.com/android/repository/android_m2repository_r39.zip";
21+
var M2_REPOSITORY_SHA1 = "89ad37d67a1018c42be36933cec3d7712141d42c";
2122
var BUILD_TOOLS_URL = "https://dl-ssl.google.com/android/repository/build-tools_r24-macosx.zip";
2223
var DOCS_URL = "https://dl-ssl.google.com/android/repository/docs-23_r01.zip";
2324
var ANDROID_SDK_VERSION = IsRunningOnWindows () ? "v7.0" : "android-24";
@@ -26,14 +27,53 @@ var RENDERSCRIPT_FOLDER = "android-N";
2627
// We grab the previous release's api-info.xml to use as a comparison for this build's generated info to make an api-diff
2728
var BASE_API_INFO_URL = "https://github.com/xamarin/AndroidSupportComponents/releases/download/24.2.1/api-info.xml";
2829

29-
var AAR_DIRS = new [] {
30-
"support-v4", "support-v13", "appcompat-v7", "gridlayout-v7", "mediarouter-v7", "recyclerview-v7",
31-
"palette-v7", "cardview-v7", "leanback-v17", "design", "percent", "customtabs", "preference-v7",
32-
"preference-v14", "preference-leanback-v17", "recommendation", "animated-vector-drawable",
33-
"support-vector-drawable", "support-compat", "support-core-utils", "support-core-ui",
34-
"support-media-compat", "support-fragment", "transition"
30+
var AAR_INFOS = new [] {
31+
new AarInfo ("support-v4", "v4", "Xamarin.Android.Support.v4", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
32+
new AarInfo ("support-v13", "v13", "Xamarin.Android.Support.v13", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
33+
new AarInfo ("appcompat-v7", "v7-appcompat", "Xamarin.Android.Support.v7.AppCompat", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
34+
new AarInfo ("gridlayout-v7", "v7-gridlayout", "Xamarin.Android.Support.v7.GridLayout", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
35+
new AarInfo ("mediarouter-v7", "v7-mediarouter", "Xamarin.Android.Support.v7.MediaRouter", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
36+
new AarInfo ("recyclerview-v7", "v7-recyclerview", "Xamarin.Android.Support.v7.RecyclerView", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
37+
new AarInfo ("palette-v7", "v7-palette", "Xamarin.Android.Support.v7.Palette", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
38+
new AarInfo ("cardview-v7", "v7-cardview", "Xamarin.Android.Support.v7.CardView", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
39+
new AarInfo ("leanback-v17", "v17-leanback", "Xamarin.Android.Support.v17.Leanback", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
40+
new AarInfo ("design", "design", "Xamarin.Android.Support.Design", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
41+
new AarInfo ("percent", "percent", "Xamarin.Android.Support.Percent", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
42+
new AarInfo ("customtabs", "customtabs", "Xamarin.Android.Support.CustomTabs", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
43+
new AarInfo ("preference-v7", "v7-preference", "Xamarin.Android.Support.v7.Preference", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
44+
new AarInfo ("preference-v14", "v14-preference", "Xamarin.Android.Support.v14.Preference", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
45+
new AarInfo ("preference-leanback-v17", "v17-preference-leanback", "Xamarin.Android.Support.v17.Preference.Leanback", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
46+
new AarInfo ("recommendation", "recommendation", "Xamarin.Android.Support.Recommendation", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
47+
new AarInfo ("animated-vector-drawable", "animated-vector-drawable", "Xamarin.Android.Support.Animated.Vector.Drawable", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
48+
new AarInfo ("support-vector-drawable", "vector-drawable", "Xamarin.Android.Support.Vector.Drawable", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
49+
new AarInfo ("support-compat", "support-compat", "Xamarin.Android.Support.Compat", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
50+
new AarInfo ("support-core-utils", "support-core-utils", "Xamarin.Android.Support.Core.Utils", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
51+
new AarInfo ("support-core-ui", "support-core-ui", "Xamarin.Android.Support.Core.UI", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
52+
new AarInfo ("support-media-compat", "support-media-compat", "Xamarin.Android.Support.Media.Compat", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
53+
new AarInfo ("support-fragment", "support-fragment", "Xamarin.Android.Support.Fragment", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
54+
new AarInfo ("transition", "transition", "Xamarin.Android.Support.Transition", AAR_VERSION, NUGET_VERSION, COMPONENT_VERSION),
3555
};
3656

57+
class AarInfo
58+
{
59+
public AarInfo (string dir, string path, string nugetId, string aarVersion, string nugetVersion, string componentVersion)
60+
{
61+
Dir = dir;
62+
Path = path;
63+
NugetId = nugetId;
64+
AarVersion = aarVersion;
65+
NuGetVersion = nugetVersion;
66+
ComponentVersion = componentVersion;
67+
}
68+
69+
public string Dir { get; set; }
70+
public string Path { get; set; }
71+
public string NugetId { get;set; }
72+
public string AarVersion { get; set; }
73+
public string NuGetVersion { get; set; }
74+
public string ComponentVersion { get; set; }
75+
}
76+
3777
var MONODROID_PATH = "/Library/Frameworks/Xamarin.Android.framework/Versions/Current/lib/mandroid/platforms/" + ANDROID_SDK_VERSION + "/";
3878
if (IsRunningOnWindows ())
3979
MONODROID_PATH = MakeAbsolute (new DirectoryPath (Environment.GetFolderPath (Environment.SpecialFolder.ProgramFilesX86)).Combine ("Reference Assemblies/Microsoft/Framework/MonoAndroid/" + ANDROID_SDK_VERSION +"/")).FullPath;
@@ -154,11 +194,15 @@ var buildSpec = new BuildSpec {
154194
};
155195

156196

197+
var NUGET_SOURCES = EnvironmentVariable ("NUGET_SOURCES") ?? string.Empty;
198+
if (!string.IsNullOrEmpty (NUGET_SOURCES))
199+
buildSpec.NuGetSources = NUGET_SOURCES.Split (';',',').Select (ns => new NuGetSource { Url = ns }).ToArray ();
157200

158201
// You shouldn't have to configure anything below here
159202
// ######################################################
160203

161204
Task ("externals")
205+
.IsDependentOn ("externals-base")
162206
.WithCriteria (() => !FileExists ("./externals/support-v4/classes.jar")).Does (() =>
163207
{
164208
var path = "./externals/";
@@ -173,15 +217,16 @@ Task ("externals")
173217
Unzip(path + "m2repository.zip", path);
174218

175219
// Copy the .aar's to a better location
176-
foreach (var aar in AAR_DIRS) {
177-
CopyFile (string.Format (path + "m2repository/com/android/support/{0}/{1}/{2}-{3}.aar", aar, AAR_VERSION, aar, AAR_VERSION),
178-
string.Format (path + "{0}.aar", aar));
179-
Unzip (string.Format (path + "{0}.aar", aar), path + aar);
220+
foreach (var aar in AAR_INFOS) {
221+
var aarDir = aar.Dir;
222+
CopyFile (string.Format (path + "m2repository/com/android/support/{0}/{1}/{2}-{3}.aar", aarDir, AAR_VERSION, aarDir, AAR_VERSION),
223+
string.Format (path + "{0}.aar", aarDir));
224+
Unzip (string.Format (path + "{0}.aar", aarDir), path + aarDir);
180225

181-
var implFile = path + aar + "/libs/internal_impl-" + AAR_VERSION + ".jar";
226+
var implFile = path + aarDir + "/libs/internal_impl-" + AAR_VERSION + ".jar";
182227

183228
if (FileExists (implFile))
184-
MoveFile (implFile, path + aar + "/libs/internal_impl.jar");
229+
MoveFile (implFile, path + aarDir + "/libs/internal_impl.jar");
185230
}
186231

187232
// Get android docs
@@ -265,7 +310,73 @@ Task ("component-setup").Does (() =>
265310
}
266311
});
267312

268-
Task ("component").IsDependentOn ("component-docs").IsDependentOn ("component-setup").IsDependentOn ("component-base");
313+
Task ("nuget-setup").Does (() => {
314+
var templateText = FileReadText ("./template.targets");
315+
316+
if (FileExists ("./generated.targets"))
317+
DeleteFile ("./generated.targets");
318+
319+
foreach (var aar in AAR_INFOS) {
320+
321+
var msName = aar.Dir.Replace("-", "");
322+
323+
var items = new Dictionary<string, string> {
324+
{ "_XbdUrl_", "_XbdUrl_" + msName },
325+
{ "_XbdSha1_", "_XbdSha1_" + msName },
326+
{ "_XbdKey_", "_XbdKey_" + msName },
327+
{ "_XbdAarFile_", "_XbdAarFile_" + msName },
328+
{ "_XbdAarFileInSdk_", "_XbdAarFileInSdk_" + msName },
329+
{ "_XbdAssemblyName_", "_XbdAssemblyName_" + msName },
330+
{ "_XbdAarFileFullPath_", "_XbdAarFileFullPath_" + msName },
331+
{ "_XbdRestoreItems_", "_XbdRestoreItems_" + msName },
332+
{ "$XbdUrl$", M2_REPOSITORY_URL },
333+
{ "$XbdSha1$", M2_REPOSITORY_SHA1 },
334+
{ "$XbdKey$", "androidsupport-" + AAR_VERSION },
335+
{ "$XbdAssemblyName$", aar.NugetId },
336+
{ "$AarKey$", aar.Dir },
337+
{ "$AarVersion$", aar.AarVersion}
338+
};
339+
340+
var targetsText = templateText;
341+
342+
foreach (var kvp in items)
343+
targetsText = targetsText.Replace (kvp.Key, kvp.Value);
344+
345+
var targetsFile = string.Format ("{0}/nuget/{1}.targets", aar.Path, aar.NugetId);
346+
FileWriteText (targetsFile, targetsText);
347+
348+
// Merge each generated targets file into one main one
349+
// this makes one file to import into our actual binding projects
350+
// which is much easier/less maintenance
351+
if (!FileExists ("./generated.targets"))
352+
FileWriteText ("./generated.targets", "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n</Project>");
353+
354+
// Load the doc to append to, and the doc to append
355+
var xFileRoot = System.Xml.Linq.XDocument.Load ("./generated.targets");
356+
System.Xml.Linq.XNamespace nsRoot = xFileRoot.Root.Name.Namespace;
357+
var xFileChild = System.Xml.Linq.XDocument.Load (targetsFile);
358+
System.Xml.Linq.XNamespace nsChild = xFileRoot.Root.Name.Namespace;
359+
360+
// Add all the elements under <Project> into the existing file's <Project> node
361+
foreach (var xItemToAdd in xFileChild.Element (nsChild + "Project").Elements ())
362+
xFileRoot.Element (nsRoot + "Project").Add (xItemToAdd);
363+
364+
// Inject a property to prevent errors from missing assemblies in .targets
365+
// this allows us to use one big .targets file in all the projects and not have to figure out which specific
366+
// ones each project needs to reference for development purposes
367+
if (!xFileRoot.Descendants (nsRoot + "XamarinBuildResourceMergeThrowOnMissingAssembly").Any ()) {
368+
xFileRoot.Element (nsRoot + "Project")
369+
.AddFirst (new System.Xml.Linq.XElement (nsRoot + "PropertyGroup",
370+
new System.Xml.Linq.XElement (nsRoot + "XamarinBuildResourceMergeThrowOnMissingAssembly", false)));
371+
}
372+
373+
xFileRoot.Save ("./generated.targets");
374+
}
375+
});
376+
377+
Task ("nuget").IsDependentOn ("nuget-setup").IsDependentOn ("nuget-base").IsDependentOn ("libs");
378+
379+
Task ("component").IsDependentOn ("component-docs").IsDependentOn ("component-setup").IsDependentOn ("component-base").IsDependentOn ("libs");
269380

270381
Task ("clean").IsDependentOn ("clean-base").Does (() =>
271382
{
@@ -341,7 +452,7 @@ Task ("component-docs").Does (() =>
341452
}
342453
});
343454

344-
Task ("libs").IsDependentOn ("genapi");
455+
Task ("libs").IsDependentOn ("genapi").IsDependentOn ("nuget-setup");
345456

346457
Task ("genapi").IsDependentOn ("libs-base").IsDependentOn ("externals").Does (() => {
347458

customtabs/component/component.template.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,8 @@ samples:
2424
packages:
2525
- Xamarin.Android.Support.Compat
2626
- Xamarin.Android.Support.CustomTabs
27+
removeNodes:
28+
- "//xNS:Import[contains (@Project, 'Xamarin.Android.Support.Vector.Drawable.targets')]"
29+
- "//xNS:Import[contains (@Project, 'generated.targets')]"
2730
local-nuget-repo: ../../output
2831
no_build: true

0 commit comments

Comments
 (0)