8154313: Generated javadoc scattered all over the place
authorneugens
Fri, 15 Apr 2016 14:57:53 +0200
changeset 37034 b63fd4af003e
parent 37033 028bb52d9c95
child 37035 08e00f202d7a
8154313: Generated javadoc scattered all over the place Summary: Added new top level target zip-docs which scans all generated javadocs and prepare zip-archive in way understandable to most IDEs Reviewed-by: erikj Contributed-by: Jiri Vanek <jvanek@redhat.com>
make/Javadoc.gmk
make/Main.gmk
make/MainSupport.gmk
--- a/make/Javadoc.gmk	Thu Apr 14 09:32:16 2016 -0700
+++ b/make/Javadoc.gmk	Fri Apr 15 14:57:53 2016 +0200
@@ -235,6 +235,11 @@
 JRE_API_DOCSDIR = $(DOCSDIR)/jre/api
 PLATFORM_DOCSDIR = $(DOCSDIR)/platform
 
+JAVADOC_ARCHIVE_NAME := jdk-$(VERSION_STRING)-docs.zip
+JAVADOC_ARCHIVE_ASSEMBLY_DIR :=  $(DOCSTMPDIR)/zip-docs
+JAVADOC_ARCHIVE_DIR := $(OUTPUT_ROOT)/bundles
+JAVADOC_ARCHIVE := $(JAVADOC_ARCHIVE_DIR)/$(JAVADOC_ARCHIVE_NAME)
+
 # The core api index file is the target for the core api javadocs rule
 # and needs to be defined early so that all other javadoc rules may
 # depend on it.
@@ -378,6 +383,13 @@
 all: docs
 docs: coredocs otherdocs
 
+#
+# Optional target which bundles all generated javadocs into a zip archive.
+# The dependency on docs is handled in Main.gmk.
+#
+
+zip-docs: $(JAVADOC_ARCHIVE)
+
 #############################################################
 #
 # coredocs
@@ -1671,6 +1683,28 @@
 
 otherdocs: $(ALL_OTHER_TARGETS)
 
+#
+# Add the core docs as prerequisite to the archive to trigger a rebuild
+# if the core docs were rebuilt. Ideally any doc rebuild should trigger
+# this, but the way prerequisites are currently setup in this file, that
+# is hard to achieve.
+#
+
+$(JAVADOC_ARCHIVE): $(COREAPI_INDEX_FILE)
+	$(call LogInfo, Compressing javadoc to single $(JAVADOC_ARCHIVE_NAME))
+	$(MKDIR) -p $(JAVADOC_ARCHIVE_DIR)
+	$(RM) -r $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
+	$(MKDIR) -p $(JAVADOC_ARCHIVE_ASSEMBLY_DIR)
+	all_roots=`$(FIND) $(DOCSDIR) | $(GREP) index.html | grep -v old/doclet`; \
+	pushd $(JAVADOC_ARCHIVE_ASSEMBLY_DIR); \
+	for index_file in $${all_roots} ; do \
+	  target_dir=`dirname $${index_file}`; \
+	  name=`$(ECHO) $${target_dir} | $(SED) "s;/spec;;" | $(SED) "s;.*/;;"`; \
+	  $(LN) -s $${target_dir}  $${name}; \
+	done; \
+	$(ZIP) -q -r $(JAVADOC_ARCHIVE) * ; \
+	popd ;
+
 #############################################################
 .PHONY: all docs coredocs otherdocs \
-     $(ALL_OTHER_TARGETS)
+     $(ALL_OTHER_TARGETS) zip-docs
--- a/make/Main.gmk	Thu Apr 14 09:32:16 2016 -0700
+++ b/make/Main.gmk	Fri Apr 15 14:57:53 2016 +0200
@@ -333,6 +333,9 @@
 docs-jvmtidoc:
 	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk jvmtidocs)
 
+zip-docs: docs-javadoc docs-jvmtidoc
+	+($(CD) $(SRC_ROOT)/make && $(MAKE) $(MAKE_ARGS) -f Javadoc.gmk zip-docs)
+
 ALL_TARGETS += docs-javadoc docs-jvmtidoc
 
 ################################################################################
@@ -689,7 +692,7 @@
 endif
 
 # This target builds the documentation image
-docs-image: docs-javadoc docs-jvmtidoc
+docs-image: zip-docs
 
 # This target builds the test image
 test-image: prepare-test-image test-image-hotspot-jtreg-native \
@@ -713,7 +716,7 @@
 docs: docs-image
 all: all-images
 
-ALL_TARGETS += default jdk images docs all
+ALL_TARGETS += default jdk images docs all zip-docs
 
 ################################################################################
 ################################################################################
--- a/make/MainSupport.gmk	Thu Apr 14 09:32:16 2016 -0700
+++ b/make/MainSupport.gmk	Fri Apr 15 14:57:53 2016 +0200
@@ -104,6 +104,7 @@
 	@$(PRINTF) "\n" $(LOG_DEBUG)
 	$(RM) -r $(SUPPORT_OUTPUTDIR)/docs
 	$(RM) -r $(IMAGES_OUTPUTDIR)/docs
+	$(RM) $(OUTPUT_ROOT)/bundles/jdk-*-docs.zip
 	@$(PRINTF) " done\n"
 endef