SourceSet.getClasses() method has been deprecated


(rtayek) #1

The SourceSet.getClasses() method has been deprecated and will be removed in the

next version of Gradle. Please use the getOutput() method instead. :compileJava UP-TO-DATE

i get the above with my simple script (please see code below).

how can i fix this?

thanks

apply plugin: ‘java’ repositories { mavenCentral() } sourceSets.main.java.srcDirs = [“src”] sourceSets.test.java.srcDirs = [“tst”] sourceSets.main.resources.srcDirs = [“src”]

dependencies {

compile fileTree(dir: ‘lib’, includes: [’*.jar’])

testCompile group: ‘junit’,name:‘junit’,version: ‘4.8+’ }

task smallJar(type:Jar) {

archiveName=‘small.jar’

from sourceSets.main.classes

include ‘com/tayek/hmr//*’, 'com/tayek/qanda//*’

}


(René Groeschke) #2

Hello Ray, the reason for that deprecation warning is this line in your Jar task:

from sourceSets.main.classes

To get rid of this message, you have to use the getOutput() method of source set instead:

from sourceSets.main.output

sourceSet.main is of type SourceSet. Have a look at the DSL reference for further information about SourceSet (http://gradle.org/docs/current/dsl/org.gradle.api.tasks.SourceSet.html)


(rtayek) #3

from sourceSets.main.output

works like a charm!

thanks