TestJavaCompilation.gmk revision 1379:6af7f86fc626
165793Smsmith# 265793Smsmith# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 381082Sscottl# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 465793Smsmith# 581082Sscottl# This code is free software; you can redistribute it and/or modify it 665793Smsmith# under the terms of the GNU General Public License version 2 only, as 765793Smsmith# published by the Free Software Foundation. Oracle designates this 865793Smsmith# particular file as subject to the "Classpath" exception as provided 965793Smsmith# by Oracle in the LICENSE file that accompanied this code. 1065793Smsmith# 1165793Smsmith# This code is distributed in the hope that it will be useful, but WITHOUT 1265793Smsmith# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1365793Smsmith# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1465793Smsmith# version 2 for more details (a copy is included in the LICENSE file that 1565793Smsmith# accompanied this code). 1665793Smsmith# 1765793Smsmith# You should have received a copy of the GNU General Public License version 1865793Smsmith# 2 along with this work; if not, write to the Free Software Foundation, 1965793Smsmith# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 2065793Smsmith# 2165793Smsmith# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2265793Smsmith# or visit www.oracle.com if you need additional information or have any 2365793Smsmith# questions. 2465793Smsmith# 2565793Smsmith 2665793Smsmithdefault: all 2765793Smsmith 2865793Smsmithinclude $(SPEC) 2965793Smsmithinclude MakeBase.gmk 3065793Smsmithinclude JavaCompilation.gmk 3165793Smsmith 32111691SscottlTHIS_FILE := $(SRC_ROOT)/test/make/TestJavaCompilation.gmk 33188896SattilioDEPS := $(THIS_FILE) \ 34111691Sscottl $(SRC_ROOT)/make/common/MakeBase.gmk \ 35111691Sscottl $(SRC_ROOT)/make/common/JavaCompilation.gmk \ 36247570Smarius # 37247570Smarius 38111691SscottlOUTPUT_DIR := $(TESTMAKE_OUTPUTDIR)/java-compilation 39112946Sphk 40111691Sscottl################################################################################ 41247570Smarius# Test: jar1 42247570Smarius# Creates a simple jar file and unzips it to verify that the files have not 43203885Semaste# changed. 44203885Semaste 45203885SemasteJAR1_SRC_ROOT := $(OUTPUT_DIR)/jar1src 46203885SemasteJAR1_UNZIP := $(OUTPUT_DIR)/jar1unzip 47203885SemasteJAR1_FILE := $(OUTPUT_DIR)/jar1.jar 48203885SemasteJAR1_MANIFEST := $(OUTPUT_DIR)/jar1_manifest 49203885Semaste 50203885Semasteclean-jar1: 51203885Semaste $(RM) -r $(OUTPUT_DIR)/_jar1* $(OUTPUT_DIR)/jar1* 52203885Semaste 53151086Sscottl$(JAR1_MANIFEST): | $(OUTPUT_DIR)/_jar1_created 54151086Sscottl $(ECHO) "Test-Attribute: value" > $(JAR1_MANIFEST) 55151086Sscottl 56112946Sphk$(OUTPUT_DIR)/_jar1_created: $(DEPS) 5783114Sscottl $(RM) -r $(JAR1_SRC_ROOT) 5883114Sscottl $(RM) $(JAR1_FILE) 5983114Sscottl $(RM) -r $(JAR1_UNZIP) 6065793Smsmith $(MKDIR) -p $(JAR1_SRC_ROOT) 6165793Smsmith $(MKDIR) -p $(JAR1_SRC_ROOT)/dir1 62206534Semaste $(MKDIR) -p $(JAR1_SRC_ROOT)/dir2 6365793Smsmith $(MKDIR) -p $(JAR1_SRC_ROOT)/META-INF 6465793Smsmith $(TOUCH) $(JAR1_SRC_ROOT)/dir1/file1.class 65254004Smarius $(TOUCH) $(JAR1_SRC_ROOT)/dir2/file2.class 6665793Smsmith $(TOUCH) $(JAR1_SRC_ROOT)/META-INF/metafile 6765793Smsmith $(TOUCH) $@ 6865793Smsmith 6965793Smsmith$(eval $(call SetupArchive,BUILD_JAR1, \ 7065793Smsmith DEPENDENCIES := $(OUTPUT_DIR)/_jar1_created, \ 7165793Smsmith SRCS := $(JAR1_SRC_ROOT), \ 7265793Smsmith MANIFEST := $(JAR1_MANIFEST), \ 7381082Sscottl JAR := $(JAR1_FILE))) 7481082Sscottl 7565793Smsmith$(OUTPUT_DIR)/_jar1_verified: $(BUILD_JAR1) 7665793Smsmith $(RM) -r $(JAR1_UNZIP) 7765793Smsmith $(MKDIR) -p $(JAR1_UNZIP) 7865793Smsmith $(CD) $(JAR1_UNZIP) && $(UNZIP) $(JAR1_FILE) $(LOG_DEBUG) 7965793Smsmith $(DIFF) -r $(JAR1_SRC_ROOT)/dir1 $(JAR1_UNZIP)/dir1 8065793Smsmith $(DIFF) -r $(JAR1_SRC_ROOT)/dir2 $(JAR1_UNZIP)/dir2 8165793Smsmith $(DIFF) -r $(JAR1_SRC_ROOT)/META-INF/metafile $(JAR1_UNZIP)/META-INF/metafile 8265793Smsmith if [ "`$(GREP) 'Test-Attribute: value' $(JAR1_UNZIP)/META-INF/MANIFEST.MF`" = "" ]; then \ 8365793Smsmith $(ECHO) "Could not find Test-Attribute in manifest of $(JAR1_FILE)"; \ 84206534Semaste exit 1; \ 8581082Sscottl fi 8665793Smsmith $(TOUCH) $@ 8765793Smsmith 8865793Smsmithcreate-jar2: $(OUTPUT_DIR)/_jar1_verified 8965793SmsmithTEST_TARGETS += $(OUTPUT_DIR)/_jar1_verified 9065793Smsmith 9165793Smsmith# Change a source file and call this makefile again to force the jar to be 9270393Smsmith# updated. 9365793Smsmith$(OUTPUT_DIR)/_jar1_updated: $(OUTPUT_DIR)/_jar1_verified 9465793Smsmith $(ECHO) updated > $(JAR1_SRC_ROOT)/dir1/file1.class 9570393Smsmith $(ECHO) updated > $(JAR1_SRC_ROOT)/META-INF/metafile 9670393Smsmith $(TOUCH) $(OUTPUT_DIR)/_jar1_created 97197011Semaste +$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar1_verified 9870393Smsmith $(TOUCH) $@ 9970393Smsmith 10070393Smsmithupdate-jar1: $(OUTPUT_DIR)_jar1_updated 10170393Smsmith 10270393Smsmith# Change the manifest file and call this makefile again to force the jar 10382527Sscottl# to be updated 10470393Smsmith$(OUTPUT_DIR)/_jar1_updated_manifest: $(OUTPUT_DIR)/_jar1_updated 10570393Smsmith $(ECHO) "Test-Attribute: foobar" > $(JAR1_MANIFEST) 10665793Smsmith +$(MAKE) -f $(THIS_FILE) $(BUILD_JAR1) 10765793Smsmith $(RM) -r $(JAR1_UNZIP) 10865793Smsmith $(MKDIR) -p $(JAR1_UNZIP) 10965793Smsmith $(CD) $(JAR1_UNZIP) && $(UNZIP) $(JAR1_FILE) $(LOG_DEBUG) 11083114Sscottl if [ "`$(GREP) 'Test-Attribute: foobar' $(JAR1_UNZIP)/META-INF/MANIFEST.MF`" = "" ]; then \ 11183114Sscottl $(ECHO) "Could not find Test-Attribute in manifest of $(JAR1_FILE)"; \ 11283114Sscottl exit 1; \ 11383114Sscottl fi 11465793Smsmith $(TOUCH) $@ 11565793Smsmith 11665793Smsmithupdate-jar1-manifest: $(OUTPUT_DIR)/_jar1_updated_manifest 117110426Sscottl 118110426SscottlTEST_TARGETS += $(OUTPUT_DIR)/_jar1_updated $(OUTPUT_DIR)/_jar1_updated_manifest 119213272Semaste 120110426Sscottl.PHONY: clean-jar1 create-jar1 update-jar1 update-jar1-manifest 121110426Sscottl 122110426Sscottl################################################################################ 123110426Sscottl# Test: jar2 124110426Sscottl# Creates a jar file based on 2 source roots 125110426Sscottl 126110426SscottlJAR2_SRC_ROOT1 := $(OUTPUT_DIR)/jar2src1 127213272SemasteJAR2_SRC_ROOT2 := $(OUTPUT_DIR)/jar2src2 128110426SscottlJAR2_UNZIP := $(OUTPUT_DIR)/jar2unzip 129110426SscottlJAR2_FILE := $(OUTPUT_DIR)/jar2.jar 130110426Sscottl 131110426Sscottlclean-jar2: 13265793Smsmith $(RM) -r $(OUTPUT_DIR)/_jar2* $(OUTPUT_DIR)/jar2* 13365793Smsmith 134206534Semaste$(OUTPUT_DIR)/_jar2_created: $(DEPS) 13565793Smsmith $(RM) -r $(JAR2_SRC_ROOT1) 13683114Sscottl $(RM) -r $(JAR2_SRC_ROOT2) 13783114Sscottl $(RM) $(JAR2_FILE) 13883114Sscottl $(RM) -r $(JAR2_UNZIP) 139125975Sphk $(MKDIR) -p $(JAR2_SRC_ROOT1)/dir1 14083114Sscottl $(MKDIR) -p $(JAR2_SRC_ROOT2)/dir2 14165793Smsmith $(TOUCH) $(JAR2_SRC_ROOT1)/dir1/file1.class 14283114Sscottl $(TOUCH) $(JAR2_SRC_ROOT2)/dir2/file2.class 14383114Sscottl $(TOUCH) $@ 14483114Sscottl 145177619Semaste$(eval $(call SetupArchive,BUILD_JAR2, \ 14683114Sscottl DEPENDENCIES := $(OUTPUT_DIR)/_jar2_created, \ 14765793Smsmith SRCS := $(JAR2_SRC_ROOT1) $(JAR2_SRC_ROOT2), \ 14865793Smsmith JAR := $(JAR2_FILE))) 14965793Smsmith 15065793Smsmith$(OUTPUT_DIR)/_jar2_verified: $(BUILD_JAR2) 15165793Smsmith $(RM) -r $(JAR2_UNZIP) 15265793Smsmith $(MKDIR) -p $(JAR2_UNZIP) 15365793Smsmith $(CD) $(JAR2_UNZIP) && $(UNZIP) $(JAR2_FILE) $(LOG_DEBUG) 15483114Sscottl $(DIFF) -r $(JAR2_SRC_ROOT1)/dir1 $(JAR2_UNZIP)/dir1 15565793Smsmith $(DIFF) -r $(JAR2_SRC_ROOT2)/dir2 $(JAR2_UNZIP)/dir2 15683114Sscottl $(TOUCH) $@ 15765793Smsmith 15883114Sscottlcreate-jar2: $(OUTPUT_DIR)/_jar2_verified 15981082SscottlTEST_TARGETS += $(OUTPUT_DIR)/_jar2_verified 160151086Sscottl 161251115Smarius$(OUTPUT_DIR)/_jar2_updated: $(OUTPUT_DIR)/_jar2_verified 16281082Sscottl $(ECHO) updated > $(JAR2_SRC_ROOT1)/dir1/file1.class 16383114Sscottl $(TOUCH) $(OUTPUT_DIR)/_jar2_created 16483114Sscottl +$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar2_verified 16583114Sscottl $(TOUCH) $@ 16681082Sscottl 167251115Smariusupdate-jar2: $(OUTPUT_DIR)/_jar2_updated 16881082SscottlTEST_TARGETS += $(OUTPUT_DIR)/_jar2_updated 16981082Sscottl 17081082Sscottl.PHONY: clean-jar2 create-jar2 update-jar2 17181082Sscottl 17281082Sscottl################################################################################ 17381082Sscottl# Test: jar3 17465793Smsmith# Creates a jar file based on 2 source roots with an extra file 17570393Smsmith 17681151SscottlJAR3_SRC_ROOT1 := $(OUTPUT_DIR)/jar3src1 17781151SscottlJAR3_SRC_ROOT2 := $(OUTPUT_DIR)/jar3src2 17881151SscottlJAR3_UNZIP := $(OUTPUT_DIR)/jar3unzip 179151086SscottlJAR3_FILE := $(OUTPUT_DIR)/jar3.jar 180151086Sscottl 181151086Sscottlclean-jar3: 182117363Sscottl $(RM) -r $(OUTPUT_DIR)/_jar3* $(OUTPUT_DIR)/jar3* 183117363Sscottl 184251116Smarius$(OUTPUT_DIR)/_jar3_created: $(DEPS) 185251116Smarius $(RM) -r $(JAR3_SRC_ROOT1) 18665793Smsmith $(RM) -r $(JAR3_SRC_ROOT2) 187251115Smarius $(RM) $(JAR3_FILE) 18883114Sscottl $(RM) -r $(JAR3_UNZIP) 18983114Sscottl $(MKDIR) -p $(JAR3_SRC_ROOT1)/dir1 19083114Sscottl $(MKDIR) -p $(JAR3_SRC_ROOT2)/dir2 191111152Sscottl $(TOUCH) $(JAR3_SRC_ROOT1)/dir1/file1\$$foo.class 19265793Smsmith $(TOUCH) $(JAR3_SRC_ROOT2)/dir2/file2.class 19365793Smsmith $(TOUCH) $(JAR3_SRC_ROOT2)/extra-file 194110604Sscottl $(TOUCH) $(JAR3_SRC_ROOT2)/extra-file-abs 195110604Sscottl $(TOUCH) $(JAR3_SRC_ROOT2)/dir2/file\$$foo.dollar 196110604Sscottl $(TOUCH) $@ 197110604Sscottl 198110604Sscottl$(eval $(call SetupArchive,BUILD_JAR3, \ 199110604Sscottl DEPENDENCIES := $(OUTPUT_DIR)/_jar3_created, \ 200110604Sscottl SRCS := $(JAR3_SRC_ROOT1) $(JAR3_SRC_ROOT2), \ 20165793Smsmith EXTRA_FILES := extra-file \ 20265793Smsmith dir2/file$$$$foo.dollar \ 20365793Smsmith $(JAR3_SRC_ROOT2)/extra-file-abs, \ 20465793Smsmith EXCLUDE_FILES := dir1/file1$$$$foo.class, \ 20565793Smsmith JAR := $(JAR3_FILE))) 20665793Smsmith 20765793Smsmith$(OUTPUT_DIR)/_jar3_verified: $(BUILD_JAR3) 20865793Smsmith $(RM) -r $(JAR3_UNZIP) 20965793Smsmith $(MKDIR) -p $(JAR3_UNZIP) 21065793Smsmith $(CD) $(JAR3_UNZIP) && $(UNZIP) $(JAR3_FILE) $(LOG_DEBUG) 21165793Smsmith if [ -d "$(JAR3_UNZIP)/dir1" ]; then \ 21265793Smsmith echo Should not be included $(JAR3_UNZIP)/dir1; \ 21365793Smsmith exit 1; \ 21465793Smsmith fi 21583114Sscottl $(DIFF) -r $(JAR3_SRC_ROOT2)/dir2 $(JAR3_UNZIP)/dir2 21683114Sscottl $(DIFF) -r $(JAR3_SRC_ROOT2)/extra-file $(JAR3_UNZIP)/extra-file 21765793Smsmith $(TOUCH) $@ 21883114Sscottl 21983114Sscottlcreate-jar3: $(OUTPUT_DIR)/_jar3_verified 22065793SmsmithTEST_TARGETS += $(OUTPUT_DIR)/_jar3_verified 22183114Sscottl 22283114Sscottl$(OUTPUT_DIR)/_jar3_updated: $(OUTPUT_DIR)/_jar3_verified 22383114Sscottl $(ECHO) updated > $(JAR3_SRC_ROOT2)/extra-file 22465793Smsmith $(TOUCH) $(OUTPUT_DIR)/_jar3_created 22583114Sscottl +$(MAKE) -f $(THIS_FILE) $(OUTPUT_DIR)/_jar3_verified 226206534Semaste $(TOUCH) $@ 227254004Smarius 22883114Sscottlupdate-jar3: $(OUTPUT_DIR)/_jar3_updated 22983114SscottlTEST_TARGETS += $(OUTPUT_DIR)/_jar3_updated 23065793Smsmith 23165793Smsmith.PHONY: clean-jar3 create-jar3 update-jar3 23265793Smsmith 23365793Smsmith################################################################################ 23465793Smsmith 235206534Semasteall: $(TEST_TARGETS) 23665793Smsmith 23783114Sscottl.PHONY: default all 23883114Sscottl