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
|
ObfuscateCustomizerPanel.jCheckBox1.text=Obfuscate Build
|
||||||
ProGuard=ProGuard
|
ProGuard=ProGuard
|
||||||
LBL_Category_Obfuscate=Obfuscation
|
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 final String CAT_OBFUSCATION = "Obfuscation"; // NOI18N
|
||||||
private static ProjectExtensionProperties jwsProps = null;
|
private static ProjectExtensionProperties jwsProps = null;
|
||||||
private String[] keyList = new String[]{
|
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() {
|
public ObfuscateCompositeProvider() {
|
||||||
}
|
}
|
||||||
@ -43,6 +52,9 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
|||||||
@Override
|
@Override
|
||||||
public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
|
public JComponent createComponent(ProjectCustomizer.Category category, Lookup context) {
|
||||||
jwsProps = new ProjectExtensionProperties(context.lookup(Project.class), keyList);
|
jwsProps = new ProjectExtensionProperties(context.lookup(Project.class), keyList);
|
||||||
|
if(jwsProps.getProperty("obfuscate.options")==null){
|
||||||
|
jwsProps.setProperty("obfuscate.options", defaultOpts);
|
||||||
|
}
|
||||||
ObfuscateCustomizerPanel panel = new ObfuscateCustomizerPanel(jwsProps);
|
ObfuscateCustomizerPanel panel = new ObfuscateCustomizerPanel(jwsProps);
|
||||||
category.setStoreListener(new SavePropsListener(jwsProps, context.lookup(Project.class)));
|
category.setStoreListener(new SavePropsListener(jwsProps, context.lookup(Project.class)));
|
||||||
category.setOkButtonListener(panel);
|
category.setOkButtonListener(panel);
|
||||||
@ -52,7 +64,7 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
|||||||
private class SavePropsListener implements ActionListener {
|
private class SavePropsListener implements ActionListener {
|
||||||
|
|
||||||
private String extensionName = "obfuscate";
|
private String extensionName = "obfuscate";
|
||||||
private String extensionVersion = "v0.9";
|
private String extensionVersion = "v0.10";
|
||||||
private String[] extensionDependencies = new String[]{"-post-jar", "-obfuscate"};
|
private String[] extensionDependencies = new String[]{"-post-jar", "-obfuscate"};
|
||||||
private ProjectExtensionManager manager = new ProjectExtensionManager(extensionName, extensionVersion, extensionDependencies);
|
private ProjectExtensionManager manager = new ProjectExtensionManager(extensionName, extensionVersion, extensionDependencies);
|
||||||
private ProjectExtensionProperties properties;
|
private ProjectExtensionProperties properties;
|
||||||
@ -77,31 +89,5 @@ public class ObfuscateCompositeProvider implements ProjectCustomizer.CompositeCa
|
|||||||
Exceptions.printStackTrace(ioe);
|
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">
|
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
|
||||||
<AuxValues>
|
<AuxValues>
|
||||||
@ -16,9 +16,16 @@
|
|||||||
<Layout>
|
<Layout>
|
||||||
<DimensionLayout dim="0">
|
<DimensionLayout dim="0">
|
||||||
<Group type="103" groupAlignment="0" attributes="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"/>
|
<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"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
</Group>
|
</Group>
|
||||||
</Group>
|
</Group>
|
||||||
@ -28,7 +35,11 @@
|
|||||||
<Group type="102" alignment="0" attributes="0">
|
<Group type="102" alignment="0" attributes="0">
|
||||||
<EmptySpace max="-2" attributes="0"/>
|
<EmptySpace max="-2" attributes="0"/>
|
||||||
<Component id="jCheckBox1" min="-2" 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>
|
||||||
</Group>
|
</Group>
|
||||||
</DimensionLayout>
|
</DimensionLayout>
|
||||||
@ -41,5 +52,27 @@
|
|||||||
</Property>
|
</Property>
|
||||||
</Properties>
|
</Properties>
|
||||||
</Component>
|
</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>
|
</SubComponents>
|
||||||
</Form>
|
</Form>
|
||||||
|
@ -23,7 +23,9 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
|||||||
|
|
||||||
private ProjectExtensionProperties properties;
|
private ProjectExtensionProperties properties;
|
||||||
|
|
||||||
/** Creates new form LwjglAppletCustomizerPanel */
|
/**
|
||||||
|
* Creates new form LwjglAppletCustomizerPanel
|
||||||
|
*/
|
||||||
public ObfuscateCustomizerPanel(ProjectExtensionProperties properties) {
|
public ObfuscateCustomizerPanel(ProjectExtensionProperties properties) {
|
||||||
this.properties = properties;
|
this.properties = properties;
|
||||||
initComponents();
|
initComponents();
|
||||||
@ -38,6 +40,8 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
|||||||
} else {
|
} else {
|
||||||
jCheckBox1.setSelected(false);
|
jCheckBox1.setSelected(false);
|
||||||
}
|
}
|
||||||
|
String props = properties.getProperty("obfuscate.options");
|
||||||
|
jTextArea1.setText(props);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveProperties() {
|
private void saveProperties() {
|
||||||
@ -46,32 +50,47 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
|||||||
} else {
|
} else {
|
||||||
properties.setProperty("obfuscate", "");
|
properties.setProperty("obfuscate", "");
|
||||||
}
|
}
|
||||||
|
properties.setProperty("obfuscate.options", jTextArea1.getText());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void actionPerformed(ActionEvent e) {
|
public void actionPerformed(ActionEvent e) {
|
||||||
saveProperties();
|
saveProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called from within the constructor to
|
/**
|
||||||
* initialize the form.
|
* This method is called from within the constructor to initialize the form.
|
||||||
* WARNING: Do NOT modify this code. The content of this method is
|
* WARNING: Do NOT modify this code. The content of this method is always
|
||||||
* always regenerated by the Form Editor.
|
* regenerated by the Form Editor.
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||||
private void initComponents() {
|
private void initComponents() {
|
||||||
|
|
||||||
jCheckBox1 = new javax.swing.JCheckBox();
|
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
|
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);
|
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||||
this.setLayout(layout);
|
this.setLayout(layout);
|
||||||
layout.setHorizontalGroup(
|
layout.setHorizontalGroup(
|
||||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.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())
|
.addContainerGap())
|
||||||
);
|
);
|
||||||
layout.setVerticalGroup(
|
layout.setVerticalGroup(
|
||||||
@ -79,10 +98,17 @@ public class ObfuscateCustomizerPanel extends javax.swing.JPanel implements Acti
|
|||||||
.addGroup(layout.createSequentialGroup()
|
.addGroup(layout.createSequentialGroup()
|
||||||
.addContainerGap()
|
.addContainerGap()
|
||||||
.addComponent(jCheckBox1)
|
.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
|
}// </editor-fold>//GEN-END:initComponents
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private javax.swing.JCheckBox jCheckBox1;
|
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
|
// End of variables declaration//GEN-END:variables
|
||||||
}
|
}
|
||||||
|
@ -2,17 +2,20 @@
|
|||||||
<taskdef resource="proguard/ant/task.properties"
|
<taskdef resource="proguard/ant/task.properties"
|
||||||
classpath="${libs.pro-guard.classpath}" />
|
classpath="${libs.pro-guard.classpath}" />
|
||||||
<proguard>
|
<proguard>
|
||||||
-libraryjars ${proguard.library.path}
|
-libraryjars ${proguard.library.path}
|
||||||
-injars ${dist.jar}
|
-injars ${dist.dir}/lib(!META-INF/MANIFEST.MF)
|
||||||
-outjars ${dist.jar}.obfuscated.jar
|
-injars ${dist.jar}
|
||||||
-keepclasseswithmembers public class * {
|
-outjars ${dist.jar}.obfuscated.jar
|
||||||
public static void main(java.lang.String[]);
|
-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
|
${obfuscate.options}
|
||||||
</proguard>
|
</proguard>
|
||||||
<delete file="${dist.jar}"/>
|
<delete file="${dist.jar}"/>
|
||||||
<move file="${dist.jar}.obfuscated.jar" tofile="${dist.jar}"/>
|
<move file="${dist.jar}.obfuscated.jar" tofile="${dist.jar}"/>
|
||||||
|
<delete>
|
||||||
|
<fileset dir="${dist.dir}/lib" includes="**/*.jar"/>
|
||||||
|
</delete>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="-test-obfuscate-enabled">
|
<target name="-test-obfuscate-enabled">
|
||||||
@ -22,15 +25,16 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="-create-library-property" depends="-create-mac-library-property">
|
<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>
|
||||||
|
|
||||||
<target name="-create-mac-library-property" depends="-test-mac" if="is.macos">
|
<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>
|
||||||
|
|
||||||
<target name="-test-mac">
|
<target name="-test-mac">
|
||||||
<condition property="is.macos">
|
<condition property="is.macos">
|
||||||
<os family="mac"/>
|
<os family="mac"/>
|
||||||
</condition>
|
</condition>
|
||||||
</target>
|
</target>
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user