예제 #1
0
  private Parameters initParams(ProviderOperationParameters operationParameters) {
    BuildLayoutParameters layout = new BuildLayoutParameters();
    if (operationParameters.getGradleUserHomeDir() != null) {
      layout.setGradleUserHomeDir(operationParameters.getGradleUserHomeDir());
    }
    layout.setSearchUpwards(
        operationParameters.isSearchUpwards() != null
            ? operationParameters.isSearchUpwards()
            : true);
    layout.setProjectDir(operationParameters.getProjectDir());

    Map<String, String> properties = new HashMap<String, String>();
    new LayoutToPropertiesConverter().convert(layout, properties);

    DaemonParameters daemonParams = new DaemonParameters(layout);
    new PropertiesToDaemonParametersConverter().convert(properties, daemonParams);
    if (operationParameters.getDaemonBaseDir(null) != null) {
      daemonParams.setBaseDir(operationParameters.getDaemonBaseDir(null));
    }

    // override the params with the explicit settings provided by the tooling api
    List<String> defaultJvmArgs = daemonParams.getAllJvmArgs();
    daemonParams.setJvmArgs(operationParameters.getJvmArguments(defaultJvmArgs));
    File defaultJavaHome = daemonParams.getEffectiveJavaHome();
    daemonParams.setJavaHome(operationParameters.getJavaHome(defaultJavaHome));

    if (operationParameters.getDaemonMaxIdleTimeValue() != null
        && operationParameters.getDaemonMaxIdleTimeUnits() != null) {
      int idleTimeout =
          (int)
              operationParameters
                  .getDaemonMaxIdleTimeUnits()
                  .toMillis(operationParameters.getDaemonMaxIdleTimeValue());
      daemonParams.setIdleTimeout(idleTimeout);
    }

    return new Parameters(daemonParams, properties);
  }
예제 #2
0
 private boolean hasJavaHome(DaemonParameters requiredJavaHome) {
   return getJavaHome().equals(requiredJavaHome.getEffectiveJavaHome());
 }