-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.cake
293 lines (256 loc) · 13.2 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
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
///////////////////////////////////////////////////////////////////////////////
// ARGUMENTS
///////////////////////////////////////////////////////////////////////////////
var target = Argument("target", "Default");
var configuration = Argument("configuration", "Release");
///////////////////////////////////////////////////////////////////////////////
// TASKS
///////////////////////////////////////////////////////////////////////////////
var temp = Directory("./.temp");
var nugetDir = Directory("./.nuget");
TaskSetup(setupContext =>
{
CleanDirectory(temp);
});
Task("Clean-Output")
.Does(() =>
{
CleanDirectory(nugetDir);
});
Task("All")
.IsDependentOn("Clean-Output")
.IsDependentOn("JMeter")
.IsDependentOn("dotnet-framework-sonarscanner")
.IsDependentOn("7-Zip.StandaloneConsole")
.IsDependentOn("Flyway.CommandLine")
.Does(() =>
{
});
Task("JMeter")
.IsDependentOn("Clean-Output")
.Does(() =>
{
var jMeterVersion = "5.6.3";
var jMeterPath = temp + Directory($"apache-jmeter-{jMeterVersion}");
var libPath = jMeterPath + Directory("lib");
var extPath = libPath + Directory("ext");
// Download and Extract JMeter
var resource = DownloadFile($"https://dlcdn.apache.org//jmeter/binaries/apache-jmeter-{jMeterVersion}.zip");
Unzip(resource, temp);
// Install the plugin manager
var pluginManagerVersion = "1.10";
DownloadFile($"http://search.maven.org/remotecontent?filepath=kg/apc/jmeter-plugins-manager/{pluginManagerVersion}/jmeter-plugins-manager-{pluginManagerVersion}.jar", extPath + File($"jmeter-plugins-manager-{pluginManagerVersion}.jar"));
// Install the command runner
var cmdRunnerVersion = "2.3";
DownloadFile($"https://search.maven.org/remotecontent?filepath=kg/apc/cmdrunner/{cmdRunnerVersion}/cmdrunner-{cmdRunnerVersion}.jar", libPath + File($"cmdrunner-{cmdRunnerVersion}.jar"));
// Generate the cmd wrappers
var exitCodeWithArgument = StartProcess("java", new ProcessSettings{ Arguments = $"-cp {jMeterPath}/lib/ext/jmeter-plugins-manager-{pluginManagerVersion}.jar org.jmeterplugins.repository.PluginManagerCMDInstaller" });
// Create the NuGet package
var nuGetPackSettings = new NuGetPackSettings {
Id = "JMeter",
Version = jMeterVersion,
Authors = new[] {"phmarques", "Roemer"},
Description = "The Apache JMeter™ application is open source software, a 100% pure Java application designed to load test functional behavior and measure performance. It was originally designed for testing Web Applications but has since expanded to other test functions.",
ProjectUrl = new Uri("https://github.com/Roemer/nuget-packages"),
LicenseUrl = new Uri("https://www.apache.org/licenses/"),
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new [] {
new NuSpecContent { Source = $@".temp\apache-jmeter-{jMeterVersion}\**", Exclude = $@".temp\apache-jmeter-{jMeterVersion}\docs\**;.temp\apache-jmeter-{jMeterVersion}\printable_docs\**", Target = "tools" }
},
BasePath = "./",
OutputDirectory = nugetDir,
ArgumentCustomization = args => args.Append("-NoDefaultExcludes"),
};
NuGetPack(nuGetPackSettings);
});
Task("dotnet-framework-sonarscanner")
.IsDependentOn("Clean-Output")
.Does(() =>
{
var version = "7.1.1";
var versionSuffix = "96069";
var fullVersionString = $"{version}.{versionSuffix}";
var resource = DownloadFile($"https://github.com/SonarSource/sonar-scanner-msbuild/releases/download/{fullVersionString}/sonar-scanner-{fullVersionString}-net-framework.zip");
Unzip(resource, temp);
var nuGetPackSettings = new NuGetPackSettings {
Id = "dotnet-framework-sonarscanner",
Title = "SonarScanner for .Net Framework",
Version = version,
Authors = new[] {"SonarSource", "Microsoft", "Roemer"},
Description = "The SonarScanner for .Net Framework allows easy analysis of any .NET project with SonarCloud/SonarQube.",
ProjectUrl = new Uri("https://github.com/Roemer/nuget-packages"),
LicenseUrl = new Uri("https://cdn.rawgit.com/SonarSource/sonar-scanner-msbuild/master/LICENSE.txt"),
IconUrl = new Uri("https://cdn.rawgit.com/SonarSource/sonar-scanner-msbuild/cdd1f588/icon.png"),
ReleaseNotes = new [] {"All release notes for SonarScanner .Net Framework can be found on the GitHub site - https://github.com/SonarSource/sonar-scanner-msbuild/releases"},
Tags = new [] {"sonarqube", "sonarcloud", "msbuild", "scanner", "sonarsource", "sonar", "sonar-scanner", "sonarscanner"},
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new [] {
new NuSpecContent { Source = $@".temp\**", Target = "tools" }
},
BasePath = "./",
OutputDirectory = nugetDir
};
NuGetPack(nuGetPackSettings);
});
Task("7-Zip.StandaloneConsole")
.IsDependentOn("Clean-Output")
.Does(() =>
{
var version = "24.07";
var resource = DownloadFile($"https://www.7-zip.org/a/7z{version.Replace(".", "")}-extra.7z");
UnSevenZip(resource, temp);
resource = DownloadFile($"https://www.7-zip.org/a/7z{version.Replace(".", "")}-x64.exe");
UnSevenZip(resource, temp);
var genericFiles = new [] {
new NuSpecContent { Source = temp + File("7-zip.chm"), Target = "tools" },
new NuSpecContent { Source = temp + File("readme.txt"), Target = "tools" },
new NuSpecContent { Source = temp + File("License.txt"), Target = "tools" },
};
var nuGetPackSettings = new NuGetPackSettings {
Id = "7-Zip.StandaloneConsole",
Title = "7-Zip Standalone Console Version",
Version = version,
Authors = new[] {"Igor Pavlov", "Roemer"},
Description = "Standalone Console Version of the 7-Zip packer/unpacker.",
ProjectUrl = new Uri("https://github.com/Roemer/nuget-packages"),
License = new NuSpecLicense {
Type = "file",
Value = @"tools\License.txt"
},
IconUrl = new Uri("http://www.7-zip.org/7ziplogo.png"),
ReleaseNotes = new [] {"https://www.7-zip.org/history.txt"},
Tags = new [] {"7z", "7zip", "7-Zip", "ZIP", "xz", "GZIP", "BZIP2", "TAR", "Z", "lzma", "CAB", "7za"},
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new List<NuSpecContent>(genericFiles) {
// x86
new NuSpecContent { Source = temp + File("7za.exe"), Target = @"tools" },
// x64
new NuSpecContent { Source = temp + Directory("x64") + File("7za.exe"), Target = @"tools\x64" }
},
BasePath = "./",
OutputDirectory = nugetDir
};
// Base version
NuGetPack(nuGetPackSettings);
// x64 version
nuGetPackSettings.Id = "7-Zip.StandaloneConsole.x64";
nuGetPackSettings.Files = new List<NuSpecContent>(genericFiles) {
new NuSpecContent { Source = temp + Directory("x64") + File("7za.exe"), Target = @"tools" }
};
NuGetPack(nuGetPackSettings);
// x86 version
nuGetPackSettings.Id = "7-Zip.StandaloneConsole.x86";
nuGetPackSettings.Files = new List<NuSpecContent>(genericFiles) {
new NuSpecContent { Source = temp + File("7za.exe"), Target = @"tools" }
};
NuGetPack(nuGetPackSettings);
});
Task("Flyway.CommandLine")
.IsDependentOn("Clean-Output")
.Does(() =>
{
var version = "10.17.0";
var licenseFile = @"licenses\LICENSE.md";
//licenseFile = @"licenses\flyway-community.txt"; // For pre-10 versions
//licenseFile = @"LICENSE.txt"; // For pre-6 versions
var nuGetPackSettings = new NuGetPackSettings {
Version = version,
Authors = new[] {"Boxfuse", "Roemer"},
Description = "The Flyway command-line tool is a standalone Flyway distribution. It is primarily meant for users who wish to migrate their database from the command-line without having to integrate Flyway into their applications nor having to install a build tool.",
ProjectUrl = new Uri("https://github.com/Roemer/nuget-packages"),
License = new NuSpecLicense {
Type = "file",
Value = $@"tools\{licenseFile}"
},
IconUrl = new Uri("https://flywaydb.org/assets/logo/flyway-logo.png"),
ReleaseNotes = new [] {"All release notes can be found on - https://flywaydb.org/documentation/releaseNotes"},
Tags = new [] {"flyway", "migration", "db"},
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new [] {
new NuSpecContent { Source = $@".temp\flyway-{version}\**", Target = "tools" }
},
BasePath = "./",
OutputDirectory = nugetDir
};
// Handle the file without jre
{
var resource = DownloadFile($"https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/{version}/flyway-commandline-{version}.zip");
Unzip(resource, temp);
nuGetPackSettings.Id = "Flyway.CommandLine";
nuGetPackSettings.Title = "Flyway command-line tool";
NuGetPack(nuGetPackSettings);
}
CleanDirectory(temp);
// Handle the file with JRE
{
var resource = DownloadFile($"https://repo1.maven.org/maven2/org/flywaydb/flyway-commandline/{version}/flyway-commandline-{version}-windows-x64.zip");
Unzip(resource, temp);
nuGetPackSettings.Id = "Flyway.CommandLine.Jre";
nuGetPackSettings.Title = "Flyway command-line tool with JRE";
NuGetPack(nuGetPackSettings);
}
});
Task("Docker-CLI")
.IsDependentOn("Clean-Output")
.Does(() =>
{
var version = "27.1.1";
var resource = DownloadFile($"https://download.docker.com/win/static/stable/x86_64/docker-{version}.zip");
Unzip(resource, temp);
var nuGetPackSettings = new NuGetPackSettings {
Id = "docker-cli",
Title = "Docker CLI for Windows",
Version = version,
Authors = new[] {"Docker", "StefanScherer", "Roemer"},
Description = "This package contains the docker-cli executable for Windows.",
ProjectUrl = new Uri("https://github.com/Roemer/nuget-packages"),
LicenseUrl = new Uri("https://github.com/StefanScherer/docker-cli-builder/blob/master/LICENSE"),
Tags = new [] {"docker", "cli", "windows"},
RequireLicenseAcceptance = false,
Symbols = false,
NoPackageAnalysis = true,
Files = new [] {
new NuSpecContent { Source = $@".temp\docker\**", Target = "tools" }
},
BasePath = "./",
OutputDirectory = nugetDir
};
NuGetPack(nuGetPackSettings);
});
Task("Push-Packages")
.Does(() =>
{
var apiKey = System.IO.File.ReadAllText(".nugetapikey");
var files = GetFiles($"{nugetDir}/*.nupkg");
foreach (var package in files) {
Information($"Pushing {package}");
NuGetPush(package, new NuGetPushSettings {
Source = "https://nuget.org/api/v2/package",
ApiKey = apiKey
});
}
});
Task("Default")
.Does(() =>
{
Information("Hello Cake!");
});
RunTarget(target);
private void UnSevenZip(FilePath fileToExtract, DirectoryPath targetDirectory)
{
var settings = new ProcessSettings
{
WorkingDirectory = MakeAbsolute(targetDirectory),
Arguments = $"x -aoa {MakeAbsolute(fileToExtract).ToString().Quote()} *"
};
var exePath = Context.Environment.GetSpecialPath(SpecialPath.ProgramFiles).CombineWithFilePath(@"7-Zip\7z.exe");
StartProcess(exePath, settings);
}