android - How are .java files in android_stubs_current_intermediates directory generated? -


the android build process generates(?) java stubs each of classes in android.jar, , stores them in following directory:

./out/target/common/obj/java_libraries/android_stubs_current_intermediates/src/

for example, subdirectory java/lang/ of above directory contains .java files corresponding java.lang.* classes, , subdirectory `android/app/' contains .java files corresponding android.app.* classes. these .java files dont contain actual code, signatures dummy bodies.

i assuming .java files generated actual source code using tool. question is, tool, , usable outside of android build process?

i want use tool generate stubs non-android java classes.

the "stubs" here framework api stub generated running javadoc tool.

in cases, when talk stub file in android, mean java file generated aidl tool. example see how generate stub in android? - stack overflow

in particular, android build system contains makefile called droiddoc.mk can used generate documentation, java api stubs , api xml files, calls javadoc.
droiddoc.mk under build/core. in build/core/config.mk there variable named build_droiddoc make easier include droiddoc.mk.

look @ droiddoc.mk, calls javadoc:

javadoc \             \@$(private_src_list_file) \             -j-xmx1280m \             $(private_profiling_options) \             -quiet \             -doclet com.google.doclava.doclava \             -docletpath $(private_docletpath) \             -templatedir $(private_custom_template_dir) \             $(private_droiddoc_html_dir) \             $(addprefix -bootclasspath ,$(private_bootclasspath)) \             $(addprefix -classpath ,$(private_classpath)) \             -sourcepath $(private_source_path)$(addprefix :,$(private_classpath)) \             -d $(private_out_dir) \             $(private_current_build) $(private_current_time) \             $(private_droiddoc_options) \     && touch -f $@  

there nothing stub right? don't worry, notice there private_droiddoc_options variable, ,

private_droiddoc_options := $(local_droiddoc_options) 

many android.mk files in aosp, example framework/base/android.mk, contain include $(build_droiddoc) generate docs. in framework/base/android.mk, there piece of code:

local_droiddoc_options:=\                 $(framework_docs_local_droiddoc_options) \                 -stubs $(target_out_common_intermediates)/java_libraries/android_stubs_current_intermediates/src \                 -api $(internal_platform_api_file) \                 -nodocs  local_droiddoc_custom_template_dir:=build/tools/droiddoc/templates-sdk  local_uninstallable_module := true  include $(build_droiddoc) 

the local_droiddoc_options contains -stubs option. , put javadoc command used droiddoc.mk.

however, may notice javadoc doesn't contain option -stubs. key can customize content , format of javadoc tool's output using doclets. javadoc tool has default "built-in" doclet, called standard doclet, generates html-formatted api documentation. can modify or subclass standard doclet, or write own doclet generate html, xml, mif, rtf or whatever output format you'd like.

we can use -doclet option specify our customized doclet. , javadoc command in droiddoc.mk use -doclet com.google.doclava.doclava. doclet receives -stubs option.

look @ doclava implementation under external/doclava/src/com/google/doclava/doclava.java

  else if (a[0].equals("-stubs")) {     stubsdir = a[1];   } else if (a[0].equals("-stubpackages")) {     stubpackages = new hashset<string>();     (string pkg : a[1].split(":")) {       stubpackages.add(pkg);     }   } 

it receives -stubs option. , here how process stubsdir.

// stubs if (stubsdir != null || apifile != null || proguardfile != null) {   stubs.writestubsandapi(stubsdir, apifile, proguardfile, stubpackages); } 

and trace implementation of stubs.writestubsandapi, can see why content in stub files that.

you can write own java files , generate stubs test cases under build/tools/droiddoc/test.


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -