-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.cake
180 lines (152 loc) · 8.64 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
#addin nuget:?package=Cake.Git&version=1.0.1
var target = Argument ("target", "Default");
// Nice online pom dependency explorer
// https://jar-download.com/
var PSPDFKIT_VERSION = "8.7.3";
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 (() => {
// PSPDFKit.Android
Information ("Downloading all the dependencies...");
DownloadFile (PSPDFKITURL, $"./PSPDFKit.Android/Jars/pspdfkit-{PSPDFKIT_VERSION}.aar");
// DownloadFile (RXANDROIDURL, $"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}.aar");
// DownloadFile (RXJAVAURL, $"./PSPDFKit.Android/Jars/rxjava-{RXJAVA_VERSION}.jar");
// DownloadFile (REACTIVESTREAMSURL, $"./PSPDFKit.Android/Jars/reactive-streams-{REACTIVESTREAMS_VERSION}.jar");
// DownloadFile (YOUTUBEURL, $"./PSPDFKit.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}.zip");
DownloadFile (RELINKERURL, $"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}.aar");
//DownloadFile (KOTLINSTDLIBURL, $"./PSPDFKit.Android/Jars/kotlin-stdlib-{KOTLINSTDLIB_VERSION}.jar");
//DownloadFile (KOTLINSTDLIBCOMMONURL, $"./PSPDFKit.Android/Jars/kotlin-stdlib-common-{KOTLINSTDLIBCOMMON_VERSION}.jar");
//DownloadFile (KOTLIANNOTATIONSURL, $"./PSPDFKit.Android/Jars/annotations-{KOTLIANNOTATIONS_VERSION}.jar");
DownloadFile (YEARCLASSURL, $"./PSPDFKit.Android/Jars/yearclass-{YEARCLASS_VERSION}.jar");
//DownloadFile (OKHTTP3URL, $"./PSPDFKit.Android/Jars/okhttp-{OKHTTP3_VERSION}.jar");
//DownloadFile (OKHTTP3LOGGINGURL, $"./PSPDFKit.Android/Jars/logging-interceptor-{OKHTTP3LOGGING_VERSION}.jar");
//DownloadFile (OKIOURL, $"./PSPDFKit.Android/Jars/okio-{OKIO_VERSION}.jar");
});
Task ("ExtractAars")
.IsDependentOn ("FetchDependencies")
.Does (() => {
Information ("Unzipping needed dependencies...");
var delDirSettings = new DeleteDirectorySettings { Recursive = true, Force = true };
if(DirectoryExists ($"./PSPDFKit.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}"))
DeleteDirectory ($"./PSPDFKit.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}", delDirSettings);
if(DirectoryExists ($"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}"))
DeleteDirectory ($"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}", delDirSettings);
if(DirectoryExists ($"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}"))
DeleteDirectory ($"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}", delDirSettings);
// Unzip ($"./PSPDFKit.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}.zip", $"./PSPDFKit.Android/Jars/YouTubeAndroidPlayerApi-{YOUTUBE_VERSION}");
// Unzip ($"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}.aar", $"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}");
Unzip ($"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}.aar", $"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}");
// CopyFile ($"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}/classes.jar", $"./PSPDFKit.Android/Jars/rxandroid-{RXANDROID_VERSION}.jar");
CopyFile ($"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}/classes.jar", $"./PSPDFKit.Android/Jars/relinker-{RELINKER_VERSION}.jar");
});
Task ("RestoreNugets")
.Does (() => {
Information ("Restoring NuGets...");
NuGetRestore ("./PSPDFKit.Android.sln");
});
Task ("BuildPSPDFKit")
.Does (() => {
if (FileExists ($"./PSPDFKit.Android/Jars/pspdfkit-{PSPDFKIT_VERSION}.aar")) {
Information ("Building PSPDFKit.Android.dll");
Information ("PLEASE WAIT, it might take a few minutes to build...");
MSBuild ("./PSPDFKit.Android/PSPDFKit.Android.csproj", new MSBuildSettings ()
.SetConfiguration ("Release")
);
if (FileExists ("./PSPDFKit.Android/bin/Release/PSPDFKit.Android.dll"))
CopyFile ("./PSPDFKit.Android/bin/Release/PSPDFKit.Android.dll", "./PSPDFKit.Android.dll");
} else {
Warning ($"./PSPDFKit.Android/Jars/pspdfkit-{PSPDFKIT_VERSION}.aar file not found.");
Warning ($"PSPDFKit.Android.dll was not built.");
}
});
Task ("Default")
.IsDependentOn ("ExtractAars")
.IsDependentOn ("RestoreNugets")
.IsDependentOn ("BuildPSPDFKit")
.Does (() => {
Information ("Build Done!");
});
Task ("NuGet")
.IsDependentOn("Default")
.Does (() =>
{
if(!DirectoryExists("./nuget/pkgs/"))
CreateDirectory("./nuget/pkgs");
var head = GitLogTip("./");
var commit = head.Sha.Substring (0,7);
NuGetPack ("./nuget/pspdfkit-android.nuspec", new NuGetPackSettings {
Version = $"{PSPDFKIT_VERSION}.{SERVICERELEASE_VERSION}+sha.{commit}",
OutputDirectory = "./nuget/pkgs/",
BasePath = "./"
});
});
Task ("NuGet-Push")
.IsDependentOn("Nuget")
.Does (() =>
{
var package = "./nuget/pkgs/PSPDFKit.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.Android.dll"))
DeleteFile ("./PSPDFKit.Android.dll");
var delDirSettings = new DeleteDirectorySettings { Recursive = true, Force = true };
if (DirectoryExists ("./packages/"))
DeleteDirectory ("./packages", delDirSettings);
if (DirectoryExists ("./PSPDFKit.Android/bin/"))
DeleteDirectory ("./PSPDFKit.Android/bin", delDirSettings);
if (DirectoryExists ("./PSPDFKit.Android/obj/"))
DeleteDirectory ("./PSPDFKit.Android/obj", delDirSettings);
if (DirectoryExists ("./PSPDFKit.Android/Jars/")) {
DeleteDirectory ("./PSPDFKit.Android/Jars", delDirSettings);
GitCheckout ("./", new FilePath [] { "./PSPDFKit.Android/Jars" });
}
});
Task ("Clean-obj-bin")
.Does (() => {
var delDirSettings = new DeleteDirectorySettings { Recursive = true, Force = true };
var dirs = new [] {
"./PSPDFKit.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);
}
});
RunTarget (target);