-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathbuild-and-package.cake
115 lines (94 loc) · 3.53 KB
/
build-and-package.cake
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
// Contains tasks for building and packaging projects
// Builds the NuGet packages
Task ("nuget")
.IsDependentOn ("libs")
.Does (() =>
{
var settings = new DotNetMSBuildSettings ()
.SetConfiguration (CONFIGURATION)
.EnableBinaryLogger ($"./output/nuget.{CONFIGURATION}.binlog")
.WithProperty ("NoBuild", "true")
.WithProperty ("PackageOutputPath", MakeAbsolute ((DirectoryPath)"./output/").FullPath)
.WithTarget ("Pack");
settings.NodeReuse = false;
DotNetBuild (
"./generated/AndroidX.sln",
new DotNetBuildSettings { MSBuildSettings = settings }
);
// validation fails on CI if the package is in the output directory
DeleteFile ($"./output/cliwrap.3.8.2.nupkg");
DeleteFile ($"./output/holisticware.core.net.http.0.0.4.nupkg");
DeleteFile ($"./output/holisticware.core.io.0.0.4.nupkg");
DeleteFile ($"./output/holisticware.xamarin.tools.componentgovernance.0.0.1.4.nupkg");
});
// Builds the .csproj projects
Task ("libs")
.IsDependentOn("metadata-verify")
.IsDependentOn ("libs-native")
.Does(() =>
{
var settings = new DotNetMSBuildSettings ()
.SetConfiguration (CONFIGURATION)
.EnableBinaryLogger ($"./output/libs.{CONFIGURATION}.binlog")
.WithProperty("Verbosity", VERBOSITY.ToString ());
settings.NodeReuse = false;
DotNetBuild (
"./generated/AndroidX.sln",
new DotNetBuildSettings { MSBuildSettings = settings }
);
});
// Builds the Java libraries
Task ("libs-native")
.Does (() =>
{
// com.xamarin.google.android.material.extensions
BuildGradleProject (
"./source/com.google.android.material/material.extensions/",
"./externals/com.xamarin.google.android.material.extensions/",
false
);
// com.google.android.play/core.extensions
BuildGradleProject (
"./source/com.google.android.play/core.extensions/",
"./externals/com.xamarin.google.android.play.core.extensions/",
true
);
// com.google.android.play/asset.delivery.extensions
BuildGradleProject (
"./source/com.google.android.play/asset.delivery.extensions/",
"./externals/com.xamarin.google.android.play.asset.delivery.extensions/",
true
);
// com.google.android.play/feature.delivery.extensions
BuildGradleProject (
"./source/com.google.android.play/feature.delivery.extensions/",
"./externals/com.xamarin.google.android.play.feature.delivery.extensions/",
true
);
});
void BuildGradleProject (string root, string outputDir, bool moveFile)
{
RunGradle (root, "build");
EnsureDirectoryExists (outputDir);
CleanDirectories (outputDir);
var full_file_path = $"{root}extensions-aar/build/outputs/aar/extensions-aar-release.aar";
var file_name = System.IO.Path.GetFileName (full_file_path);
CopyFileToDirectory (full_file_path, outputDir);
Unzip($"{outputDir}/{file_name}", outputDir);
if (moveFile)
MoveFile ($"{outputDir}/classes.jar", $"{outputDir}/extensions.jar");
}
void RunGradle (DirectoryPath root, string target)
{
root = MakeAbsolute (root);
var proc = IsRunningOnWindows ()
? root.CombineWithFilePath ("gradlew.bat").FullPath
: "bash";
var args = IsRunningOnWindows ()
? ""
: root.CombineWithFilePath ("gradlew").FullPath;
args += $" {target} -p {root}";
var exitCode = StartProcess (proc, args);
if (exitCode != 0)
throw new Exception ($"Gradle exited with code {exitCode}.");
}