示例#1
0
  /** Call this to browse for a custom gradle executor. */
  private void browseForCustomGradleExecutor() {
    File startingDirectory = new File(SystemProperties.getInstance().getUserHome());
    File currentFile = gradlePluginLord.getCustomGradleExecutor();
    if (currentFile != null) {
      startingDirectory = currentFile.getAbsoluteFile();
    } else {
      if (gradlePluginLord.getCurrentDirectory() != null) {
        startingDirectory = gradlePluginLord.getCurrentDirectory();
      }
    }

    JFileChooser chooser = new JFileChooser(startingDirectory);
    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setMultiSelectionEnabled(false);

    File file = null;
    if (chooser.showOpenDialog(mainPanel) == JFileChooser.APPROVE_OPTION) {
      file = chooser.getSelectedFile();
    }

    if (file != null) {
      setCustomGradleExecutor(file);
    } else { // if they canceled, and they have no custom gradle executor specified, then we must
             // clear things
      // This will reset the UI back to 'not using a custom executor'. We can't have them check the
      // field and not have a value here.
      if (gradlePluginLord.getCustomGradleExecutor() == null) {
        setCustomGradleExecutor(null);
      }
    }
  }
示例#2
0
  private String createDiagnosticsMessage(
      String trailingMessage, GradleExecutionResult gradleExecutionResult) {
    String lineBreak = SystemProperties.getInstance().getLineSeparator();
    StringBuilder message = new StringBuilder();
    message.append(trailingMessage);
    message.append(" in ");
    message.append(getProjectDir().getAbsolutePath());
    message.append(" with arguments ");
    message.append(getArguments());
    message.append(lineBreak).append(lineBreak);
    message.append("Output:");
    message.append(lineBreak);
    message.append(gradleExecutionResult.getStandardOutput());
    message.append(lineBreak);
    message.append(DIAGNOSTICS_MESSAGE_SEPARATOR);
    message.append(lineBreak);
    message.append("Error:");
    message.append(lineBreak);
    message.append(gradleExecutionResult.getStandardError());
    message.append(lineBreak);
    message.append(DIAGNOSTICS_MESSAGE_SEPARATOR);

    if (gradleExecutionResult.getThrowable() != null) {
      message.append(lineBreak);
      message.append("Reason:");
      message.append(lineBreak);
      message.append(determineExceptionMessage(gradleExecutionResult.getThrowable()));
      message.append(lineBreak);
      message.append(DIAGNOSTICS_MESSAGE_SEPARATOR);
    }

    return message.toString();
  }
示例#3
0
 public static String getUserAgentString() {
   String osName = System.getProperty("os.name");
   String osVersion = System.getProperty("os.version");
   String osArch = System.getProperty("os.arch");
   String javaVendor = System.getProperty("java.vendor");
   String javaVersion = SystemProperties.getInstance().getJavaVersion();
   String javaVendorVersion = System.getProperty("java.vm.version");
   return String.format(
       "Gradle/%s (%s;%s;%s) (%s;%s;%s)",
       GradleVersion.current().getVersion(),
       osName,
       osVersion,
       osArch,
       javaVendor,
       javaVersion,
       javaVendorVersion);
 }
示例#4
0
  /** Browses for a file using the text value from the text field as the current value. */
  private File browseForDirectory(File initialFile) {

    if (initialFile == null) {
      initialFile = SystemProperties.getInstance().getCurrentDir();
    }

    JFileChooser chooser = new JFileChooser(initialFile);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setMultiSelectionEnabled(false);

    File file = null;
    if (chooser.showOpenDialog(mainPanel) == JFileChooser.APPROVE_OPTION) {
      file = chooser.getSelectedFile();
    }

    return file;
  }
示例#5
0
 public List<JvmInstallation> findJvms() {
   List<JvmInstallation> jvms = new ArrayList<JvmInstallation>();
   for (File file : new File(SystemProperties.getUserHome()).listFiles()) {
     Matcher matcher = JDK_DIR.matcher(file.getName());
     if (matcher.matches() && new File(file, "bin/javac").isFile()) {
       String version = matcher.group(1);
       jvms.add(
           new JvmInstallation(
               JavaVersion.toVersion(version),
               version,
               file,
               true,
               JvmInstallation.Arch.Unknown));
     }
   }
   return jvms;
 }
 public <T> T execute(
     BuildAction<T> action,
     BuildCancellationToken cancellationToken,
     ProviderOperationParameters actionParameters) {
   BuildActionParameters parameters =
       new DefaultBuildActionParameters(
           new GradleLauncherMetaData(),
           actionParameters.getStartTime(),
           this.parameters.getEffectiveSystemProperties(),
           System.getenv(),
           SystemProperties.getCurrentDir(),
           actionParameters.getBuildLogLevel());
   try {
     return executer.execute(action, cancellationToken, parameters);
   } catch (ReportedException e) {
     throw new BuildExceptionVersion1(e.getCause());
   }
 }
示例#7
0
  @SuppressWarnings("StringBufferReplaceableByString")
  String createDiagnosticsMessage(
      String trailingMessage, GradleExecutionResult gradleExecutionResult) {
    String lineBreak = SystemProperties.getInstance().getLineSeparator();
    StringBuilder message = new StringBuilder();
    message.append(trailingMessage);
    message.append(" in ");
    message.append(getProjectDir().getAbsolutePath());
    message.append(" with arguments ");
    message.append(getArguments());

    String output = gradleExecutionResult.getOutput();
    if (output != null && !output.isEmpty()) {
      message.append(lineBreak);
      message.append(lineBreak);
      message.append("Output:");
      message.append(lineBreak);
      message.append(output);
    }

    return message.toString();
  }
示例#8
0
 private Runnable runBuild(
     StartParameter startParameter,
     DaemonParameters daemonParameters,
     BuildActionExecuter<BuildActionParameters> executer,
     ServiceRegistry sharedServices) {
   BuildActionParameters parameters =
       new DefaultBuildActionParameters(
           daemonParameters.getEffectiveSystemProperties(),
           System.getenv(),
           SystemProperties.getInstance().getCurrentDir(),
           startParameter.getLogLevel(),
           daemonParameters.getDaemonUsage(),
           startParameter.isContinuous(),
           daemonParameters.isInteractive(),
           ClassPath.EMPTY);
   return new RunBuildAction(
       executer,
       startParameter,
       clientMetaData(),
       getBuildStartTime(),
       parameters,
       sharedServices);
 }
 protected LocalMavenRepositoryLocator createLocalMavenRepositoryLocator() {
   return new DefaultLocalMavenRepositoryLocator(
       get(MavenSettingsProvider.class), SystemProperties.asMap(), System.getenv());
 }
 protected LocalMavenRepositoryLocator createLocalMavenRepositoryLocator() {
   return new DefaultLocalMavenRepositoryLocator(
       new DefaultMavenFileLocations(), SystemProperties.asMap(), System.getenv());
 }