【问题标题】:yguard not updating properties file in the jaryguard 不更新 jar 中的属性文件
【发布时间】:2014-01-23 18:39:44
【问题描述】:

我有 jar 文件,其中包含一些属性文件,例如 log4j.properties 和 config.properties。以下是我为 yguard 编写的 ant 脚本。除了属性文件更新之外,其他一切都在工作。

<target name="yguard">
    <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="lib/yguard.jar" />
    <yguard>
        <inoutpairs resources="none">
            <fileset dir="${basedir}">
                <include name="MyApp.jar" />
            </fileset>
            <mapper type="glob" from="MyApp.jar" to="MyAppObs.jar" />
        </inoutpairs>
        <externalclasses>
            <pathelement location="lib/log4j-1.2.17.jar" />
        </externalclasses>
        <rename conservemanifest="true" mainclass="com.amit.Application" >
            <adjust replaceContent="true" >
                <include name="**/*.properties" />
            </adjust>
        </rename>
    </yguard>
</target>

config.properties 文件

com.amit.Application.param1 = something

我在 stackoverflow 中发现了一些问题,但它们没有帮助。有人提到文件(如jsp、xml、属性)应该在我已经拥有的jar文件中。但是我的 yguard 混淆文件只是按原样复制文件。

我尝试了许多重命名和调整标签的组合,但对我没有任何效果。

以下我已经访问过的帖子

Is it possible to manage logs through Obfuscation with yGuard?

How to include obfuscated jar file into a war file

【问题讨论】:

    标签: ant yguard


    【解决方案1】:

    显然您希望 yGuard 混淆字段名称 param1,因为 com.amit.Application 显然是您的入口点,并且 yGuard 会自动排除给定的主类。所以基本上你希望结果是这样的

    com.amit.Application.AÖÜF = something
    

    这是不可能的,因为 yGuard 只能调整属性文件中的类名,如下所述:yGuard Manual

    【讨论】:

    • 感谢 Sabastian 的 cmets,但我希望 yguard 替换类名而不是参数名。我提到的类名只是一个示例,不幸的是我选择了类似于入门类的东西,但它只是主类以外的一些类。
    • 然后这样写:com.amit.Application#param1 = something
    • 我不确定这会有什么帮助。即使我只是将类名放在该文件中,它也不会被混淆名称替换。还有其他建议吗?
    • 不,因为它对我有用。我在我的项目中放置了一个属性文件,一个被混淆的类,然后将 com.MyClass#value = "hi" 之类的内容写入属性文件,像你一样调整构建过程并且它可以工作。
    • 好的,我试试看它是否有效。谢谢!
    猜你喜欢
    • 2017-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-07-24
    • 1970-01-01
    • 2017-05-10
    • 2014-10-02
    相关资源
    最近更新 更多