Skip to content
This repository was archived by the owner on Jul 10, 2021. It is now read-only.

Commit c870ed3

Browse files
committed
desktop build support in respect to #4
1 parent 88698cf commit c870ed3

File tree

7 files changed

+110
-19
lines changed

7 files changed

+110
-19
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Installs the [Flutter SDK](https://flutter.io/sdk-archive/) onto the running age
3636
Build the given mobile application project. You must call the `Flutter Install` task or use the optional `flutterDirectory` task input that points to your `flutter/bin` folder before execution. All application bundles are created in the `build/outputs` folder of your project.
3737

3838
* Select the `projectDirectory` that contains the `pubspec.yaml` file.
39-
* Select the `target` platform. Options are: `apk` (default), `aab`, `ios`, `web`, `all` (Android and iOS, but without Web) or `allweb` (Android, iOS and Web).
39+
* Select the `target` platform. Options are: `apk` (default), `aab`, `ios`, `web`, `all mobile` (all mobile platforms only), `desktop (windows)`, `desktop (macos)`, `desktop (linux)`, `all desktop` (all desktop platforms only) , `all` (all platforms).
4040
* _(Optional)_. Set `flutterDirectory` to set path to the Flutter SDK if you were not using `Flutter Install` task before this one
4141
* _(Optional)_. Set `buildName` (like `1.2.3`) that will override the manifest's one.
4242
* _(Optional)_. Set `buildNumber` (like `12`) that will override the manifest's one.

tasks/build/index.js

Lines changed: 43 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,21 +40,42 @@ function main() {
4040
let isVerbose = task.getBoolInput('verboseMode', false);
4141
let extraArgs = task.getInput('extraArgs', false);
4242
// 5. Builds
43-
if (target === "all" || target === "ios") {
43+
if (target === "all"
44+
|| target === "mobile"
45+
|| target === "ios") {
4446
let targetPlatform = task.getInput('iosTargetPlatform', false);
4547
let codesign = task.getBoolInput('iosCodesign', false);
4648
yield buildIpa(flutterPath, targetPlatform == "simulator", codesign, buildName, buildNumber, debugMode, buildFlavour, entryPoint, dartDefine, isVerbose, extraArgs);
4749
}
48-
if (target === "all" || target === "apk") {
50+
if (target === "all"
51+
|| target === "mobile"
52+
|| target === "apk") {
4953
let targetPlatform = task.getInput('apkTargetPlatform', false);
5054
yield buildApk(flutterPath, targetPlatform, buildName, buildNumber, debugMode, buildFlavour, entryPoint, splitPerAbi, dartDefine, isVerbose, extraArgs);
5155
}
52-
if (target === "all" || target === "aab") {
56+
if (target === "all"
57+
|| target === "mobile"
58+
|| target === "aab") {
5359
yield buildAab(flutterPath, buildName, buildNumber, debugMode, buildFlavour, entryPoint, isVerbose, extraArgs);
5460
}
55-
if (target === "allweb" || target === "web") {
61+
if (target === "all" || target === "web") {
5662
yield buildWeb(flutterPath, isVerbose, extraArgs);
5763
}
64+
if (target === "all"
65+
|| target === "desktop"
66+
|| target === "windows") {
67+
yield buildDesktop(flutterPath, "windows", isVerbose, extraArgs);
68+
}
69+
if (target === "all"
70+
|| target === "desktop"
71+
|| target === "macos") {
72+
yield buildDesktop(flutterPath, "macos", isVerbose, extraArgs);
73+
}
74+
if (target === "all"
75+
|| target === "desktop"
76+
|| target === "linux") {
77+
yield buildDesktop(flutterPath, "linux", isVerbose, extraArgs);
78+
}
5879
task.setResult(task.TaskResult.Succeeded, "Application built");
5980
});
6081
}
@@ -201,6 +222,24 @@ function buildWeb(flutter, isVerbose, extraArgs) {
201222
}
202223
});
203224
}
225+
function buildDesktop(flutter, os, isVerbose, extraArgs) {
226+
return __awaiter(this, void 0, void 0, function* () {
227+
var args = [
228+
"build",
229+
os
230+
];
231+
if (isVerbose) {
232+
args.push("--verbose");
233+
}
234+
if (extraArgs) {
235+
args.push(extraArgs);
236+
}
237+
var result = yield task.exec(flutter, args);
238+
if (result !== 0) {
239+
throw new Error("desktop (windows) build failed");
240+
}
241+
});
242+
}
204243
main().catch(error => {
205244
task.setResult(task.TaskResult.Failed, error);
206245
});

tasks/build/index.ts

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,9 @@ async function main(): Promise<void> {
3434
let extraArgs = task.getInput('extraArgs', false);
3535

3636
// 5. Builds
37-
if (target === "all" || target === "ios") {
37+
if (target === "all"
38+
|| target === "mobile"
39+
|| target === "ios") {
3840
let targetPlatform = task.getInput('iosTargetPlatform', false);
3941
let codesign = task.getBoolInput('iosCodesign', false);
4042
await buildIpa(
@@ -51,7 +53,9 @@ async function main(): Promise<void> {
5153
extraArgs);
5254
}
5355

54-
if (target === "all" || target === "apk") {
56+
if (target === "all"
57+
|| target === "mobile"
58+
|| target === "apk") {
5559
let targetPlatform = task.getInput('apkTargetPlatform', false);
5660
await buildApk(
5761
flutterPath,
@@ -67,7 +71,9 @@ async function main(): Promise<void> {
6771
extraArgs);
6872
}
6973

70-
if (target === "all" || target === "aab") {
74+
if (target === "all"
75+
|| target === "mobile"
76+
|| target === "aab") {
7177
await buildAab(
7278
flutterPath,
7379
buildName,
@@ -79,9 +85,26 @@ async function main(): Promise<void> {
7985
extraArgs);
8086
}
8187

82-
if (target === "allweb" || target === "web") {
83-
await buildWeb(flutterPath, isVerbose,
84-
extraArgs);
88+
if (target === "all" || target === "web") {
89+
await buildWeb(flutterPath, isVerbose, extraArgs);
90+
}
91+
92+
if (target === "all"
93+
|| target === "desktop"
94+
|| target === "windows") {
95+
await buildDesktop(flutterPath, "windows", isVerbose, extraArgs);
96+
}
97+
98+
if (target === "all"
99+
|| target === "desktop"
100+
|| target === "macos") {
101+
await buildDesktop(flutterPath, "macos", isVerbose, extraArgs);
102+
}
103+
104+
if (target === "all"
105+
|| target === "desktop"
106+
|| target === "linux") {
107+
await buildDesktop(flutterPath, "linux", isVerbose, extraArgs);
85108
}
86109

87110
task.setResult(task.TaskResult.Succeeded, "Application built");
@@ -275,7 +298,7 @@ async function buildIpa(
275298
}
276299

277300
async function buildWeb(
278-
flutter: string,
301+
flutter: string,
279302
isVerbose?: boolean,
280303
extraArgs?: string) {
281304

@@ -299,6 +322,31 @@ async function buildWeb(
299322
}
300323
}
301324

325+
async function buildDesktop(
326+
flutter: string,
327+
os: string,
328+
isVerbose?: boolean,
329+
extraArgs?: string) {
330+
331+
var args = [
332+
"build",
333+
os
334+
];
335+
336+
if (isVerbose) {
337+
args.push("--verbose");
338+
}
339+
340+
if (extraArgs) {
341+
args.push(extraArgs);
342+
}
343+
344+
var result = await task.exec(flutter, args);
345+
346+
if (result !== 0) {
347+
throw new Error("desktop (windows) build failed");
348+
}
349+
}
302350

303351
main().catch(error => {
304352
task.setResult(task.TaskResult.Failed, error);

tasks/build/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tasks/build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "flutterbuild",
3-
"version": "0.2.40",
3+
"version": "0.2.43",
44
"description": "Flutter Build Task",
55
"main": "index.js",
66
"scripts": {

tasks/build/task.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"version": {
1313
"Major": 0,
1414
"Minor": 2,
15-
"Patch": 42
15+
"Patch": 43
1616
},
1717
"groups": [],
1818
"instanceNameFormat": "Flutter Build $(target)",
@@ -25,12 +25,16 @@
2525
"helpMarkDown": "The target platform of your application.",
2626
"required": true,
2727
"options": {
28-
"allweb": "All (with 'web')",
29-
"all": "All (except 'web')",
28+
"all": "All Platforms",
29+
"mobile": "All Mobile Platform Only",
30+
"desktop": "All Desktop Platform Only",
3031
"ios": "iOS",
3132
"apk": "Android (apk)",
3233
"aab": "Android (aab)",
33-
"web": "Web"
34+
"web": "Web",
35+
"windows": "Desktop (windows)",
36+
"macos": "Desktop (macos)",
37+
"linux": "Desktop (linux)"
3438
}
3539
},
3640
{

vss-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifestVersion": 1,
33
"id": "flutter",
4-
"version": "0.2.46",
4+
"version": "0.2.47",
55
"name": "Flutter Tasks",
66
"description": "Flutter extension for Azure DevOps. Active-Updated Fork of aloisdeniel/vsts-flutter-tasks",
77
"publisher": "hey24sheep",

0 commit comments

Comments
 (0)