0

I have an eclipse based application which uses YFiles library. I want to obfuscate YFiles & adjust obfuscated classes of YFiles libraries in my code.

I am executing this obfuscation via a Maven build triggering an ant script. My ant-script has the logic of obfuscation. This looks like--

<project name="obfuscate">
<target name="obf-modeler">
    <taskdef name="yguard" classname="com.yworks.yguard.YGuardTask" classpath="./lib/yguard.jar" />
    <yguard>
        <inoutpair in="yfiles.jar" out="obfyfiles.jar" />
        <inoutpair in="<my-app-jar>" out="<my-app-jar>" />
        <rename replaceClassNameStrings="true">
            <keep>
                <class classes="private" methods="private" fields="private">
                    <patternset>
                        <include name="com.<my-company-name>." />
                    </patternset>
                </class>
                <package>
                    <patternset>
                        <include name="com.<my-company-name>." />
                    </patternset>
                 </package>
            </keep>
            <adjust replaceContent="true">
                <include name="plugin.xml" />
            </adjust>
        </rename>
    </yguard>
</target>

I am obfuscating Yfiles & my code together so that YFiles obfuscation is incorporated in my code as well. I also have a patternset on class & package elements to tell YGaurd that "don't obfuscate my code, only adjust the YFiles obfuscation changes"

Unfortunately, if I run the maven build, Some public YFiles methods with some return type are not getting obfuscated. For example -- y.base.NodeMap class has methods obfuscated which don't have a return type, other methods who return something are still having old method names.

Any clue what is going wrong in my patter-set. Also, if I remove this pattern-set, there is no issue in YFiles obfuscation. However, my code is getting obfuscated too in that case which I don't want.

Thanks & regards Abhinaw

zhujik
  • 6,514
  • 2
  • 36
  • 43
abhinaw
  • 1
  • 2

1 Answers1

0

It seems that you are subclassing / implementing interfaces or classes of the yFiles library. Note that if you are subclassing a class and tell yGuard to not obfuscate the subclass, the entiry class hierarchy is kept as well (this is necessary for the classloader). Just exclude your classes that extend/implement yFiles API classes in your keep rule. A pitfall here are anonymous classes. To avoid this, transform your anonymous classes to outer or inner classes and exclude these classes explicitly in your keep rule.

zhujik
  • 6,514
  • 2
  • 36
  • 43