Revert "Always run package check"

This reverts commit 91206d9ed1a1e3cb81d1ace021580c4be8362f1f.

Reason for revert: package-check.sh doesn't work on mac
Bug: 158081251
Bug: 157649935
Change-Id: I50af71d54d5f1f8b516bfcf1efbcf6217e89c83a
diff --git a/java/java.go b/java/java.go
index 09df2ad..76bfa86 100644
--- a/java/java.go
+++ b/java/java.go
@@ -463,6 +463,9 @@
 	// expanded Jarjar_rules
 	expandJarjarRules android.Path
 
+	// list of additional targets for checkbuild
+	additionalCheckedModules android.Paths
+
 	// Extra files generated by the module type to be added as java resources.
 	extraResources android.Paths
 
@@ -1518,10 +1521,10 @@
 
 	// Check package restrictions if necessary.
 	if len(j.properties.Permitted_packages) > 0 {
-		// Check packages and copy input to package-checked file.
-		// Use the file copied after a successful package check as the output file for this
-		// module so that any dependencies on this module will trigger the package check.
-		outputFile = CheckJarPackages(ctx, outputFile, j.properties.Permitted_packages)
+		// Check packages and copy to package-checked file.
+		pkgckFile := android.PathForModuleOut(ctx, "package-check.stamp")
+		CheckJarPackages(ctx, pkgckFile, outputFile, j.properties.Permitted_packages)
+		j.additionalCheckedModules = append(j.additionalCheckedModules, pkgckFile)
 
 		if ctx.Failed() {
 			return