Версия для печати темы
Нажмите сюда для просмотра этой темы в оригинальном формате
Форум программистов > Java tools & IDE's > Proguard


Автор: tipoc 14.3.2008, 01:51
Подскажите как сделать обфускацию resource файлов в proguard. 
У меня есть jar-файл (моя программа), который я обфусцирую, и папка conf (в которой находятся txt-файлы, из которой программа считывает свои настройки). Jar файл proguard обфусцирует, а вот txt-файлы почему то нет (в txt-файлах имена настроек имеют вид: ru.mypackage.MyClass.title=MyProgram, т.е. по полному имени класса).
Т.к. jar-файл у меня обфусцирован, а настройки с обфусцированным именем нет. То программа не может считать настройки из этих файлов.

Пытаюсь делать что-то подобное (proguard запускаю через ant):
<proguard printmapping="proguard.map">
            <adaptresourcefilecontents filter="conf(*.txt)"/>
            <injar dir="my.jar"/>
            <injar dir="conf"/>
            <outjar dir="outjars"/>
            <libraryjar file="${java.home}/lib/rt.jar"/>
            .... (здесь еще настройки для proguard)
        </proguard>

Автор: LSD 14.3.2008, 16:03
А как она должна догадаться, что у тебя ключи завязаны на имена классов? Обычно они все таки никак не связанны с именами классов, а просто описывают значение типа:
Цитата
mainframe.title=My program

Автор: tipoc 14.3.2008, 18:54
Как proguard об этом догадается - это уже алгоритмы его внутренней работы. Вопрос не в этом. 

Вот что написано в мане proguard (взял отсюда http://proguard.sourceforge.net/manual/examples.html#resourcefiles ):

Цитата

Processing resource files
If your application, applet, servlet, library, etc., contains resource files, it may be necessary to adapt their names and/or their contents when the application is obfuscated. The following two options can achieve this automatically:

-adaptresourcefilenames    **.properties,**.gif,**.jpg
-adaptresourcefilecontents **.properties,META-INF/MANIFEST.MF

The -adaptresourcefilenames option in this case renames properties files and image files in the processed output, based on the obfuscated names of their corresponding class files (if any). The -adaptresourcefilecontents option looks for class names in properties files and in the manifest file, and replaces these names by the obfuscated names (if any). You'll probably want to adapt the filters to suit your application. Note that package names of resource files that don't have corresponding class files are not updated in the current implementation.   


Т.е. делать он это умеет. Только нужно ему видимо опции правильно задать. Вот я и хочу узнать что я делаю не так. smile

В моем случае настройки я задаю по полному имени класса (т.е. типа ru.mycompany.mypackage.MyClass.settingName=someValue)

Powered by Invision Power Board (http://www.invisionboard.com)
© Invision Power Services (http://www.invisionpower.com)