What appears to be happening is that ‘compileJava’ pulls in ‘commons-io-1.4.jar’ from the gradle distribution, in preference to my declared ‘commons-io:commons-io:2.4’. When I try to call a method (‘readLines(InputStream, Charset)’) introduced in a later version, Gradle can’t find it:
$ gradle compileJava
:compileJava
/home/dmoles/Projects/m12n-plugins/tools/m12n/multiproject-plugin/src/main/java/m12n/tools/multiproject/dependencies/DependencyExtractor.java:42: error: no suitable method found for readLines(ByteArrayInputStream,Charset)
List lines = IOUtils.readLines(new ByteArrayInputStream(stream.toByteArray()), Charsets.UTF_8);
^
method IOUtils.readLines(Reader) is not applicable
(actual and formal argument lists differ in length)
method IOUtils.readLines(InputStream,String) is not applicable
(actual argument Charset cannot be converted to String by method invocation conversion)
method IOUtils.readLines(InputStream) is not applicable
(actual and formal argument lists differ in length)
1 error
:compileJava FAILED
FAILURE: Build failed with an exception.
The ‘dependencies’ section of my ‘build.gradle’ (abbreviated):
dependencies {
compile ‘commons-io:commons-io:2.4’
compile gradleApi()
compile localGroovy()
}
‘gradle dependencies’ shows the right thing:
±-- commons-io:commons-io:2.4
Obviously in this specific case I can work around it by calling the older method, but is there a general fix for this? I don’t want to have to individually track down every time I happen to use a library that’s also used by Gradle itself.