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
diff --git a/gerrit-plugin-api/BUCK b/gerrit-plugin-api/BUCK
index c18e497..7e12f232 100644
--- a/gerrit-plugin-api/BUCK
+++ b/gerrit-plugin-api/BUCK
@@ -13,10 +13,20 @@
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 + [