GradleException Could not create ZIP

陌路散爱 提交于 2020-12-12 13:22:38

问题


Caused by: org.gradle.api.GradleException: Could not create ZIP '/jenkins/repository/workspace/profile/build/libs/../profile.jar'.

Project
    common  << I build under this directory
    profile

build.gradle(in common)
    ...
    dependencies {
    compile project(':../profile')
    ...

settings.gradle(in common)
    include '../profile'

It works on windows environment. But it does not work on linux environment even using root account


回答1:


The project paths accepted by the include and project methods are logical paths, not physical paths. They cannot contain a ... Physical paths must be declared separately in settings.gradle (if they divert from the logical path). The easiest way to declare a flat physical directory layout is to use the includeFlat method:

common/settings.gradle

includeFlat 'profile'

common/build.gradle

dependencies {
    compile project(':profile')
}

You can find more information on this topic in the "multi-project builds" chapter of the Gradle User Guide.




回答2:


Another common issue that can happen here especially if you're using windows is you could have opened the previous jar up in 7zip or some other tool and that's causing the file to be locked. To test this try to delete the jar that's sitting in build/libs if you can't delete the file it's locked by another program more than likely. :D




回答3:


An even shorter way to fix this: Add the following line to the build.gradle file of the included profile project:

archivesBaseName = 'profile'

This overwrites the default name of the jar.



来源:https://stackoverflow.com/questions/16786818/gradleexception-could-not-create-zip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!