SDK:
- improve obfuscation option - make obfuscation option obfuscate whole application incl libraries - add way to add options to obfuscation git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9920 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
This commit is contained in:
parent
706e286aa4
commit
2f73363107
@ -6,3 +6,4 @@ OpenIDE-Module-Short-Description=Support for obfuscating distributions
|
||||
ObfuscateCustomizerPanel.jCheckBox1.text=Obfuscate Build
|
||||
ProGuard=ProGuard
|
||||
LBL_Category_Obfuscate=Obfuscation
|
||||
ObfuscateCustomizerPanel.jLabel1.text=Obfuscation option additions:
|
||||
|
@ -28,8 +28,17 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
||||
private static final String CAT_OBFUSCATION = "Obfuscation"; // NOI18N
|
||||
private static ProjectExtensionProperties jwsProps = null;
|
||||
private String[] keyList = new String[]{
|
||||
"obfuscate"
|
||||
"obfuscate",
|
||||
"obfuscate.options"
|
||||
};
|
||||
private static String defaultOpts = "-keep public class * extends com.jme3.app.Application{public *;}\n"
|
||||
+ "-keep public class * extends com.jme3.system.JmeSystemDelegate{public *;}\n"
|
||||
+ "-keep public class * implements com.jme3.renderer.Renderer{public *;}\n"
|
||||
+ "-keep public class * implements com.jme3.asset.AssetLoader{public *;}\n"
|
||||
+ "-keep public class * implements com.jme3.asset.AssetLocator{public *;}\n"
|
||||
+ "-keep public class * implements de.lessvoid.nifty.screen.ScreenController{public *;}\n"
|
||||
+ "-dontwarn\n"
|
||||
+ "-dontnote\n";
|
||||
|
||||
public ObfuscateCompositeProvider() {
|
||||
}
|
||||
@ -43,6 +52,9 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
||||
@Override
|
||||
public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
|
||||
jwsProps = new ProjectExtensionProperties(context.lookup(Project.class), keyList);
|
||||
if(jwsProps.getProperty("obfuscate.options")==null){
|
||||
jwsProps.setProperty("obfuscate.options", defaultOpts);
|
||||
}
|
||||
ObfuscateCustomizerPanel panel = new ObfuscateCustomizerPanel(jwsProps);
|
||||
category.setStoreListener(new SavePropsListener(jwsProps, context.lookup(Project.class)));
|
||||
category.setOkButtonListener(panel);
|
||||
@ -52,7 +64,7 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
||||
private class SavePropsListener implements ActionListener {
|
||||
|
||||
private String extensionName = "obfuscate";
|
||||
private String extensionVersion = "v0.9";
|
||||
private String extensionVersion = "v0.10";
|
||||
private String[] extensionDependencies = new String[]{"-post-jar", "-obfuscate"};
|
||||
private ProjectExtensionManager manager = new ProjectExtensionManager(extensionName, extensionVersion, extensionDependencies);
|
||||
private ProjectExtensionProperties properties;
|
||||
@ -77,31 +89,5 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
||||
Exceptions.printStackTrace(ioe);
|
||||
}
|
||||
}
|
||||
|
||||
// private void unZipFile(InputStream source, FileObject projectRoot) throws IOException {
|
||||
// try {
|
||||
// ZipInputStream str = new ZipInputStream(source);
|
||||
// ZipEntry entry;
|
||||
// while ((entry = str.getNextEntry()) != null) {
|
||||
// if (entry.isDirectory()) {
|
||||
// FileUtil.createFolder(projectRoot, entry.getName());
|
||||
// } else {
|
||||
// FileObject fo = FileUtil.createData(projectRoot, entry.getName());
|
||||
// writeFile(str, fo);
|
||||
// }
|
||||
// }
|
||||
// } finally {
|
||||
// source.close();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void writeFile(ZipInputStream str, FileObject fo) throws IOException {
|
||||
// OutputStream out = fo.getOutputStream();
|
||||
// try {
|
||||
// FileUtil.copy(str, out);
|
||||
// } finally {
|
||||
// out.close();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?xml version="1.1" encoding="UTF-8" ?>
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
|
||||
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||
<AuxValues>
|
||||
@ -16,9 +16,16 @@
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="102" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jCheckBox1" pref="328" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="jScrollPane1" alignment="1" pref="366" max="32767" attributes="0"/>
|
||||
<Component id="jCheckBox1" alignment="1" max="32767" attributes="0"/>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
@ -28,7 +35,11 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jCheckBox1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="241" max="32767" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="jScrollPane1" pref="201" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@ -41,5 +52,27 @@
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
|
||||
<AuxValues>
|
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/>
|
||||
</AuxValues>
|
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JTextArea" name="jTextArea1">
|
||||
<Properties>
|
||||
<Property name="columns" type="int" value="20"/>
|
||||
<Property name="rows" type="int" value="5"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JLabel" name="jLabel1">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
|
||||
<ResourceString bundle="com/jme3/gde/obfuscate/Bundle.properties" key="ObfuscateCustomizerPanel.jLabel1.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
|
||||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
@ -23,7 +23,9 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
||||
|
||||
private ProjectExtensionProperties properties;
|
||||
|
||||
/** Creates new form LwjglAppletCustomizerPanel */
|
||||
/**
|
||||
* Creates new form LwjglAppletCustomizerPanel
|
||||
*/
|
||||
public ObfuscateCustomizerPanel(ProjectExtensionProperties properties) {
|
||||
this.properties = properties;
|
||||
initComponents();
|
||||
@ -38,6 +40,8 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
||||
} else {
|
||||
jCheckBox1.setSelected(false);
|
||||
}
|
||||
String props = properties.getProperty("obfuscate.options");
|
||||
jTextArea1.setText(props);
|
||||
}
|
||||
|
||||
private void saveProperties() {
|
||||
@ -46,32 +50,47 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
||||
} else {
|
||||
properties.setProperty("obfuscate", "");
|
||||
}
|
||||
properties.setProperty("obfuscate.options", jTextArea1.getText());
|
||||
}
|
||||
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
saveProperties();
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
* always regenerated by the Form Editor.
|
||||
/**
|
||||
* This method is called from within the constructor to initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is always
|
||||
* regenerated by the Form Editor.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() {
|
||||
|
||||
jCheckBox1 = new javax.swing.JCheckBox();
|
||||
jScrollPane1 = new javax.swing.JScrollPane();
|
||||
jTextArea1 = new javax.swing.JTextArea();
|
||||
jLabel1 = new javax.swing.JLabel();
|
||||
|
||||
jCheckBox1.setText(org.openide.util.NbBundle.getMessage(ObfuscateCustomizerPanel.class, "ObfuscateCustomizerPanel.jCheckBox1.text")); // NOI18N
|
||||
|
||||
jTextArea1.setColumns(20);
|
||||
jTextArea1.setRows(5);
|
||||
jScrollPane1.setViewportView(jTextArea1);
|
||||
|
||||
jLabel1.setText(org.openide.util.NbBundle.getMessage(ObfuscateCustomizerPanel.class, "ObfuscateCustomizerPanel.jLabel1.text")); // NOI18N
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jCheckBox1, javax.swing.GroupLayout.DEFAULT_SIZE, 328, Short.MAX_VALUE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 366, Short.MAX_VALUE)
|
||||
.addComponent(jCheckBox1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(jLabel1)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))
|
||||
.addContainerGap())
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
@ -79,10 +98,17 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(jCheckBox1)
|
||||
.addContainerGap(241, Short.MAX_VALUE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jLabel1)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 201, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JCheckBox jCheckBox1;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JScrollPane jScrollPane1;
|
||||
private javax.swing.JTextArea jTextArea1;
|
||||
// End of variables declaration//GEN-END:variables
|
||||
}
|
||||
|
@ -2,17 +2,20 @@
|
||||
<taskdef resource="proguard/ant/task.properties"
|
||||
classpath="${libs.pro-guard.classpath}" />
|
||||
<proguard>
|
||||
-libraryjars ${proguard.library.path}
|
||||
-injars ${dist.jar}
|
||||
-outjars ${dist.jar}.obfuscated.jar
|
||||
-keepclasseswithmembers public class * {
|
||||
public static void main(java.lang.String[]);
|
||||
}
|
||||
-keep public class * implements de.lessvoid.nifty.screen.ScreenController
|
||||
-keep public class * extends com.jme3.app.Application
|
||||
-libraryjars ${proguard.library.path}
|
||||
-injars ${dist.dir}/lib(!META-INF/MANIFEST.MF)
|
||||
-injars ${dist.jar}
|
||||
-outjars ${dist.jar}.obfuscated.jar
|
||||
-keepclasseswithmembers public class * {
|
||||
public static void main(java.lang.String[]);
|
||||
}
|
||||
${obfuscate.options}
|
||||
</proguard>
|
||||
<delete file="${dist.jar}"/>
|
||||
<move file="${dist.jar}.obfuscated.jar" tofile="${dist.jar}"/>
|
||||
<delete>
|
||||
<fileset dir="${dist.dir}/lib" includes="**/*.jar"/>
|
||||
</delete>
|
||||
</target>
|
||||
|
||||
<target name="-test-obfuscate-enabled">
|
||||
@ -22,15 +25,16 @@
|
||||
</target>
|
||||
|
||||
<target name="-create-library-property" depends="-create-mac-library-property">
|
||||
<property name="proguard.library.path" value="${java.home}/lib/rt.jar${path.separator}${run.classpath}"/>
|
||||
<property name="proguard.library.path" value="${java.home}/lib/rt.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="-create-mac-library-property" depends="-test-mac" if="is.macos">
|
||||
<property name="proguard.library.path" value="/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar:${run.classpath}"/>
|
||||
<property name="proguard.library.path" value="/System/Library/Frameworks/JavaVM.framework/Classes/classes.jar"/>
|
||||
</target>
|
||||
|
||||
<target name="-test-mac">
|
||||
<condition property="is.macos">
|
||||
<os family="mac"/>
|
||||
</condition>
|
||||
</target>
|
||||
</target>
|
||||
|
Loading…
x
Reference in New Issue
Block a user