Search in sources :

Example 6 with WrapperConfiguration

use of org.gradle.wrapper.WrapperConfiguration in project intellij-community by JetBrains.

the class GradleInstallationManager method getGradleHome.

@Nullable
private File getGradleHome(@NotNull DistributionType distributionType, @NotNull String linkedProjectPath, @Nullable String gradleHome) {
    File candidate = null;
    switch(distributionType) {
        case LOCAL:
        case WRAPPED:
            if (gradleHome != null) {
                candidate = new File(gradleHome);
            }
            break;
        case DEFAULT_WRAPPED:
            WrapperConfiguration wrapperConfiguration = GradleUtil.getWrapperConfiguration(linkedProjectPath);
            candidate = getWrappedGradleHome(linkedProjectPath, wrapperConfiguration);
            break;
        case BUNDLED:
            WrapperConfiguration bundledWrapperSettings = new WrapperConfiguration();
            DistributionLocator distributionLocator = new DistributionLocator();
            bundledWrapperSettings.setDistribution(distributionLocator.getDistributionFor(GradleVersion.current()));
            candidate = getWrappedGradleHome(linkedProjectPath, bundledWrapperSettings);
            break;
    }
    File result = null;
    if (candidate != null) {
        result = isGradleSdkHome(candidate) ? candidate : null;
    }
    if (result != null) {
        return result;
    }
    return getAutodetectedGradleHome();
}
Also used : DistributionLocator(org.gradle.util.DistributionLocator) WrapperConfiguration(org.gradle.wrapper.WrapperConfiguration) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

WrapperConfiguration (org.gradle.wrapper.WrapperConfiguration)6 File (java.io.File)4 URI (java.net.URI)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)3 Properties (java.util.Properties)3 IOException (java.io.IOException)2 URISyntaxException (java.net.URISyntaxException)2 Nullable (org.jetbrains.annotations.Nullable)2 Result (com.intellij.openapi.application.Result)1 WriteAction (com.intellij.openapi.application.WriteAction)1 ExternalSystemException (com.intellij.openapi.externalSystem.model.ExternalSystemException)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 IndexNotReadyException (com.intellij.openapi.project.IndexNotReadyException)1 BufferedReader (java.io.BufferedReader)1 FileReader (java.io.FileReader)1 StringWriter (java.io.StringWriter)1 ZipException (java.util.zip.ZipException)1 ZipFile (java.util.zip.ZipFile)1 DistributionLocator (org.gradle.util.DistributionLocator)1 PathAssembler (org.gradle.wrapper.PathAssembler)1