Example #1
0
 /**
  * Disables the HTML test report.
  *
  * @deprecated Replaced by {@code getReports().getHtml().setEnabled()}
  */
 @SuppressWarnings("UnusedDeclaration")
 @Deprecated
 public void disableTestReport() {
   DeprecationLogger.nagUserOfReplacedProperty(
       "Test.testReport", "Test.getReports().getHtml().setEnabled()");
   reports.getHtml().setEnabled(false);
 }
Example #2
0
 public T parseNotation(Object notation) {
   if (notation == null) {
     return null;
   }
   if (notation instanceof CharSequence
       || notation instanceof Number
       || notation instanceof Boolean) {
     return (T) notation.toString();
   }
   if (notation instanceof Closure) {
     final Closure closure = (Closure) notation;
     final Object called = closure.call();
     return parseNotation(called);
   }
   if (notation instanceof Callable) {
     try {
       final Callable callableNotation = (Callable) notation;
       final Object called = callableNotation.call();
       return parseNotation(called);
     } catch (Exception e) {
       throw UncheckedException.throwAsUncheckedException(e);
     }
   }
   DeprecationLogger.nagUserOfDeprecated(
       String.format(
           "Converting class %s to path using toString() method", notation.getClass().getName()),
       "Please use java.io.File, java.lang.CharSequence, java.lang.Number, java.util.concurrent.Callable or groovy.lang.Closure");
   return (T) notation.toString();
 }
Example #3
0
 @Deprecated
 public void setUseMavenMetadata(boolean useMavenMetadata) {
   DeprecationLogger.nagUserOfDiscontinuedMethod("MavenResolver.setUseMavenMetadata(boolean)");
   this.useMavenMetadata = useMavenMetadata;
   if (useMavenMetadata) {
     this.versionLister =
         new ChainedVersionLister(
             new MavenVersionLister(getRepository()), new ResourceVersionLister(getRepository()));
   } else {
     this.versionLister = new ResourceVersionLister(getRepository());
   }
 }
 @Override
 public GradleExecuter reset() {
   DeprecationLogger.reset();
   return super.reset();
 }
  private BuildResult doRun(
      final OutputListenerImpl outputListener,
      OutputListenerImpl errorListener,
      BuildListenerImpl listener) {
    // Capture the current state of things that we will change during execution
    InputStream originalStdIn = System.in;
    Properties originalSysProperties = new Properties();
    originalSysProperties.putAll(System.getProperties());
    File originalUserDir = new File(originalSysProperties.getProperty("user.dir"));
    Map<String, String> originalEnv = new HashMap<String, String>(System.getenv());

    // Augment the environment for the execution
    System.setIn(getStdin());
    processEnvironment.maybeSetProcessDir(getWorkingDir());
    for (Map.Entry<String, String> entry : getEnvironmentVars().entrySet()) {
      processEnvironment.maybeSetEnvironmentVariable(entry.getKey(), entry.getValue());
    }
    Map<String, String> implicitJvmSystemProperties = getImplicitJvmSystemProperties();
    System.getProperties().putAll(implicitJvmSystemProperties);

    DefaultStartParameter parameter = new DefaultStartParameter();
    parameter.setCurrentDir(getWorkingDir());
    parameter.setShowStacktrace(ShowStacktrace.ALWAYS);

    CommandLineParser parser = new CommandLineParser();
    DefaultCommandLineConverter converter = new DefaultCommandLineConverter();
    converter.configure(parser);
    ParsedCommandLine parsedCommandLine = parser.parse(getAllArgs());

    BuildLayoutParameters layout = converter.getLayoutConverter().convert(parsedCommandLine);

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

    new PropertiesToStartParameterConverter().convert(properties, parameter);
    converter.convert(parsedCommandLine, parameter);

    DefaultGradleLauncherFactory factory =
        DeprecationLogger.whileDisabled(
            new Factory<DefaultGradleLauncherFactory>() {
              public DefaultGradleLauncherFactory create() {
                return (DefaultGradleLauncherFactory) GradleLauncher.getFactory();
              }
            });
    factory.addListener(listener);
    GradleLauncher gradleLauncher = factory.newInstance(parameter);
    gradleLauncher.addStandardOutputListener(outputListener);
    gradleLauncher.addStandardErrorListener(errorListener);
    try {
      return gradleLauncher.run();
    } finally {
      // Restore the environment
      System.setProperties(originalSysProperties);
      processEnvironment.maybeSetProcessDir(originalUserDir);
      for (String envVar : getEnvironmentVars().keySet()) {
        String oldValue = originalEnv.get(envVar);
        if (oldValue != null) {
          processEnvironment.maybeSetEnvironmentVariable(envVar, oldValue);
        } else {
          processEnvironment.maybeRemoveEnvironmentVariable(envVar);
        }
      }
      factory.removeListener(listener);
      System.setIn(originalStdIn);
    }
  }
 public ResolvedDependency getResolvedDependency() {
   DeprecationLogger.nagUserWith(
       "ResolvedArtifact.getResolvedDependency() is deprecated. For version info use ResolvedArtifact.getModuleVersion(), to access the dependency graph use ResolvedConfiguration.getFirstLevelModuleDependencies()");
   return resolvedDependency;
 }
  private DefaultGradleLauncher doNewInstance(
      StartParameter startParameter, BuildRequestMetaData requestMetaData) {
    final BuildScopeServices serviceRegistry =
        new BuildScopeServices(sharedServices, startParameter);
    serviceRegistry.add(BuildRequestMetaData.class, requestMetaData);
    serviceRegistry.add(BuildClientMetaData.class, requestMetaData.getClient());
    ListenerManager listenerManager = serviceRegistry.get(ListenerManager.class);
    LoggingManagerInternal loggingManager =
        serviceRegistry.newInstance(LoggingManagerInternal.class);
    loggingManager.setLevel(startParameter.getLogLevel());

    // this hooks up the ListenerManager and LoggingConfigurer so you can call Gradle.addListener()
    // with a StandardOutputListener.
    loggingManager.addStandardOutputListener(
        listenerManager.getBroadcaster(StandardOutputListener.class));
    loggingManager.addStandardErrorListener(
        listenerManager.getBroadcaster(StandardOutputListener.class));

    listenerManager.useLogger(
        new TaskExecutionLogger(serviceRegistry.get(ProgressLoggerFactory.class)));
    if (tracker.getCurrentBuild() == null) {
      listenerManager.useLogger(
          new BuildLogger(
              Logging.getLogger(BuildLogger.class),
              serviceRegistry.get(StyledTextOutputFactory.class),
              startParameter,
              requestMetaData));
    }
    listenerManager.addListener(tracker);
    listenerManager.addListener(new BuildCleanupListener(serviceRegistry));

    listenerManager.addListener(serviceRegistry.get(ProfileEventAdapter.class));
    if (startParameter.isProfile()) {
      listenerManager.addListener(new ReportGeneratingProfileListener());
    }
    ScriptUsageLocationReporter usageLocationReporter = new ScriptUsageLocationReporter();
    listenerManager.addListener(usageLocationReporter);
    DeprecationLogger.useLocationReporter(usageLocationReporter);

    GradleInternal gradle =
        serviceRegistry
            .get(Instantiator.class)
            .newInstance(
                DefaultGradle.class, tracker.getCurrentBuild(), startParameter, serviceRegistry);
    return new DefaultGradleLauncher(
        gradle,
        serviceRegistry.get(InitScriptHandler.class),
        new SettingsHandler(
            new DefaultSettingsFinder(new BuildLayoutFactory()),
            serviceRegistry.get(SettingsProcessor.class),
            new BuildSourceBuilder(
                this,
                serviceRegistry.get(ClassLoaderRegistry.class),
                serviceRegistry.get(CacheRepository.class))),
        serviceRegistry.get(BuildLoader.class),
        serviceRegistry.get(BuildConfigurer.class),
        gradle.getBuildListenerBroadcaster(),
        serviceRegistry.get(ExceptionAnalyser.class),
        loggingManager,
        listenerManager.getBroadcaster(ModelConfigurationListener.class),
        listenerManager.getBroadcaster(TasksCompletionListener.class),
        gradle.getServices().get(BuildExecuter.class));
  }
Example #8
0
 /**
  * Sets whether the test HTML report should be generated.
  *
  * @deprecated Replaced by {@code getReports().getHtml().setEnabled()}
  */
 @Deprecated
 public void setTestReport(boolean testReport) {
   DeprecationLogger.nagUserOfReplacedProperty(
       "Test.testReport", "Test.getReports().getHtml().setEnabled()");
   reports.getHtml().setEnabled(testReport);
 }
Example #9
0
 /**
  * Specifies whether the test HTML report should be generated.
  *
  * @deprecated Replaced by {@code getReports().getHtml().isEnabled()}
  */
 @Deprecated
 public boolean isTestReport() {
   DeprecationLogger.nagUserOfReplacedProperty(
       "Test.testReport", "Test.getReports().getHtml().isEnabled()");
   return reports.getHtml().isEnabled();
 }
Example #10
0
 /**
  * Sets the root folder for the test reports.
  *
  * @param testReportDir The root folder
  * @deprecated Replaced by {@code getReports().getHtml().setDestination()}
  */
 @Deprecated
 public void setTestReportDir(File testReportDir) {
   DeprecationLogger.nagUserOfReplacedProperty(
       "Test.testReportDir", "Test.getReports().getHtml().getDestination()");
   reports.getHtml().setDestination(testReportDir);
 }
Example #11
0
 /**
  * Returns the root folder for the test reports.
  *
  * @return the test report directory, containing the test report mostly in HTML form.
  * @deprecated Replaced by {@code getReports().getHtml().getDestination()}
  */
 @Deprecated
 public File getTestReportDir() {
   DeprecationLogger.nagUserOfReplacedProperty(
       "Test.testReportDir", "Test.getReports().getHtml().getDestination()");
   return reports.getHtml().getDestination();
 }