# # Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License version 2 only, as # published by the Free Software Foundation. Oracle designates this # particular file as subject to the "Classpath" exception as provided # by Oracle in the LICENSE file that accompanied this code. # # This code is distributed in the hope that it will be useful, but WITHOUT # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # version 2 for more details (a copy is included in the LICENSE file that # accompanied this code). # # You should have received a copy of the GNU General Public License version # 2 along with this work; if not, write to the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. # # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA # or visit www.oracle.com if you need additional information or have any # questions. # default: all include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk THIS_FILE := $(SRC_ROOT)/test/make/TestJavaCompilation.gmk DEPS := $(THIS_FILE) \ $(SRC_ROOT)/make/common/MakeBase.gmk \ $(SRC_ROOT)/make/common/JavaCompilation.gmk \ # OUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/java-compilation ################################################################################ # Test: jar1 # Creates a simple jar file and unzips it to verify that the files have not # changed. JAR1_SRC_ROOT := $(OUTPUT_DIR)/jar1src JAR1_UNZIP := $(OUTPUT_DIR)/jar1unzip JAR1_FILE := $(OUTPUT_DIR)/jar1.jar JAR1_MANIFEST := $(OUTPUT_DIR)/jar1_manifest clean-jar1: $(RM) -r $(OUTPUT_DIR)/_jar1* $(OUTPUT_DIR)/jar1* $(JAR1_MANIFEST): | $(OUTPUT_DIR)/_jar1_created $(ECHO) "Test-Attribute: value" > $(JAR1_MANIFEST) $(OUTPUT_DIR)/_jar1_created: $(DEPS) $(RM) -r $(JAR1_SRC_ROOT) $(RM) $(JAR1_FILE) $(RM) -r $(JAR1_UNZIP) $(MKDIR) -p $(JAR1_SRC_ROOT) $(MKDIR) -p $(JAR1_SRC_ROOT)/dir1 $(MKDIR) -p $(JAR1_SRC_ROOT)/dir2 $(MKDIR) -p $(JAR1_SRC_ROOT)/META-INF $(TOUCH) $(JAR1_SRC_ROOT)/dir1/file1.class $(TOUCH) $(JAR1_SRC_ROOT)/dir2/file2.class $(TOUCH) $(JAR1_SRC_ROOT)/META-INF/metafile $(TOUCH) $@ $(eval $(call SetupArchive,BUILD_JAR1, \ $(OUTPUT_DIR)/_jar1_created, \ SRCS := $(JAR1_SRC_ROOT), \ MANIFEST := $(JAR1_MANIFEST), \ JAR := $(JAR1_FILE))) $(OUTPUT_DIR)/_jar1_verified: $(BUILD_JAR1) $(RM) -r $(JAR1_UNZIP) $(MKDIR) -p $(JAR1_UNZIP) $(CD) $(JAR1_UNZIP) && $(UNZIP) $(JAR1_FILE) $(LOG_DEBUG) $(DIFF) -r $(JAR1_SRC_ROOT)/dir1 $(JAR1_UNZIP)/dir1 $(DIFF) -r $(JAR1_SRC_ROOT)/dir2 $(JAR1_UNZIP)/dir2 $(DIFF) -r $(JAR1_SRC_ROOT)/META-INF/metafile $(JAR1_UNZIP)/META-INF/metafile if [ "`$(GREP) 'Test-Attribute: value' $(JAR1_UNZIP)/META-INF/MANIFEST.MF`" = "" ]; then \ $(ECHO) "Could not find Test-Attribute in manifest of $(JAR1_FILE)"; \ exit 1; \ fi $(TOUCH) $@ create-jar2: $(OUTPUT_DIR)/_jar1_verified TEST_TARGETS += $(OUTPUT_DIR)/_jar1_verified # Change a source file and call this makefile again to force the jar to be # updated. $(OUTPUT_DIR)/_jar1_updated: $(OUTPUT_DIR)/_jar1_verified $(ECHO) updated > $(JAR1_SRC_ROOT)/dir1/file1.class $(ECHO) updated > $(JAR1_SRC_ROOT)/META-INF/metafile $(TOUCH) $(OUTPUT_DIR)/_jar1_created +$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar1_verified $(TOUCH) $@ update-jar1: $(OUTPUT_DIR)_jar1_updated # Change the manifest file and call this makefile again to force the jar # to be updated $(OUTPUT_DIR)/_jar1_updated_manifest: $(OUTPUT_DIR)/_jar1_updated $(ECHO) "Test-Attribute: foobar" > $(JAR1_MANIFEST) +$(MAKE) -f $(THIS_FILE) $(BUILD_JAR1) $(RM) -r $(JAR1_UNZIP) $(MKDIR) -p $(JAR1_UNZIP) $(CD) $(JAR1_UNZIP) && $(UNZIP) $(JAR1_FILE) $(LOG_DEBUG) if [ "`$(GREP) 'Test-Attribute: foobar' $(JAR1_UNZIP)/META-INF/MANIFEST.MF`" = "" ]; then \ $(ECHO) "Could not find Test-Attribute in manifest of $(JAR1_FILE)"; \ exit 1; \ fi $(TOUCH) $@ update-jar1-manifest: $(OUTPUT_DIR)/_jar1_updated_manifest TEST_TARGETS += $(OUTPUT_DIR)/_jar1_updated $(OUTPUT_DIR)/_jar1_updated_manifest .PHONY: clean-jar1 create-jar1 update-jar1 update-jar1-manifest ################################################################################ # Test: jar2 # Creates a jar file based on 2 source roots JAR2_SRC_ROOT1 := $(OUTPUT_DIR)/jar2src1 JAR2_SRC_ROOT2 := $(OUTPUT_DIR)/jar2src2 JAR2_UNZIP := $(OUTPUT_DIR)/jar2unzip JAR2_FILE := $(OUTPUT_DIR)/jar2.jar clean-jar2: $(RM) -r $(OUTPUT_DIR)/_jar2* $(OUTPUT_DIR)/jar2* $(OUTPUT_DIR)/_jar2_created: $(DEPS) $(RM) -r $(JAR2_SRC_ROOT1) $(RM) -r $(JAR2_SRC_ROOT2) $(RM) $(JAR2_FILE) $(RM) -r $(JAR2_UNZIP) $(MKDIR) -p $(JAR2_SRC_ROOT1)/dir1 $(MKDIR) -p $(JAR2_SRC_ROOT2)/dir2 $(TOUCH) $(JAR2_SRC_ROOT1)/dir1/file1.class $(TOUCH) $(JAR2_SRC_ROOT2)/dir2/file2.class $(TOUCH) $@ $(eval $(call SetupArchive,BUILD_JAR2, \ $(OUTPUT_DIR)/_jar2_created, \ SRCS := $(JAR2_SRC_ROOT1) $(JAR2_SRC_ROOT2), \ JAR := $(JAR2_FILE))) $(OUTPUT_DIR)/_jar2_verified: $(BUILD_JAR2) $(RM) -r $(JAR2_UNZIP) $(MKDIR) -p $(JAR2_UNZIP) $(CD) $(JAR2_UNZIP) && $(UNZIP) $(JAR2_FILE) $(LOG_DEBUG) $(DIFF) -r $(JAR2_SRC_ROOT1)/dir1 $(JAR2_UNZIP)/dir1 $(DIFF) -r $(JAR2_SRC_ROOT2)/dir2 $(JAR2_UNZIP)/dir2 $(TOUCH) $@ create-jar2: $(OUTPUT_DIR)/_jar2_verified TEST_TARGETS += $(OUTPUT_DIR)/_jar2_verified $(OUTPUT_DIR)/_jar2_updated: $(OUTPUT_DIR)/_jar2_verified $(ECHO) updated > $(JAR2_SRC_ROOT1)/dir1/file1.class $(TOUCH) $(OUTPUT_DIR)/_jar2_created +$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar2_verified $(TOUCH) $@ update-jar2: $(OUTPUT_DIR)/_jar2_updated TEST_TARGETS += $(OUTPUT_DIR)/_jar2_updated .PHONY: clean-jar2 create-jar2 update-jar2 ################################################################################ # Test: jar3 # Creates a jar file based on 2 source roots with an extra file JAR3_SRC_ROOT1 := $(OUTPUT_DIR)/jar3src1 JAR3_SRC_ROOT2 := $(OUTPUT_DIR)/jar3src2 JAR3_UNZIP := $(OUTPUT_DIR)/jar3unzip JAR3_FILE := $(OUTPUT_DIR)/jar3.jar clean-jar3: $(RM) -r $(OUTPUT_DIR)/_jar3* $(OUTPUT_DIR)/jar3* $(OUTPUT_DIR)/_jar3_created: $(DEPS) $(RM) -r $(JAR3_SRC_ROOT1) $(RM) -r $(JAR3_SRC_ROOT2) $(RM) $(JAR3_FILE) $(RM) -r $(JAR3_UNZIP) $(MKDIR) -p $(JAR3_SRC_ROOT1)/dir1 $(MKDIR) -p $(JAR3_SRC_ROOT2)/dir2 $(TOUCH) $(JAR3_SRC_ROOT1)/dir1/file1\$$foo.class $(TOUCH) $(JAR3_SRC_ROOT2)/dir2/file2.class $(TOUCH) $(JAR3_SRC_ROOT2)/extra-file $(TOUCH) $(JAR3_SRC_ROOT2)/extra-file-abs $(TOUCH) $(JAR3_SRC_ROOT2)/dir2/file\$$foo.dollar $(TOUCH) $@ $(eval $(call SetupArchive,BUILD_JAR3, \ $(OUTPUT_DIR)/_jar3_created, \ SRCS := $(JAR3_SRC_ROOT1) $(JAR3_SRC_ROOT2), \ EXTRA_FILES := extra-file \ dir2/file$$$$foo.dollar \ $(JAR3_SRC_ROOT2)/extra-file-abs, \ EXCLUDE_FILES := dir1/file1$$$$foo.class, \ JAR := $(JAR3_FILE))) $(OUTPUT_DIR)/_jar3_verified: $(BUILD_JAR3) $(RM) -r $(JAR3_UNZIP) $(MKDIR) -p $(JAR3_UNZIP) $(CD) $(JAR3_UNZIP) && $(UNZIP) $(JAR3_FILE) $(LOG_DEBUG) if [ -d "$(JAR3_UNZIP)/dir1" ]; then \ echo Should not be included $(JAR3_UNZIP)/dir1; \ exit 1; \ fi $(DIFF) -r $(JAR3_SRC_ROOT2)/dir2 $(JAR3_UNZIP)/dir2 $(DIFF) -r $(JAR3_SRC_ROOT2)/extra-file $(JAR3_UNZIP)/extra-file $(TOUCH) $@ create-jar3: $(OUTPUT_DIR)/_jar3_verified TEST_TARGETS += $(OUTPUT_DIR)/_jar3_verified $(OUTPUT_DIR)/_jar3_updated: $(OUTPUT_DIR)/_jar3_verified $(ECHO) updated > $(JAR3_SRC_ROOT2)/extra-file $(TOUCH) $(OUTPUT_DIR)/_jar3_created +$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar3_verified $(TOUCH) $@ update-jar3: $(OUTPUT_DIR)/_jar3_updated TEST_TARGETS += $(OUTPUT_DIR)/_jar3_updated .PHONY: clean-jar3 create-jar3 update-jar3 ################################################################################ all: $(TEST_TARGETS) .PHONY: default all