Buck: Align gerrit build interface to bucklets

Bucklets are reusable building blocks for buck driven build. Many
bucklets match Gerrit's own methods and were derived from them. To
enable buck driven build of gerrit plugins bucklets, are used. This
simplifies the implementation without need of code duplication. The
problem is however, that unlike maven driven build, in gerrit tree
build mode is supported for plugins.  Because of mismatch of buck
build interface between gerrit core and bucklets this currently can
not be done. This change synchronizes the interfaces between gerrit
and bucklets by exposing building blocks that are shared between gerrit
and bucklets in own files and linking them from bucklets directory.
That way bucklets can be (re-)used from both build modes: in gerrit
tree and standalone.

Change-Id: I8457b99936f009b4bc531f3b5633e4f19cb3b676
diff --git a/lib/maven.defs b/lib/maven.defs
index 5f4006f..adce2a5 100644
--- a/lib/maven.defs
+++ b/lib/maven.defs
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+include_defs('//lib/local.defs')
+
 ATLASSIAN = 'ATLASSIAN:'
 GERRIT = 'GERRIT:'
 GERRIT_API = 'GERRIT_API:'
@@ -135,35 +137,3 @@
       visibility = visibility,
     )
 
-def local_jar(
-    name,
-    jar,
-    src = None,
-    deps = [],
-    visibility = ['PUBLIC']):
-  binjar = name + '.jar'
-  srcjar = name + '-src.jar'
-  genrule(
-    name = '%s__local_bin' % name,
-    cmd = 'ln -s %s $OUT' % jar,
-    out = binjar)
-  if src:
-    genrule(
-      name = '%s__local_src' % name,
-      cmd = 'ln -s %s $OUT' % src,
-      out = srcjar)
-    prebuilt_jar(
-      name = '%s_src' % name,
-      binary_jar = ':%s__local_src' % name,
-      visibility = visibility,
-    )
-  else:
-    srcjar = None
-
-  prebuilt_jar(
-    name = name,
-    deps = deps,
-    binary_jar = ':%s__local_bin' % name,
-    source_jar = ':%s__local_src' % name if srcjar else None,
-    visibility = visibility,
-  )