forked from qt-creator/qt-creator
Android: Get Java home location from the java_home tool on OS X.
If the java_home executable exists on OS X we can run it to get the current JDK location. Change-Id: I5d032d153cba4d7168931ab0f83723292d3d714a Reviewed-by: Daniel Teske <daniel.teske@theqtcompany.com>
This commit is contained in:
committed by
Christian Stromme
parent
5bc0d37479
commit
7dd847404f
@@ -1483,9 +1483,19 @@ void AndroidConfigurations::load()
|
|||||||
saveSettings = true;
|
saveSettings = true;
|
||||||
}
|
}
|
||||||
} else if (HostOsInfo::isMacHost()) {
|
} else if (HostOsInfo::isMacHost()) {
|
||||||
QString javaHome = QLatin1String("/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home");
|
QFileInfo javaHomeExec(QLatin1String("/usr/libexec/java_home"));
|
||||||
if (QFileInfo::exists(javaHome))
|
if (javaHomeExec.isExecutable() && !javaHomeExec.isDir()) {
|
||||||
m_config.setOpenJDKLocation(FileName::fromString(javaHome));
|
QProcess proc;
|
||||||
|
proc.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
|
proc.start(javaHomeExec.absoluteFilePath());
|
||||||
|
if (!proc.waitForFinished(2000)) {
|
||||||
|
proc.kill();
|
||||||
|
} else {
|
||||||
|
const QString &javaHome = QString::fromLocal8Bit(proc.readAll().trimmed());
|
||||||
|
if (!javaHome.isEmpty() && QFileInfo::exists(javaHome))
|
||||||
|
m_config.setOpenJDKLocation(FileName::fromString(javaHome));
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (HostOsInfo::isWindowsHost()) {
|
} else if (HostOsInfo::isWindowsHost()) {
|
||||||
QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Javasoft\\Java Development Kit"), QSettings::NativeFormat);
|
QSettings settings(QLatin1String("HKEY_LOCAL_MACHINE\\SOFTWARE\\Javasoft\\Java Development Kit"), QSettings::NativeFormat);
|
||||||
QStringList allVersions = settings.childGroups();
|
QStringList allVersions = settings.childGroups();
|
||||||
|
|||||||
Reference in New Issue
Block a user