We are doing hadoop2 migration. There is a problem with the test case. In the test, we are starting a MiniMRCluster and a MiniDFSCluster to serve as a local hadoop cluster, and MiniMRCluster is relying on avro 1.7.4 as specified in hadoop2 libraries. However, our product is still using avro 1.4.0 and there is no way to upgrade avro version in the near future. So now I have to compile with avro 1.4.0, and in testRuntime use avro 1.7.4 to start MiniMRCluster. The job can be avro 1.4.0. I just merely need to use avro 1.7.4 to start MiniMRCluster, then no longer needed anymore.
So the question is, how can I let gradle compile with avro 1.4.0 and in testRuntime use avro 1.7.4?
I tried to use the following in build.gradle
robo group: ‘org.apache.avro’, name: ‘avro’, version: ‘1.7.4’
sourceSets.test.runtimeClasspath = configurations.robo + sourceSets.test.runtimeClasspath
However, ‘gradle dependencies’ shows
| ±-- org.apache.avro:avro:1.7.4 -> 1.4.0 (*)
Apparently, 1.7.4 is not identified at all. Please, any suggestions to solve it? I’m using gradle 2.2.1
Thank you very much.
Just define different versions for the
Results in compile looking like this:
And testRuntime is properly using 1.7.4:
org.apache.avro:avro:1.7.4 (conflict resolution)
org.apache.avro:avro:1.4.0 -> 1.7.4
I tried these, and the result is still the same. Does it because we are having a large and complex build system? The component is depending on other components and ‘gradle dependencies’ still shows
| +--- org.apache.avro:avro:1.7.4 -> 1.4.0 (*)
testRuntime - Runtime classpath for source set 'test'.
|+--- org.apache.avro:avro:1.4.0 (*)
The other components also included avro 1.4.0. Any other ideas? Can you share your gradle version and complete build.gradle file?
Thank you very much for your help!
gradle dependencyInsight --dependency avro to find out why 1.4.0 is being chosen. It’s possible that dependency is being forced somewhere.
It turns out it’s the policy from company tools that disallows multiple version in gradle. So it is not a gradle problem.
Thank you very much for your help