Bug 946083 - Part 1: Delete .class files when (re-)building a Java JAR. r=glandium
authorNick Alexander <nalexander@mozilla.com>
Tue, 11 Feb 2014 09:55:47 -0800
changeset 168096 5c68bbcef1abeec86d0b2e51ec842f51907a9155
parent 168095 08b4b4b4aef3fd01b342dd50ee44bf2c9590e854
child 168097 1a05d8dffc6541b985d4495bacc41d87303031f9
push id39653
push usernalexander@mozilla.com
push dateTue, 11 Feb 2014 19:29:00 +0000
treeherdermozilla-inbound@1a05d8dffc65 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersglandium
bugs946083
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 946083 - Part 1: Delete .class files when (re-)building a Java JAR. r=glandium This cleans up stale .class files, so they don't get packaged into the .jar files that Proguard consumes.
config/makefiles/java-build.mk
--- a/config/makefiles/java-build.mk
+++ b/config/makefiles/java-build.mk
@@ -78,19 +78,27 @@ endif #} ANDROID_APK_NAME
 ifdef JAVA_JAR_TARGETS #{
 # Arg 1: Output target name with .jar suffix, like jars/jarfile.jar.
 #        Intermediate class files are generated in jars/jarfile-classes.
 # Arg 2: Java sources list.  We use VPATH and $^ so sources can be
 #        relative to $(srcdir) or $(CURDIR).
 # Arg 3: List of extra jars to link against.  We do not use VPATH so
 #        jars must be relative to $(CURDIR).
 # Arg 4: Additional JAVAC_FLAGS.
+
+# Note: Proguard fails when stale .class files corresponding to
+# removed inner classes are present in the object directory.  These
+# stale class files get packaged into the .jar file, which then gets
+# processed by Proguard.  To work around this, we always delete any
+# existing jarfile-classes directory and start fresh.
+
 define java_jar_template
 $(1): $(2) $(3)
 	$$(REPORT_BUILD)
+	@$$(RM) -rf $(1:.jar=)-classes
 	@$$(NSINSTALL) -D $(1:.jar=)-classes
 	@$$(if $$(filter-out .,$$(@D)),$$(NSINSTALL) -D $$(@D))
 	$$(JAVAC) $$(JAVAC_FLAGS)\
     $(4)\
 		-d $(1:.jar=)-classes\
 		$(if $(strip $(3)),-classpath $(subst $(NULL) ,:,$(strip $(3))))\
 		$$(filter %.java,$$^)
 	$$(JAR) cMf $$@ -C $(1:.jar=)-classes .