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
This commit is contained in:
David Ostrovsky 2016-08-22 00:32:46 +02:00 committed by David Ostrovsky
parent 7a54f8be78
commit 29f95395d5
2 changed files with 20 additions and 0 deletions

View File

@ -37,10 +37,20 @@ PROVIDED = [
java_binary( java_binary(
name = 'acceptance-framework', name = 'acceptance-framework',
merge_manifests = False,
manifest_file = ':manifest',
deps = [':lib'], deps = [':lib'],
visibility = ['PUBLIC'], 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( java_library(
name = 'lib', name = 'lib',
srcs = SRCS, srcs = SRCS,

View File

@ -13,10 +13,20 @@ PLUGIN_API = [
java_binary( java_binary(
name = 'plugin-api', name = 'plugin-api',
merge_manifests = False,
manifest_file = ':manifest',
deps = [':lib'], deps = [':lib'],
visibility = ['PUBLIC'], 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( java_library(
name = 'lib', name = 'lib',
exported_deps = PLUGIN_API + [ exported_deps = PLUGIN_API + [