fix: 🐛 Fix running on macos

This commit is contained in:
2024-05-19 20:45:14 +02:00
parent 8755904ca5
commit c478bfec45
3 changed files with 146 additions and 2 deletions

View File

@ -81,16 +81,35 @@ class FlutterGradlePlugin implements Plugin<Project> {
}
List<String> dartCommand(String... args) {
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
String osName = System.getProperty('os.name').toLowerCase();
if (osName.contains('windows')) {
return ['cmd', '/c', 'dart'] + args.toList()
} else if (osName.contains('mac')) {
String dartPath = new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'which', 'dart'
standardOutput = os
}
os.toString().trim()
return [dartPath] + args.toList()
}
} else {
return ['dart'] + args.toList()
}
}
List<String> flutterCommand(String... args) {
if (System.getProperty('os.name').toLowerCase().contains('windows')) {
String osName = System.getProperty('os.name').toLowerCase();
if (osName.contains('windows')) {
return ['cmd', '/c', 'flutter'] + args.toList()
} else if (osName.contains('mac')) {
String flutterPath = new ByteArrayOutputStream().withStream { os ->
exec {
commandLine 'which', 'flutter'
standardOutput = os
}
os.toString().trim()
return [flutterPath] + args.toList()
} else {
return ['flutter'] + args.toList()
}