Getting rid of: "plus operator on Iterable<FileCollection> deprecated" warning

(Karl-Johan Karlberg) #1


As of gradle 2.10 (?) we are getting warning:
The plus(Iterable) method and using the ‘+’ operator in conjunction with an Iterable object have been deprecated and are scheduled to be removed in 3.0. Please use the plus(FileCollection) method or the ‘+’ operator with a FileCollection object instead.

This comes from doing this:

eclipse {
    plusConfigurations +=  [ configurations.dbDriver ]

As suggested here:

I want to update this to get rid of this warning…

(Lance Java) #2
eclipse {
   classpath {
      plusConfigurations << configurations.dbDriver

(Karl-Johan Karlberg) #3

Many thanks (in the process i realized that I have two forum users, oops)

(Karl-Johan Karlberg) #4

I can fix the documentation so it uses

eclipse {
  classpath {
    plusConfigurations << configurations.dbDriver

Over what is currently there:

 classpath {
   //you can tweak the classpath of the Eclipse project by adding extra configurations:
   plusConfigurations += [ configurations.provided ]
   //you can also remove configurations from the classpath:
   minusConfigurations += [ configurations.someBoringConfig ]
 .... }

I guess this is thanks to the documentation in:

(Stefan Oehme) #5

I don’t get any warning with this build script and Gradle 2.13

apply plugin: 'java'
apply plugin: 'eclipse'

configurations {

eclipse.classpath.plusConfigurations += []

Your problem must be caused by something else.

(Karl-Johan Karlberg) #6

Yes it was. A runtime classpath.

something like:

run.classpath += [configurations.dbDriver ]

Was fixed by something like:

run.classpath << [configurations.dbDriver.asPath]

Can’t remember if the [] was needed or not :wink:

(Stefan Oehme) #7

Please don’t call asPath there, this will resolve dependencies at configuration time.

It should just be

run.classpath += configurations.dbDriver

There’s a difference between run.classpath and eclipse.classpath.plusConfigurations: The former is a single FileCollection, the latter is a List<Configuration>.