Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

插件依赖有重复module-info.class会导致插件打包失败 #704

Closed
weixiaokang opened this issue Dec 7, 2021 · 1 comment · Fixed by #705
Closed

插件依赖有重复module-info.class会导致插件打包失败 #704

weixiaokang opened this issue Dec 7, 2021 · 1 comment · Fixed by #705

Comments

@weixiaokang
Copy link

weixiaokang commented Dec 7, 2021

问题现象
最近把插件app依赖的Gson组件由2.8.5版本升级到2.8.6之后,插件打包会报异常

java.util.zip.ZipException: duplicate entry: module-info.class

原因分析
在transform中打印日志,发现是jackson core 2.12.3和gson 2.8.6中都带有module-info.class,这个文件不带包路径的。
在transform阶段,调用ZipOutputStream的putNextEntry有重复的entry就会抛异常

目前我们是通过修改AbstractTransform.kt排除module-info.class解决的

    private fun CtClass.debugWriteJar(outputEntryName: String?, outputStream: ZipOutputStream) {
        // 忽略META-INF
        if (outputEntryName?.startsWith("META-INF/") == true || outputEntryName?.equals("module-info.class") == true) {
            return
        }
        ......
    }

除了jackson core和gson,其他开源组件也可能会有module-info.class,这个问题是不是统一处理下免得其他人也遇到这个问题

shifujun added a commit to shifujun/Shadow that referenced this issue Dec 7, 2021
有些第三方库的module-info.class没有放到`META-INF/`目录下。

fix Tencent#704
shifujun added a commit to shifujun/Shadow that referenced this issue Dec 7, 2021
有些第三方库的module-info.class没有放到`META-INF/`目录下。

fix Tencent#704
@shifujun
Copy link
Collaborator

shifujun commented Dec 7, 2021

感谢反馈。欢迎下次直接提个PR过来😃

shifujun added a commit to shifujun/Shadow that referenced this issue Dec 7, 2021
有些第三方库的module-info.class没有放到`META-INF/`目录下。

fix Tencent#704
shifujun added a commit that referenced this issue Dec 8, 2021
有些第三方库的module-info.class没有放到`META-INF/`目录下。

fix #704
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants