[JAVA] How to make a jar with old Hadoop (hadoop-core-0.20.2-cdh3u6) in Gradle: (What to do if you get Could not expand ZIP ..)

It didn't work around Hadoop when I was moving my old project to Gradle, so a note on how to solve it

Before (failure)

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.

After (solution)

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.

What seems to be the cause

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

Addendum

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

Recommended Posts

How to make a jar with old Hadoop (hadoop-core-0.20.2-cdh3u6) in Gradle: (What to do if you get Could not expand ZIP ..)
What to do if you get a java.io.IOException in GlassFish
What to do if you get Could not save master table to file after importing a project in Eclipse
What to do if you get a gcc error in Docker
What to do if you get a DISPLAY error in gym.render ()
What to do if you get a groovy warning in Thymeleaf Layout
What to do if zip dies if there is a pom when making an executable jar with gradle
What to do if you get Could not locate Gemfile or .bundle / directory
What to do if you get a wrong number of arguments error in binding.pry
What to do if you get an error saying "Could not find a JavaScript runtime." When starting rails server
What to do if you get a "302" error in your controller unit test code in Rails
How to make a jar file with no dependencies in Maven
What to do if you get angry with OpenSSL with pyenv install
[Rails] What to do if you can't get parameters with form_with
[Maven] What to do if you are asked to incorporate a jar that is not in the remote repository into the war
What to do if you select a JRE in Eclipse and get "The selected JRE does not support the current compliance level 11"
What to do if you get a "Mysql2 :: Error: Operand should contain 1 column (s)" error in Rails
What to do if you get a JNI shared library error when trying to build in Eclipse
If you want to make a zip file with Ruby, it's rubyzip.
What to do if you get a MiniMagick vulnerability alert on GitHub
What to do if you get an error with bundle install by entering gem'bcrypt' in your Gemfile
What to do if Operation not permitted is displayed when you execute a command in the terminal
What to do if you get a SQLite3 :: BusyException: database is locked error
What to do if the changes are not reflected in the jar manifest file
What to do if you get a javax.net.ssl.SSLHandshakeException: Remote host closed connection during handshake in the IBM JDK
What to do if you accidentally create a model
What to do if you get a NoClassDefFoundError when trying to run eclipse on Java9
What to do if you get a port error when docker-compose up on Mac
How to deal with errors in Rails s could not find a JavaScript runtime.
[Java] What to do if you get an error in Eclipse saying "Not allowed at source level below 1.X"
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
What to do if you installed Ruby with rbenv but the version does not change
How to read a library from a JAR file with VS Code << How to not use Maven / Gradle >>
What to do when a could not find driver appears when connecting to a DB in a Docker environment
[Rails Tutorial Chapter 2] What to do when you make a mistake in the column name
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
[Rails] What to do if you can't get an error message with the errors method
What to do if you get an error in Basic authentication during Rails test code
What to do if you get an [An HTTP request took too long to complete.] Error in Docker.
What to do if you get "Changes not staged for commit:" when you git status after git add.
[Rails] What to do if data is not registered in DB
What to do if you forget the root password in CentOS7
What to do if you get Application with name appName is already registered. When you try to start GlassFish
What to do if you get the error Too long with no output (exceeded 10m0s) on CircleCI
What to do if you get an error during rails db: reset
What to do if the prefix c is not bound in JSP
What to do if you get an uninitialized constant Likes Controller error
How to create a server executable JAR and WAR with Spring gradle
What to do if you get an error when you hit Heroku logs
What to do if you install Ubuntu
What to do if you get an "A server is already running." Error when you try to start the rails server
What to do if you have enabled Use the WSL2 based engine in Docker Desktop with insufficient WSL2 installation
How to translate the error message into Japanese (What to do if you cannot log in for some reason)
What to do if you get the error message unrecognized selector send to instance "***"
How to make @Transactional work that does not work if you use it incorrectly
How to get the ID of a user authenticated with Firebase in Swift
How to output jar with main class specified by gradle in Intellij IDEA
What to do if you get an error on heroku rake db: migrate
What to do if you get angry if you don't have nokogiri while installing wp2txt
What to do if you get To install the missing version, run `gem install bundler: 2.1.4`
What to do when is invalid because it does not start with a'-'