TaskContainer.add is deprecated in Gradle 1.6+

Issue #14 resolved
Joshua Foster
created an issue

Gradle 1.6 renamed the "add" method to "create".

See following warning and stacktrace:

The TaskContainer.add() method has been deprecated and is scheduled to be removed in Gradle 2.0. Please use the create() method instead.
    org.gradle.util.SingleMessageLogger.logTraceIfNecessary(SingleMessageLogger.java:183)
    org.gradle.util.SingleMessageLogger.nagUserWith(SingleMessageLogger.java:140)
    org.gradle.util.SingleMessageLogger.nagUserOfReplacedMethod(SingleMessageLogger.java:102)
    org.gradle.api.internal.tasks.DefaultTaskContainer.add(DefaultTaskContainer.java:81)
    org.gradle.api.tasks.TaskContainer$add.call(Unknown Source)
    clojuresque.ClojureBasePlugin$_configureCompilation_closure4.doCall(ClojureBasePlugin.groovy:108)
    clojuresque.ClojureBasePlugin.configureCompilation(ClojureBasePlugin.groovy:104)
    clojuresque.ClojureBasePlugin.this$2$configureCompilation(ClojureBasePlugin.groovy)
    clojuresque.ClojureBasePlugin$this$2$configureCompilation.callCurrent(Unknown Source)
    clojuresque.ClojureBasePlugin.apply(ClojureBasePlugin.groovy:51)
    clojuresque.ClojureBasePlugin.apply(ClojureBasePlugin.groovy)
    org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:107)
    org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:71)
    org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:41)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:90)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$100(DefaultObjectConfigurationAction.java:32)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$2.run(DefaultObjectConfigurationAction.java:63)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
    org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:39)
    org.gradle.api.Project$apply.call(Unknown Source)
    clojuresque.ClojurePlugin.apply(ClojurePlugin.groovy:33)
    clojuresque.ClojurePlugin.apply(ClojurePlugin.groovy)
    org.gradle.api.internal.plugins.DefaultPluginContainer.providePlugin(DefaultPluginContainer.java:107)
    org.gradle.api.internal.plugins.DefaultPluginContainer.addPluginInternal(DefaultPluginContainer.java:71)
    org.gradle.api.internal.plugins.DefaultPluginContainer.apply(DefaultPluginContainer.java:37)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.applyPlugin(DefaultObjectConfigurationAction.java:101)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.access$200(DefaultObjectConfigurationAction.java:32)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction$3.run(DefaultObjectConfigurationAction.java:72)
    org.gradle.api.internal.plugins.DefaultObjectConfigurationAction.execute(DefaultObjectConfigurationAction.java:114)
    org.gradle.api.internal.project.AbstractPluginAware.apply(AbstractPluginAware.java:39)
    org.gradle.api.Project$apply.call(Unknown Source)
    org.gradle.api.internal.project.ProjectScript.apply(ProjectScript.groovy:34)
    org.gradle.api.Script$apply.callCurrent(Unknown Source)
    build_5kbav2ep44l9ta2e0vn1rmvatv.run(****\build.gradle:1)
    org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:52)
    org.gradle.configuration.DefaultScriptPluginFactory$ScriptPluginImpl.apply(DefaultScriptPluginFactory.java:127)
    org.gradle.configuration.BuildScriptProcessor.execute(BuildScriptProcessor.java:36)
    org.gradle.configuration.BuildScriptProcessor.execute(BuildScriptProcessor.java:23)
    org.gradle.configuration.ConfigureActionsProjectEvaluator.evaluate(ConfigureActionsProjectEvaluator.java:34)
    org.gradle.configuration.LifecycleProjectEvaluator.evaluate(LifecycleProjectEvaluator.java:55)
    org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:465)
    org.gradle.api.internal.project.AbstractProject.evaluate(AbstractProject.java:76)
    org.gradle.configuration.DefaultBuildConfigurer.configure(DefaultBuildConfigurer.java:31)
    org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:142)
    org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:113)
    org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:81)
    org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:64)
    org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:33)
    org.gradle.launcher.cli.ExecuteBuildAction.run(ExecuteBuildAction.java:24)
    org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:35)
    org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:50)
    org.gradle.api.internal.Actions$RunnableActionAdapter.execute(Actions.java:171)
    org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:201)
    org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:174)
    org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:170)
    org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:139)
    org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
    org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
    org.gradle.launcher.Main.doAction(Main.java:48)
    org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
    org.gradle.launcher.Main.main(Main.java:39)
    org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:50)
    org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:32)
    org.gradle.launcher.GradleMain.main(GradleMain.java:26)

Comments (8)

  1. Meikel Brandmeyer

    That it is an issue. I can switch to create, but that will exclude quite a bit of people who might not have upgraded, yet. (Including myself)

    I can keep add for a while (2.0 is not here, yet), but the you will be annoyed with the message every build. I fear there will be no way around two branches.

    I will check the gradle guys.

  2. Joshua Foster reporter

    I somewhat see 3 options:

    1. Leave as is till closer to 2.0 so people have a chance to upgrade.
    2. Update to create and let people who don't upgrade to 1.6 stay on older versions of the plugin
    3. Check the Gradle.gradleVersion and call create or add based one if it is greater than 1.6

    Personally, I think maybe a mix of 1 and 2 are preferrable.

  3. Joshua Foster reporter

    According to the 1.6 release notes, the create methods have been there from before 1.0.

    To improve consistency in the Gradle API, we've replaced the container add() methods with a create() method. Since well before Gradle 1.0, every container type has had a number of create() methods which both create a new object and add it to the container. Some older container types also define an add() method which does the same thing, but also conflicts with the add() method inherited from java.util.Collection which simply adds an object rather than creating it. To simplify this, these add() methods have now been deprecated and will be removed in Gradle 2.0.

  4. Joshua Foster reporter

    I did the update and tested it. The create was introduced in 1.6 so it would need to include a version check for the right one to call or require people to move to 1.6. Let me know if you want a pull request.

  5. Meikel Brandmeyer

    To answer your questions: I don't want to force users to upgrade. So I have to find a way to tackle this.

    A pull request would be nice, but please take care about the included changes. I found pull request to be often a mix of various unrelated changes. Thank you.

  6. Log in to comment