-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.cake
189 lines (152 loc) · 8.1 KB
/
build.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
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
var target = Argument ("target", "Default");
// Nice online pom dependency explorer
// https://jar-download.com/
var PSPDFKIT_VERSION = "2024.8.1";
var SERVICERELEASE_VERSION = "0"; // This is combined with the PSPDFKIT_VERSION variable for the NuGet Package version
var RXANDROID_VERSION = "2.1.0";
var RXJAVA_VERSION = "2.2.4"; // Check Reactive-Streams if updated.
var REACTIVESTREAMS_VERSION = "1.0.2";
var YOUTUBE_VERSION = "1.2.2";
var RELINKER_VERSION = "1.4.5";
var KOTLINSTDLIB_VERSION = "1.3.50"; // Check Annotations version if updated.
var KOTLIANNOTATIONS_VERSION = "13.0";
var KOTLINSTDLIBCOMMON_VERSION = "1.3.50";
var YEARCLASS_VERSION = "2.0.0";
var OKHTTP3_VERSION = "3.9.0"; // Check OKIO version if updated.
var OKHTTP3LOGGING_VERSION = "3.9.0";
var OKIO_VERSION = "1.13.0";
var PSPDFKITURL = $"https://customers.pspdfkit.com/maven/com/pspdfkit/pspdfkit/{PSPDFKIT_VERSION}/pspdfkit-{PSPDFKIT_VERSION}.aar";
var RXANDROIDURL = $"http://search.maven.org/remotecontent?filepath=io/reactivex/rxjava2/rxandroid/{RXANDROID_VERSION}/rxandroid-{RXANDROID_VERSION}.aar";
var RXJAVAURL = $"http://search.maven.org/remotecontent?filepath=io/reactivex/rxjava2/rxjava/{RXJAVA_VERSION}/rxjava-{RXJAVA_VERSION}.jar";
var YOUTUBEURL = $"https://developers.google.com/youtube/android/player/downloads/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}.zip";
var REACTIVESTREAMSURL = $"http://search.maven.org/remotecontent?filepath=org/reactivestreams/reactive-streams/{REACTIVESTREAMS_VERSION}/reactive-streams-{REACTIVESTREAMS_VERSION}.jar";
var RELINKERURL = $"https://search.maven.org/remotecontent?filepath=com/getkeepsafe/relinker/relinker/{RELINKER_VERSION}/relinker-{RELINKER_VERSION}.aar";
var OKHTTP3URL = $"http://search.maven.org/remotecontent?filepath=com/squareup/okhttp3/okhttp/{OKHTTP3_VERSION}/okhttp-{OKHTTP3_VERSION}.jar";
var OKHTTP3LOGGINGURL = $"https://search.maven.org/remotecontent?filepath=com/squareup/okhttp3/logging-interceptor/{OKHTTP3LOGGING_VERSION}/logging-interceptor-{OKHTTP3LOGGING_VERSION}.jar";
var OKIOURL = $"http://search.maven.org/remotecontent?filepath=com/squareup/okio/okio/{OKIO_VERSION}/okio-{OKIO_VERSION}.jar";
var KOTLINSTDLIBURL = $"http://search.maven.org/remotecontent?filepath=org/jetbrains/kotlin/kotlin-stdlib/{KOTLINSTDLIB_VERSION}/kotlin-stdlib-{KOTLINSTDLIB_VERSION}.jar";
var KOTLINSTDLIBCOMMONURL = $"http://search.maven.org/remotecontent?filepath=org/jetbrains/kotlin/kotlin-stdlib-common/{KOTLINSTDLIBCOMMON_VERSION}/kotlin-stdlib-common-{KOTLINSTDLIBCOMMON_VERSION}.jar";
var KOTLIANNOTATIONSURL = $"http://search.maven.org/remotecontent?filepath=org/jetbrains/annotations/{KOTLIANNOTATIONS_VERSION}/annotations-{KOTLIANNOTATIONS_VERSION}.jar";
var YEARCLASSURL = $"http://search.maven.org/remotecontent?filepath=com/facebook/device/yearclass/yearclass/{YEARCLASS_VERSION}/yearclass-{YEARCLASS_VERSION}.jar";
var NUGET_API_KEY = EnvironmentVariable("NUGET_API_KEY");
Task ("FetchDependencies")
.Does (() => {
if(!DirectoryExists ($"./PSPDFKit.dotnet.Android/Jars"))
CreateDirectory ($"./PSPDFKit.dotnet.Android/Jars");
Information ("Downloading all the dependencies...");
DownloadFile (PSPDFKITURL, $"./PSPDFKit.dotnet.Android/Jars/pspdfkit-{PSPDFKIT_VERSION}.aar");
DownloadFile (RELINKERURL, $"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}.aar");
DownloadFile (YEARCLASSURL, $"./PSPDFKit.dotnet.Android/Jars/yearclass-{YEARCLASS_VERSION}.jar");
});
Task ("ExtractAars")
.IsDependentOn ("FetchDependencies")
.Does (() => {
Information ("Unzipping needed dependencies...");
var delDirSettings = new DeleteDirectorySettings { Recursive = true, Force = true };
if(DirectoryExists ($"./PSPDFKit.dotnet.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}"))
DeleteDirectory ($"./PSPDFKit.dotnet.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}", delDirSettings);
if(DirectoryExists ($"./PSPDFKit.dotnet.Android/Jars/rxandroid-{RXANDROID_VERSION}"))
DeleteDirectory ($"./PSPDFKit.dotnet.Android/Jars/rxandroid-{RXANDROID_VERSION}", delDirSettings);
if(DirectoryExists ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}"))
DeleteDirectory ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}", delDirSettings);
Unzip ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}.aar", $"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}");
CopyFile ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}/classes.jar", $"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}.jar");
if(DirectoryExists ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}")) {
DeleteDirectory ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}", delDirSettings);
DeleteFile ($"./PSPDFKit.dotnet.Android/Jars/relinker-{RELINKER_VERSION}.aar");
}
});
Task ("BuildPSPDFKit")
.Does (() => {
if (FileExists ($"./PSPDFKit.dotnet.Android/Jars/pspdfkit-{PSPDFKIT_VERSION}.aar")) {
Information ("Building PSPDFKit.dotnet.Android.dll");
Information ("PLEASE WAIT, it might take a few minutes to build...");
var msBuildSettings = new DotNetMSBuildSettings ()
.WithProperty ("AssemblyVersion", PSPDFKIT_VERSION);
var dotNetBuildSettings = new DotNetBuildSettings {
Configuration = "Release",
// Verbosity = DotNetVerbosity.Diagnostic,
MSBuildSettings = msBuildSettings
};
DotNetBuild ("./PSPDFKit.dotnet.Android.sln", dotNetBuildSettings);
Information (@"DONE! You will find the PSPDFKit.dotnet.Android.dll inside the 'bin\Release' directory of 'PSPDFKit.dotnet.Android' folder.");
} else {
Warning ($"./PSPDFKit.dotnet.Android/Jars/pspdfkit-{PSPDFKIT_VERSION}.aar file not found.");
Warning ($"PSPDFKit.dotnet.Android.dll was not built.");
}
});
Task ("Default")
.IsDependentOn ("ExtractAars")
.IsDependentOn ("BuildPSPDFKit")
.Does (() => {
Information ("Build Done!");
});
Task ("NuGet")
.IsDependentOn("Default")
.Does (() =>
{
if(!DirectoryExists("./nuget/pkgs/"))
CreateDirectory("./nuget/pkgs");
var commit = GetGitShortCommit ();
Console.WriteLine ($"Commit: {commit}");
XmlPoke ("Directory.Build.props", "/Project/PropertyGroup/PSVersion", $"{PSPDFKIT_VERSION}.{SERVICERELEASE_VERSION}+sha.{commit}");
var dotNetPackSettings = new DotNetPackSettings {
Configuration = "Release",
NoRestore = true,
NoBuild = true,
OutputDirectory = "./nuget/pkgs",
// Verbosity = DotNeVerbosity.Diagnostic,
};
DotNetPack ("./PSPDFKit.dotnet.Android.sln", dotNetPackSettings);
});
Task ("NuGet-Push")
.IsDependentOn("Nuget")
.Does (() =>
{
var package = "./nuget/pkgs/PSPDFKit.dotnet.Android." + PSPDFKIT_VERSION +".nupkg";
NuGetPush(package, new NuGetPushSettings {
Source = "https://api.nuget.org/v3/index.json",
ApiKey = NUGET_API_KEY
});
});
Task ("Clean")
.Does (() => {
if (FileExists ("./PSPDFKit.dotnet.Android.dll"))
DeleteFile ("./PSPDFKit.dotnet.Android.dll");
var delDirSettings = new DeleteDirectorySettings { Recursive = true, Force = true };
if (DirectoryExists ("./packages/"))
DeleteDirectory ("./packages", delDirSettings);
if (DirectoryExists ("./PSPDFKit.dotnet.Android/bin/"))
DeleteDirectory ("./PSPDFKit.dotnet.Android/bin", delDirSettings);
if (DirectoryExists ("./PSPDFKit.dotnet.Android/obj/"))
DeleteDirectory ("./PSPDFKit.dotnet.Android/obj", delDirSettings);
if (DirectoryExists ("./PSPDFKit.dotnet.Android/Jars/")) {
DeleteDirectory ("./PSPDFKit.dotnet.Android/Jars", delDirSettings);
}
});
Task ("Clean-obj-bin")
.Does (() => {
var delDirSettings = new DeleteDirectorySettings { Recursive = true, Force = true };
var dirs = new [] {
"./PSPDFKit.dotnet.Android",
"./samples/AndroidSample/AndroidSample",
"./samples/PSPDFCatalog",
"./samples/XamarinForms/Droid",
"./samples/XamarinForms/XFSample",
};
foreach (var dir in dirs) {
if (DirectoryExists ($"{dir}/bin/"))
DeleteDirectory ($"{dir}/bin", delDirSettings);
if (DirectoryExists ($"{dir}/obj/"))
DeleteDirectory ($"{dir}/obj", delDirSettings);
}
});
string GetGitShortCommit ()
{
StartProcess ("git", new ProcessSettings {
Arguments = "rev-parse --short HEAD",
RedirectStandardOutput = true
}, out var lines);
return lines.FirstOrDefault ();
}
RunTarget (target);