It didn't work around Hadoop when I was moving my old project to Gradle, so a note on how to solve it
dependencies{
compile group: 'org.apache.hadoop', name: 'hadoop-core', version: '0.20.2-cdh3u6'
}
jar {
manifest {
attributes(
'Main-Class': 'path.to.Main',
'Class-Path' : '.'
)
}
exclude 'META-INF/*.RSA', 'META-INF/*.SF','META-INF/*.DSA'
from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
}
As gradle jar
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':jar'.
> Could not expand ZIP '...\.gradle\caches\modules-2\files-2.1\com.cloudera.cdh\hadoop-ant\0.20.2-cdh3u6\...\hadoop-ant-0.20.2-cdh3u6.pom'.
I got an error saying that I couldn't make a jar.
dependencies{
compile (group: 'org.apache.hadoop', name: 'hadoop-core', version: '0.20.2-cdh3u6'){
exclude group: 'com.cloudera.cdh', module: 'hadoop-ant'
}
compile group: 'com.cloudera.cdh', name: 'hadoop-ant', version: '0.20.2-cdh3u6'
}
Then I was able to build.
If you look at hadoop-core-0.20.2-cdh3u6.pom
<dependency>
<groupId>com.cloudera.cdh</groupId>
<artifactId>hadoop-ant</artifactId>
<type>pom</type>
</dependency>
And pom is specified in the type element. Looking at the behavior, Gradle seems to unzip even if the type element is pom, so it seems that an error will occur there. Therefore, it became possible to build properly by excluding hadoop-ant from hadoop-core so that the dependency could not be resolved and going to get hadoop-ant separately. It seems.
The problem has been solved for the time being, but if anyone knows the exact cause or better solution, please let me know. M (_ _) m
Gradle confirmed in the following operating environment
------------------------------------------------------------
Gradle 2.14.1
------------------------------------------------------------
Build time: 2016-07-18 06:38:37 UTC
Revision: d9e2113d9fb05a5caabba61798bdb8dfdca83719
Groovy: 2.4.4
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_77 (Oracle Corporation 25.77-b03)
OS: Windows 7 6.1 amd64
------------------------------------------------------------
Gradle 2.0
------------------------------------------------------------
Build time: 2014-07-01 07:45:34 UTC
Build number: none
Revision: b6ead6fa452dfdadec484059191eb641d817226c
Groovy: 2.3.3
Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013
JVM: 1.8.0_77 (Oracle Corporation 25.77-b03)
OS: Windows 7 6.1 amd64