如何保留类文件“package-info.class”由 JAXB 在 proguard 混淆步骤期间生成

发布于 2024-11-05 11:02:13 字数 929 浏览 0 评论 0原文

我有一个问题,我有一些 JAXB 生成的 java 文件,其中有众所周知的“package-info.java”,它只包含 2 行代码、一个注释和一个包定义:

@javax.xml.bind.annotation.XmlSchema(namespace = "http://it.tms.project/input")
package it.tms.project.jaxb.input;

现在,编译时此文件会生成正常的.class 文件,但是当我尝试混淆它时,proguard 不会将其添加到混淆的 output.jar 中,我想这是因为它不包含任何 Class 或其他内容,并且没有其他 java 文件引用它。 我尝试了一些混淆器选项来解决这个问题,但没有一个是好的:

-keepparameternames
-keepattributes Exceptions,InnerClasses,Signature,SourceFile,EnclosingMethod
-keeppackagenames it.tms.project.jaxb.input
-dontshrink
-dontoptimize

-keepattributes *Annotation* (I thought this one would work but I was wrong)

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

现在我只需要一些选项来明确告诉混淆器不要混淆我想要的文件,而只需将其添加到output.jar中是,我该怎么做? 请记住,“keep class * {}”等选项不起作用,因为该文件不包含任何类。 感谢大家的回答,请填写您的消息FORZA NAPOLI!

I have a problem, I have some JAXB generated java files between which there is the well known "package-info.java" which just contains 2 lines of code, an annotation and a package definition:

@javax.xml.bind.annotation.XmlSchema(namespace = "http://it.tms.project/input")
package it.tms.project.jaxb.input;

now, when compiled this file produces a normal .class file but when I try to obfuscate it proguard doesn't add it to the obfuscated output.jar, I suppose that's because it doesn't contain any Class or something and no other java file refers to it.
I've tried some proguard options to get rid of the problem but no one of this was good:

-keepparameternames
-keepattributes Exceptions,InnerClasses,Signature,SourceFile,EnclosingMethod
-keeppackagenames it.tms.project.jaxb.input
-dontshrink
-dontoptimize

-keepattributes *Annotation* (I thought this one would work but I was wrong)

-keepclassmembernames class * {
    java.lang.Class class$(java.lang.String);
    java.lang.Class class$(java.lang.String, boolean);
}

Now I just need some option to explicitly tell proguard to don't obfuscate the file I desire but just add it to the output.jar as is, how can I do that?
Keep in mind that options like "keep class * {}" don't work because the file doesn't contain any class.
Thank you to anyone for your answers and please complete your messages writing FORZA NAPOLI!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

耶耶耶 2024-11-12 11:02:13

就 ProGuard 而言,编译后的类与其他类一样。默认情况下,ProGuard 会丢弃它,因为它没有被使用(除非通过内省)。您可以保留它:

-keep class it.tms.project.jaxb.input.package-info

正如您所注意到的,您可能也想保留此类上的注释:

-keepattributes *Annotation*

As far as ProGuard is concerned, the compiled class is a class like any other. By default, ProGuard discards it however, since it is not used (except by introspection). You can keep it with:

-keep class it.tms.project.jaxb.input.package-info

As you've noticed, you probably want to keep the annotation on this class too:

-keepattributes *Annotation*
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文