Teach Flutter Tools about IntelliJ and Android SDK on Windows. (#7622)
Required for https://github.com/flutter/flutter/issues/138
This commit is contained in:
committed by
GitHub
parent
e14925d366
commit
aaaf0dac19
@@ -68,10 +68,13 @@ class AndroidSdk {
|
||||
androidHomeDir = Platform.environment[kAndroidHome];
|
||||
} else if (Platform.isLinux) {
|
||||
if (homeDirPath != null)
|
||||
androidHomeDir = '$homeDirPath/Android/Sdk';
|
||||
androidHomeDir = path.join(homeDirPath, 'Android', 'Sdk');
|
||||
} else if (Platform.isMacOS) {
|
||||
if (homeDirPath != null)
|
||||
androidHomeDir = '$homeDirPath/Library/Android/sdk';
|
||||
androidHomeDir = path.join(homeDirPath, 'Library', 'Android', 'sdk');
|
||||
} else if (Platform.isWindows) {
|
||||
if (homeDirPath != null)
|
||||
androidHomeDir = path.join(homeDirPath, 'AppData', 'Local', 'Android', 'sdk');
|
||||
}
|
||||
|
||||
if (androidHomeDir != null) {
|
||||
@@ -127,7 +130,7 @@ class AndroidSdk {
|
||||
}
|
||||
|
||||
String getPlatformToolsPath(String binaryName) {
|
||||
return path.join(directory, 'platform-tools', binaryName);
|
||||
return path.join(directory, 'platform-tools', os.getExecutableName(binaryName));
|
||||
}
|
||||
|
||||
void _init() {
|
||||
@@ -218,7 +221,7 @@ class AndroidSdkVersion implements Comparable<AndroidSdkVersion> {
|
||||
|
||||
String get aaptPath => getBuildToolsPath('aapt');
|
||||
|
||||
String get dxPath => getBuildToolsPath('dx');
|
||||
String get dxPath => getBuildToolsPath('dx', winExtension: 'bat');
|
||||
|
||||
String get zipalignPath => getBuildToolsPath('zipalign');
|
||||
|
||||
@@ -239,11 +242,11 @@ class AndroidSdkVersion implements Comparable<AndroidSdkVersion> {
|
||||
}
|
||||
|
||||
String getPlatformsPath(String itemName) {
|
||||
return path.join(sdk.directory, 'platforms', platformVersionName, itemName);
|
||||
return path.join(sdk.directory, 'platforms', platformVersionName, os.getExecutableName(itemName));
|
||||
}
|
||||
|
||||
String getBuildToolsPath(String binaryName) {
|
||||
return path.join(sdk.directory, 'build-tools', buildToolsVersionName, binaryName);
|
||||
String getBuildToolsPath(String binaryName, { String winExtension }) {
|
||||
return path.join(sdk.directory, 'build-tools', buildToolsVersionName, os.getExecutableName(binaryName, winExtension: winExtension));
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
@@ -62,6 +62,7 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
|
||||
}
|
||||
|
||||
List<String> validationResult = androidSdk.validateSdkWellFormed();
|
||||
// Empty result means SDK is well formated.
|
||||
|
||||
if (validationResult.isEmpty) {
|
||||
const String _kJdkDownload = 'https://www.oracle.com/technetwork/java/javase/downloads/';
|
||||
@@ -93,7 +94,7 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
|
||||
}
|
||||
} else {
|
||||
messages.add(new ValidationMessage.error(
|
||||
'No Java SDK found; you can download Java from $_kJdkDownload.'
|
||||
'No Java Development Kit (JDK) found; you can download the JDK from $_kJdkDownload.'
|
||||
));
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -44,6 +44,13 @@ abstract class OperatingSystemUtils {
|
||||
File makePipe(String path);
|
||||
|
||||
void unzip(File file, Directory targetDirectory);
|
||||
|
||||
/// Returns the name of the [binaryName] executable.
|
||||
///
|
||||
/// No-op on most OS.
|
||||
/// On Windows it returns [binaryName].[winExtension], if [winExtension] is
|
||||
/// specified, or [binaryName].exe otherwise.
|
||||
String getExecutableName(String binaryName, { String winExtension });
|
||||
}
|
||||
|
||||
class _PosixUtils extends OperatingSystemUtils {
|
||||
@@ -76,6 +83,9 @@ class _PosixUtils extends OperatingSystemUtils {
|
||||
runSync(<String>['mkfifo', path]);
|
||||
return fs.file(path);
|
||||
}
|
||||
|
||||
@override
|
||||
String getExecutableName(String binaryName, { String winExtension }) => binaryName;
|
||||
}
|
||||
|
||||
class _WindowsUtils extends OperatingSystemUtils {
|
||||
@@ -115,6 +125,14 @@ class _WindowsUtils extends OperatingSystemUtils {
|
||||
File makePipe(String path) {
|
||||
throw new UnsupportedError('makePipe is not implemented on Windows.');
|
||||
}
|
||||
|
||||
@override
|
||||
String getExecutableName(String binaryName, { String winExtension }) {
|
||||
winExtension ??= 'exe';
|
||||
if (path.extension(binaryName).isEmpty && winExtension.isNotEmpty)
|
||||
return '$binaryName.$winExtension';
|
||||
return binaryName;
|
||||
}
|
||||
}
|
||||
|
||||
Future<int> findAvailablePort() async {
|
||||
|
||||
@@ -254,11 +254,10 @@ abstract class IntelliJValidator extends DoctorValidator {
|
||||
};
|
||||
|
||||
static Iterable<DoctorValidator> get installedValidators {
|
||||
if (Platform.isLinux)
|
||||
return IntelliJValidatorOnLinux.installed;
|
||||
if (Platform.isLinux || Platform.isWindows)
|
||||
return IntelliJValidatorOnLinuxAndWindows.installed;
|
||||
if (Platform.isMacOS)
|
||||
return IntelliJValidatorOnMac.installed;
|
||||
// TODO(danrubel): add support for Windows
|
||||
return <DoctorValidator>[];
|
||||
}
|
||||
|
||||
@@ -328,8 +327,8 @@ abstract class IntelliJValidator extends DoctorValidator {
|
||||
}
|
||||
}
|
||||
|
||||
class IntelliJValidatorOnLinux extends IntelliJValidator {
|
||||
IntelliJValidatorOnLinux(String title, this.version, this.installPath, this.pluginsPath) : super(title);
|
||||
class IntelliJValidatorOnLinuxAndWindows extends IntelliJValidator {
|
||||
IntelliJValidatorOnLinuxAndWindows(String title, this.version, this.installPath, this.pluginsPath) : super(title);
|
||||
|
||||
@override
|
||||
String version;
|
||||
@@ -344,11 +343,11 @@ class IntelliJValidatorOnLinux extends IntelliJValidator {
|
||||
if (homeDirPath == null) return validators;
|
||||
|
||||
void addValidator(String title, String version, String installPath, String pluginsPath) {
|
||||
IntelliJValidatorOnLinux validator =
|
||||
new IntelliJValidatorOnLinux(title, version, installPath, pluginsPath);
|
||||
IntelliJValidatorOnLinuxAndWindows validator =
|
||||
new IntelliJValidatorOnLinuxAndWindows(title, version, installPath, pluginsPath);
|
||||
for (int index = 0; index < validators.length; ++index) {
|
||||
DoctorValidator other = validators[index];
|
||||
if (other is IntelliJValidatorOnLinux && validator.installPath == other.installPath) {
|
||||
if (other is IntelliJValidatorOnLinuxAndWindows && validator.installPath == other.installPath) {
|
||||
if (validator.version.compareTo(other.version) > 0)
|
||||
validators[index] = validator;
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user