[JAVA] What to do if zip dies if there is a pom when making an executable jar with gradle

Specifically, what happened when using Google's API library. How to find out if you search often

from configurations.compile.collect {it.isDirectory() ? it : zipTree(it)}

It's a method, but if pom is included, it will die.

15:44:57: Executing task 'jar'...

> Task :compileJava UP-TO-DATE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :jar FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':jar'.
> Could not expand ZIP '/xxxxx/.gradle/caches/modules-2/files-2.1/com.sun.xml.bind/jaxb-ri/2.3.2/f37875be0bc7d265b5bbb08eb55b2345c27e67aa/jaxb-ri-2.3.2.pom'.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 22s
3 actionable tasks: 1 executed, 2 up-to-date
Cause: archive is not a ZIP archive
15:45:21: Task execution finished 'jar'.

As for the message I'm writing, that's right.

So, if it's pom, it's a solution that you don't have to feed it to zip.

jar {
    manifest {
        attributes 'Main-Class': 'HOGEHOGE'
    }
    from {
        configurations
                .compile
                .findAll { !it.name.endsWith('pom') }
                .collect { it.isDirectory() ? it : zipTree(it) }
    }
}

Surprisingly there was no article, so I hope it helps someone.

[Reference site] https://stackoverflow.com/questions/52816630/unable-to-create-a-jar-of-my-jda-project-because-of-pom-dependency https://qiita.com/informationsea/items/cd1d8d130a5c7b0bc31a

Recommended Posts

What to do if zip dies if there is a pom when making an executable jar with gradle
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 when is invalid because it does not start with a'-'
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 Command line is too long appears when building a gradle project in Intellij IDEA
After installing'devise''bootstrap' of gemfile with rails, what to do when url is an error
What to do if you are told "there is no main manifest attribute" when creating a jar file containing dependencies in a maven project
What to do when you launch an application with rails
What to do if you get an error saying "Please enter a valid value" when getting with Rails datetime_field
[Rails] What to do when the view collapses when a message is displayed with the errors method
[JMH] What to do if the JMH Gradle Plugin says FAILURE: Build failed with an exception. A failure occurred while executing me.champeau.gradle.IsolatedRunner [Gradle]
What to do if the Eclipse Maven dependency Jar is wrong
What to do if the app is not created with the latest Rails version installed when rails new
[IOS] What to do when the image is filled with one color
What to do if an error occurs when nokogiri enters when bundle install
How to create a server executable JAR and WAR with Spring gradle
Notes on what to do when EC2 is set up with t2.micro
What to do if tomcat process remains when tomcat is stopped in eclipse
What to do if you get an error when you hit Heroku logs
What to do if you get Application with name appName is already registered. When you try to start GlassFish
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 when you want to delete a migration file that is "NO FILE"
What to do if the server tomcat dies
What to do if ffi installation fails when launching an application in Rails
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 NoClassDefFoundError when trying to run eclipse on Java9
What to do if you get a port error when docker-compose up on Mac
What to do if you accidentally create a model
What to do when a null byte error occurs
What to do if an ActionController :: UnknownFormat error occurs
ParseException: What to do when Unparseable date is reached
[Maven] What to do if you are asked to incorporate a jar that is not in the remote repository into the war
<Dot installation> What to do if you cannot proceed due to an error when building a development environment for Rails learning.
What to do if you get a "Cannot Pull Container Error" when starting ECS ​​Fargate
What to do if a SAX Parser error occurs when using Liferay 7 / DXP on AWS
[Rails] What to do if you can't get an error message with the errors method
What to do if audio is not available on discordrb
What to do if FacesMessage is set but not displayed
What happens to instance variables when copying an instance with ruby
Generate a single executable jar with dependent libraries in Gradle 4.9
What to do if mysql2 gets a bundle install error
What to do when Gradle says "For more information, please recompile with the -Xlint: unchecked option"
What to do if an SSH key authentication error occurs during automatic deployment to EC2 with Capistrano
What to do if you get a JNI shared library error when trying to build in Eclipse
[Java] What to do if a lot of "File is opened too much" is displayed due to FileNotFoundException
What to do about the "cannot be read or is not a valid ZIP file" error
What to do if an error occurs when doing npm install axios in React + Typescript project
What to do when javax.el.ELException: Not a Valid Method Expression: appears when the JSF screen is displayed
What to do if an error occurs in VS Code when importing a django module or your own module installed by pip install
[Ubuntu 20.04] What to do if the external monitor is not recognized
What to do if validation doesn't work with the update action
[Rails] What to do if data is not registered in DB
How to output the value when there is an array in the array
What to do if Cloud9 is full in the Rails tutorial
What to do if you get a DISPLAY error in gym.render ()
What to do if you get angry with OpenSSL with pyenv install
What to do when you become a Problem During Content Assist
What to do when you run into a docker-compose node_modules problem
[Rails] What to do if you can't get parameters with form_with
Resultset's next () is not a "method to determine if there is a ResultSet next".