From 29f95395d51fb215ea1eedfe07b0531064a1dda1 Mon Sep 17 00:00:00 2001 From: David Ostrovsky Date: Mon, 22 Aug 2016 00:32:46 +0200 Subject: [PATCH] Plugin API: Provide custom manifest file If no manifest file is specified, Buck's java_binary() rule merges the content of manifest files from the dependant JARs into output META/MANIFEST.MF. Normally we wouldn't care that it ends up with a lot of mess, but unfortunately, it breaks the plugin-api.jar, with sealed package exception, so we do care. This happens because we provide the same package in multiple JARs, e.g. com.gerrit.server.project is shipped with plugin-api.jar, obviously, but it happens that one file Util.class, from the same package is shipped in the gerrit-acceptance-framework.jar artifact. Normally it doesn't matter, unless a JAR is defined as sealed in which case security violation exception is thrown during unit tests execution. To rectify this, we use the combination of custom manifest_file attribute of java_binary() rule and passing non documented option from this issue: [1] to ask Buck to not merge manifest files from the dependant JARs. With this fix, plugin unit tests executions in standalone build mode work again. * [1] https://github.com/facebook/buck/issues/86 Change-Id: I7b7571c20dcf6b54210b73760eccc8e699e6f1f6 --- gerrit-acceptance-framework/BUCK | 10 ++++++++++ gerrit-plugin-api/BUCK | 10 ++++++++++ 2 files changed, 20 insertions(+) diff --git a/gerrit-acceptance-framework/BUCK b/gerrit-acceptance-framework/BUCK index ba68fa3f2e..7ef71c4568 100644 --- a/gerrit-acceptance-framework/BUCK +++ b/gerrit-acceptance-framework/BUCK @@ -37,10 +37,20 @@ PROVIDED = [ java_binary( name = 'acceptance-framework', + merge_manifests = False, + manifest_file = ':manifest', deps = [':lib'], visibility = ['PUBLIC'], ) +genrule( + name = 'manifest', + cmd = 'echo "Manifest-Version: 1.0" >$OUT;' + + 'echo "Implementation-Title: Gerrit Acceptance Test Framework" >>$OUT;' + + 'echo "Implementation-Vendor: Gerrit Code Review Project" >>$OUT', + out = 'manifest.txt', +) + java_library( name = 'lib', srcs = SRCS, diff --git a/gerrit-plugin-api/BUCK b/gerrit-plugin-api/BUCK index c18e497d2c..7e12f232cc 100644 --- a/gerrit-plugin-api/BUCK +++ b/gerrit-plugin-api/BUCK @@ -13,10 +13,20 @@ PLUGIN_API = [ java_binary( name = 'plugin-api', + merge_manifests = False, + manifest_file = ':manifest', deps = [':lib'], visibility = ['PUBLIC'], ) +genrule( + name = 'manifest', + cmd = 'echo "Manifest-Version: 1.0" >$OUT;' + + 'echo "Implementation-Title: Gerrit Plugin API" >>$OUT;' + + 'echo "Implementation-Vendor: Gerrit Code Review Project" >>$OUT', + out = 'manifest.txt', +) + java_library( name = 'lib', exported_deps = PLUGIN_API + [