Search in sources :

Example 1 with MissingRegistryEntryException

use of net.rubygrapefruit.platform.MissingRegistryEntryException in project gradle by gradle.

the class DefaultUcrtLocator method locateUcrtsInRegistry.

private void locateUcrtsInRegistry(String baseKey) {
    String[] keys = { REGISTRY_KIT_10 };
    for (String key : keys) {
        try {
            File ucrtDir = FileUtils.canonicalize(new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_KIT, key)));
            String[] versionDirs = getUcrtVersionDirs(ucrtDir);
            if (versionDirs.length > 0) {
                for (String versionDir : versionDirs) {
                    VersionNumber version = VersionNumber.withPatchNumber().parse(versionDir);
                    LOGGER.debug("Found ucrt {} at {}", version.toString(), ucrtDir);
                    putUcrt(new Ucrt(ucrtDir, NAME_KIT + " " + version.getMajor(), version));
                }
            } else {
                LOGGER.debug("Ignoring candidate ucrt directory {} as it does not look like a ucrt installation.", ucrtDir);
            }
        } catch (MissingRegistryEntryException e) {
        // Ignore the version if the string cannot be read
        }
    }
}
Also used : MissingRegistryEntryException(net.rubygrapefruit.platform.MissingRegistryEntryException) File(java.io.File) VersionNumber(org.gradle.util.VersionNumber)

Example 2 with MissingRegistryEntryException

use of net.rubygrapefruit.platform.MissingRegistryEntryException in project gradle by gradle.

the class DefaultWindowsSdkLocator method locateKitsInRegistry.

private void locateKitsInRegistry(String baseKey) {
    String[] versions = { VERSION_KIT_8, VERSION_KIT_81 };
    String[] keys = { REGISTRY_KIT_8, REGISTRY_KIT_81 };
    for (int i = 0; i != keys.length; ++i) {
        try {
            File kitDir = FileUtils.canonicalize(new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_KIT, keys[i])));
            if (isWindowsSdk(kitDir)) {
                LOGGER.debug("Found Windows Kit {} at {}", versions[i], kitDir);
                addSdk(kitDir, versions[i], NAME_KIT + " " + versions[i]);
            } else {
                LOGGER.debug("Ignoring candidate Windows Kit directory {} as it does not look like a Windows Kit installation.", kitDir);
            }
        } catch (MissingRegistryEntryException e) {
        // Ignore the version if the string cannot be read
        }
    }
}
Also used : MissingRegistryEntryException(net.rubygrapefruit.platform.MissingRegistryEntryException) File(java.io.File)

Example 3 with MissingRegistryEntryException

use of net.rubygrapefruit.platform.MissingRegistryEntryException in project gradle by gradle.

the class DefaultVisualStudioLocator method locateInstallsInRegistry.

private void locateInstallsInRegistry(String baseKey) {
    List<String> visualCppVersions;
    try {
        visualCppVersions = windowsRegistry.getValueNames(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_VC);
    } catch (MissingRegistryEntryException e) {
        // No Visual Studio information available in the registry
        return;
    }
    for (String valueName : visualCppVersions) {
        if (!valueName.matches("\\d+\\.\\d+")) {
            // Ignore the other values
            continue;
        }
        File visualCppDir = new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_VC, valueName));
        visualCppDir = FileUtils.canonicalize(visualCppDir);
        File visualStudioDir = visualCppDir.getParentFile();
        if (isVisualCpp(visualCppDir) && isVisualStudio(visualStudioDir)) {
            LOGGER.debug("Found Visual C++ {} at {}", valueName, visualCppDir);
            VersionNumber version = VersionNumber.parse(valueName);
            VisualCppInstall visualCpp = buildVisualCppInstall("Visual C++ " + valueName, visualStudioDir, visualCppDir, version);
            VisualStudioInstall visualStudio = new VisualStudioInstall(visualStudioDir, visualCpp);
            foundInstalls.put(visualStudioDir, visualStudio);
        } else {
            LOGGER.debug("Ignoring candidate Visual C++ directory {} as it does not look like a Visual C++ installation.", visualCppDir);
        }
    }
}
Also used : MissingRegistryEntryException(net.rubygrapefruit.platform.MissingRegistryEntryException) File(java.io.File) VersionNumber(org.gradle.util.VersionNumber)

Example 4 with MissingRegistryEntryException

use of net.rubygrapefruit.platform.MissingRegistryEntryException in project gradle by gradle.

the class DefaultWindowsSdkLocator method locateSdksInRegistry.

private void locateSdksInRegistry(String baseKey) {
    try {
        List<String> subkeys = windowsRegistry.getSubkeys(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, baseKey + REGISTRY_ROOTPATH_SDK);
        for (String subkey : subkeys) {
            try {
                String basePath = baseKey + REGISTRY_ROOTPATH_SDK + "\\" + subkey;
                File sdkDir = FileUtils.canonicalize(new File(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, basePath, REGISTRY_FOLDER)));
                String version = formatVersion(windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, basePath, REGISTRY_VERSION));
                String name = windowsRegistry.getStringValue(WindowsRegistry.Key.HKEY_LOCAL_MACHINE, basePath, REGISTRY_NAME);
                if (isWindowsSdk(sdkDir)) {
                    LOGGER.debug("Found Windows SDK {} at {}", version, sdkDir);
                    addSdk(sdkDir, version, name);
                } else {
                    LOGGER.debug("Ignoring candidate Windows SDK directory {} as it does not look like a Windows SDK installation.", sdkDir);
                }
            } catch (MissingRegistryEntryException e) {
            // Ignore the subkey if it doesn't have a folder and version
            }
        }
    } catch (MissingRegistryEntryException e) {
    // No SDK information available in the registry
    }
}
Also used : MissingRegistryEntryException(net.rubygrapefruit.platform.MissingRegistryEntryException) File(java.io.File)

Aggregations

File (java.io.File)4 MissingRegistryEntryException (net.rubygrapefruit.platform.MissingRegistryEntryException)4 VersionNumber (org.gradle.util.VersionNumber)2