Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create API jar like Android does with stubbed methods?

I'm looking to distribute a custom API and know the classes will be available at run time. I would like my public and protected methods / classes to be included in a jar I can distribute but I don't want any other source code and I would like to throw an exception if that jars code is actually executed.

This is the exact behaviour the Android framework jar has when you attempt to execute the jar directly.

My question is how to I create the same jar from my source without manually going through and creating each stubbed method. I would like this to scale as my API grows.

like image 483
Bobbake4 Avatar asked Oct 29 '22 20:10

Bobbake4


1 Answers

I believe you can use for that purpose the mkstubs tool: https://github.com/android/platform_development/tree/master/tools/mkstubs

As @CommonsWare mentioned stubs in AOSP are generated by javadoc DroidDoc script, read here: How are .java files in android_stubs_current_intermediates directory generated?

like image 90
Mixaz Avatar answered Nov 15 '22 06:11

Mixaz