How are .java files created in the android_stubs_current_intermediates directory?

The Android build process generates (?) Java stubs for each of the classes in android.jar and stores them in the following directory:

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

For example, a subdirectory of the java/lang/specified directory contains .java files corresponding to java.lang. * classes, and the subdirectory `android / app / 'contains .java files corresponding to the classes android.app. *. These .java files do not contain the actual code, but simply signatures with dummy bodies.

I assume that these .java files are generated from the source code using a tool. My question is, is this a tool, and can it be used outside of the Android build process?

I want to use this tool to create stubs for classes other than Android Java.

+5
source share
1 answer

The "Cigarette butts" here is an API shell created when the javadoc tool is launched.

In most cases, when we talk about a stub in Android, we mean a java file created using the helpl tool. For example, see How to create a stub in android? - stack overflow

In particular, the Android build system contains a make file called droiddoc.mkthat can be used to create documentation, java API stubs, and API files for the API files that actually call javadoc.
droiddoc.mkis under build/core. There build/core/config.mkis a variable with a name BUILD_DROIDDOCto simplify the inclusion droiddoc.mk.

Look at droiddoc.mkit calling 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 $@ 

? , , PRIVATE_DROIDDOC_OPTIONS

PRIVATE_DROIDDOC_OPTIONS := $(LOCAL_DROIDDOC_OPTIONS)

Android.mk AOSP, framework/base/Android.mk, include $(BUILD_DROIDDOC) . framework/base/Android.mk :

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)

LOCAL_DROIDDOC_OPTIONS -stubs. , , javadoc, droiddoc.mk.

, javadoc , -stubs. , Javadoc doclets. Javadoc "" , doclet, API HTML. , HTML, XML, MIF, RTF , .

-doclet, . javadoc droiddoc.mk -doclet com.google.doclava.Doclava. doclet -stubs.

Doclava 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>();
    for (String pkg : a[1].split(":")) {
      stubPackages.add(pkg);
    }
  }

-stubs. stubsDir.

// Stubs
if (stubsDir != null || apiFile != null || proguardFile != null) {
  Stubs.writeStubsAndApi(stubsDir, apiFile, proguardFile, stubPackages);
}

Stubs.writeStubsAndApi, , - .

java , , build/tools/droiddoc/test.

+9

All Articles