Commit 66e54223 authored by Joao da Silva's avatar Joao da Silva Committed by Mehmet Fidanboylu

Check for AndroidStudio plugins in the right .dot dir. (#20619)

This fixes issues 11940 and 18155.
parent d02e67e7
......@@ -25,17 +25,19 @@ AndroidStudio get androidStudio => context[AndroidStudio];
// $HOME/Applications/Android Studio.app/Contents/
final RegExp _dotHomeStudioVersionMatcher =
RegExp(r'^\.AndroidStudio([^\d]*)([\d.]+)');
RegExp(r'^\.(AndroidStudio[^\d]*)([\d.]+)');
String get javaPath => androidStudio?.javaPath;
class AndroidStudio implements Comparable<AndroidStudio> {
AndroidStudio(this.directory, {Version version, this.configured})
AndroidStudio(this.directory,
{Version version, this.configured, this.studioAppName = 'AndroidStudio'})
: this.version = version ?? Version.unknown {
_init();
}
final String directory;
final String studioAppName;
final Version version;
final String configured;
......@@ -65,7 +67,8 @@ class AndroidStudio implements Comparable<AndroidStudio> {
return null;
}
final Version version = Version.parse(versionMatch[2]);
if (version == null) {
final String studioAppName = versionMatch[1];
if (studioAppName == null || version == null) {
return null;
}
String installPath;
......@@ -77,7 +80,11 @@ class AndroidStudio implements Comparable<AndroidStudio> {
// ignored, installPath will be null, which is handled below
}
if (installPath != null && fs.isDirectorySync(installPath)) {
return AndroidStudio(installPath, version: version);
return AndroidStudio(
installPath,
version: version,
studioAppName: studioAppName,
);
}
return null;
}
......@@ -98,7 +105,7 @@ class AndroidStudio implements Comparable<AndroidStudio> {
'AndroidStudio$major.$minor');
} else {
_pluginsPath = fs.path.join(homeDirPath,
'.AndroidStudio$major.$minor',
'.$studioAppName$major.$minor',
'config',
'plugins');
}
......
import 'package:file/memory.dart';
import 'package:flutter_tools/src/android/android_studio.dart';
import 'package:flutter_tools/src/base/file_system.dart';
import 'package:flutter_tools/src/base/platform.dart';
import '../src/common.dart';
import '../src/context.dart';
const String home = '/home/me';
Platform linuxPlatform() {
return FakePlatform.fromPlatform(const LocalPlatform())
..operatingSystem = 'linux'
..environment = <String, String>{'HOME': home};
}
void main() {
const String installPath = '/opt/android-studio-with-cheese-5.0';
const String studioHome = '$home/.AndroidStudioWithCheese5.0';
const String homeFile = '$studioHome/system/.home';
MemoryFileSystem fs;
setUp(() {
fs = MemoryFileSystem();
fs.directory(installPath).createSync(recursive: true);
fs.file(homeFile).createSync(recursive: true);
fs.file(homeFile).writeAsStringSync(installPath);
});
group('pluginsPath', () {
testUsingContext('extracts custom paths from home dir', () {
final AndroidStudio studio =
AndroidStudio.fromHomeDot(fs.directory(studioHome));
expect(studio, isNotNull);
expect(studio.pluginsPath,
equals('/home/me/.AndroidStudioWithCheese5.0/config/plugins'));
}, overrides: <Type, Generator>{
FileSystem: () => fs,
// Note that custom home paths are not supported on macOS nor Windows yet:
Platform: () => linuxPlatform(),
});
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment