public GradleConnector prepareConnector()

in gradle-runner-agent/src/main/java/jetbrains/buildServer/gradle/runtime/service/GradleBuildConfigurator.java [38:72]


  public GradleConnector prepareConnector(@NotNull String workingDirectoryPath,
                                          @NotNull Boolean useWrapper,
                                          @Nullable String gradleWrapperPropertiesPath,
                                          @Nullable String gradleHomePath) {
    File workingDirectory = new File(workingDirectoryPath);

    GradleConnector connector = GradleConnector.newConnector();
    connector.forProjectDirectory(workingDirectory);

    if (useWrapper) {
      if (gradleWrapperPropertiesPath == null) {
        throw new RuntimeException("Parameter " + GradleRunnerConstants.GRADLE_WRAPPED_DISTRIBUTION_ENV_KEY
                                   + " must be present in environment variables.");
      }
      File gradleWrapperProperties = new File(gradleWrapperPropertiesPath);
      if (!gradleWrapperProperties.exists()) {
        throw new RuntimeException("File doesn't exist: " + gradleWrapperPropertiesPath);
      }

      DistributionFactoryExtension.setWrappedDistribution(connector, gradleWrapperProperties.getAbsolutePath());
    } else {
      if (gradleHomePath == null) {
        throw new RuntimeException("Parameter " + GradleRunnerConstants.GRADLE_HOME_ENV_KEY
                                   + " must be present in environment variables.");
      }
      File gradleHome = new File(gradleHomePath);
      if (!gradleHome.exists()) {
        throw new RuntimeException("File doesn't exist: " + gradleHomePath);
      }

      connector.useInstallation(gradleHome);
    }

    return connector;
  }