Skip to content

Commit

Permalink
fix: flutter build without flavor
Browse files Browse the repository at this point in the history
  • Loading branch information
vanlooverenkoen committed Sep 24, 2024
1 parent aa6eb98 commit 1258482
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 6 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# 0.15.1

## Fix

- Issue where flavor was still used even if it was null (flutter build)

# 0.15.0

## Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,30 @@ enum FlutterBuildAndroidExtension {

extension FlutterBuildAndroidExtensions on FlutterBuildAndroidExtension {
Directory getBuildDirectory({String? flavor}) {
final List<String> parts;
switch (this) {
case FlutterBuildAndroidExtension.apk:
return Directory(
join('build', 'app', 'outputs', 'apk', flavor, 'release'));
parts = [
'build',
'app',
'outputs',
'apk',
if (flavor != null) flavor,
'release',
];
case FlutterBuildAndroidExtension.aab:
return Directory(
join('build', 'app', 'outputs', 'bundle', '${flavor}Release'));
parts = [
'build',
'app',
'outputs',
'bundle',
if (flavor == null) ...[
'release',
] else ...[
'${flavor}Release',
]
];
}
return Directory(joinAll(parts));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,16 @@ class FlutterBuildPlugin extends ImpaktfullCliPlugin {
'--build-number=$buildNr',
],
]);
final file = File(join(extension.getBuildDirectory(flavor: flavor).path,
'app-$flavor-release.${extension.fileExtension}'));
final file = File(joinAll(
[
extension.getBuildDirectory(flavor: flavor).path,
if (flavor == null) ...[
'app-release.${extension.fileExtension}',
] else ...[
'app-$flavor-release.${extension.fileExtension}',
],
],
));
if (!file.existsSync()) {
throw ImpaktfullCliError(
'After building $flavor for Android, `${file.path}` does not exists.');
Expand Down

0 comments on commit 1258482

Please sign in to comment.