[RESOLVED] Error when building Add-On Library using ProGuard

Hello,

I’m facing an issue using ProGuard for an Add-On Library project.

I’m getting the following error at the end of the build process of my library:

BUILD FAILED
Found an error when building my-library
* Where

File : C:\Program Files\MicroEJ\MicroEJ-SDK-21.11\rcp\configuration\org.eclipse.osgi\528\data\repositories\microej-build-repository\com\is2t\easyant\plugins\obf-proguard\3.0.0\obf-proguard-3.0.0.ant
Line : 75 column : 151
* Problem Report:
The output jar is empty. Did you specify the proper '-keep' options?
* Recommendation...
Run easyant with -verbose or -debug option to get more details.
Total time: 4 seconds

Some information about my environment:

  • I added the following line in my module.ivy to use ProGuard:
    <ea:plugin organisation="com.is2t.easyant.plugins" module="obf-proguard" revision="3.0.0"/>
  • I’m using MICROEJ DIST 21.11, SDK plug-in 5.8.2.
  • My library project:
    image

Am I missing something?

Thanks,

Fabrice

Hello Fabrice,

Looks like Proguard did shrink all types, resulting in an empty output jar. According to the information that you provided, you are missing a file defining the Proguard rules to use. As a consequence, Proguard will apply the default rules. The official Proguard documentation states that “by default, ProGuard shrinks the code: it removes all unused classes and class members. It only keeps the ones listed by the various -keep options, and the ones on which they depend, directly or indirectly.”.

To provide custom rules, you can add them in a file named “module.pro” file at the root of your project.

You have an example of this on our GitHub: How-To/Proguard-Get-Started/module.pro at 3.0.0 · MicroEJ/How-To · GitHub
You can also check the Proguard documentation that gives a good example for a typical library: ProGuard Manual: Examples | Guardsquare

Note that you can check how Proguard renamed your types and methods by looking at the file target~/build-env/[mymodule].renamelog at the end of the build.

Thomas

Hello Thomas,

Thanks for the information, using the module.pro template provided in the ProGuard documentation solved my problem!

Regards,

Fabrice