How to use proguard on intellij IDEA?

I have not tried this (i like to find the easy way first) but, it should work if you follow the steps. I will try this and report back.

  1. Go to this link and learn how to create an Ant build file for IntelliJ IDEA

  2. Go here to download yGuard

  3. Unpack the yGuard archive and navigate to the doc directory.

  4. There is an html "how to" file. Read up on that, and you should be ready to release minified code.

  5. Optional: search the net for yGuard tips & tricks to get the most out of your builds.

--- WORKING-NOTES ---

[1.0] In IntelliJ 2017, there is an option to generate the Ant Build File on the build menu. Build->Generate Ant Build File The settings that work for me are single-build-file, with everything else checked, using the supplied project name.

[1.1] View->Tool Windows->Ant Build this should get you where you need to be with the knowledge you got from the 5th step of the link at step 1 and step 4 of this answer.

Here is my working yGuard task:

<target depends="artifact.project" name="yguard">
<taskdef name="yguard"
         classname="com.yworks.yguard.YGuardTask"
         classpath="yguard.jar"/>
<yguard>

  <inoutpair in="${temp.jar.path.project.jar}"
             out="${artifact.output.project}/project-release.jar"/>

    <shrink
            logfile="shrinklog.xml">
        <keep>
            <class classes="protected"
                   methods="protected"
                   fields="protected"/>
        </keep>
    </shrink>

</yguard>

Then you modify your "all" to look like this:

  <target name="all" depends="build.modules, build.all.artifacts, yguard"
          description="build all">
      <!-- Delete temporary files -->
      <delete dir="${artifacts.temp.dir}"/>

  </target>

And you have to REMOVE the delete temporary files action from the build.all.artifacts target, so when you get to the all target, the files are still available.

Just like it says in the yGuard html doc at the bottom, IntelliJ will complain about your yGuard syntax, but yGuard will still work.

If anyone can clean this up, feel free. It works for me, your mileage may vary. Also, you WILL be able to create a really tiny ant build xml, and use the Project Structure->Artifacts->Post Processing, after you have added your "tiny" ant build as noted in WORKING-NOTES: [1.1] "5th step". Some hand-hacking will definitely be required for this.


1. add plugin Intellijguar2

enter image description here

2. in Project Structure ->modules->obfuscation press download yguard as it prompts. Set its path. Uncheck pedantic error-checking (optionally) and so these.

3. Build -> Build project -> build artifacts and get ordinary executable jar. (If you cannot see artifacts enabled in Run menu go to file-> project structure ->artfact and create by + new item with dependensy to the main class)

4. build -> obfuscate *** module

enter image description here

5. Add YourProject/out/production/YourProject/firstfolder_of_packagename .

6. Remove Module compile output Assign a path to obfuscated jar below and press 'build'

7. Open obfuscated jar with zip program. Make sure the class files are all obfuscated by JD-GUI app.

8. cut off META-INF folder and add META-INF one from executable inobfuscated jar and also folders like libs or assets manually. In turn you'll get an obfuscated executable jar E.g. for json lib finally I've got the result view in zip editor: enter image description here

Tags:

Java

Proguard