Merge "lib/lucene: merge jars using a java_binary rule" into stable-2.16
This commit is contained in:
@@ -1,17 +1,28 @@
|
|||||||
load("@rules_java//java:defs.bzl", "java_library")
|
load("@rules_java//java:defs.bzl", "java_binary", "java_import", "java_library")
|
||||||
load("//tools/bzl:maven.bzl", "merge_maven_jars")
|
load("//tools/bzl:maven.bzl", "merge_maven_jars")
|
||||||
|
|
||||||
package(default_visibility = ["//visibility:public"])
|
package(default_visibility = ["//visibility:public"])
|
||||||
|
|
||||||
# core and backward-codecs both provide
|
# Merge jars so
|
||||||
# META-INF/services/org.apache.lucene.codecs.Codec, so they must be merged.
|
# META-INF/services/org.apache.lucene.codecs.Codec
|
||||||
merge_maven_jars(
|
# contains the union of both Codec collections.
|
||||||
name = "lucene-core-and-backward-codecs",
|
java_binary(
|
||||||
srcs = [
|
name = "lucene-core-and-backward-codecs-merged",
|
||||||
|
data = ["//lib:LICENSE-Apache2.0"],
|
||||||
|
main_class = "NotImportant",
|
||||||
|
runtime_deps = [
|
||||||
|
# in case of conflict, we want the implementation of backwards-codecs
|
||||||
|
# first.
|
||||||
"@backward-codecs//jar",
|
"@backward-codecs//jar",
|
||||||
"@lucene-core//jar",
|
"@lucene-core//jar",
|
||||||
],
|
],
|
||||||
data = ["//lib:LICENSE-Apache2.0"],
|
)
|
||||||
|
|
||||||
|
java_import(
|
||||||
|
name = "lucene-core-and-backward-codecs",
|
||||||
|
jars = [
|
||||||
|
":lucene-core-and-backward-codecs-merged_deploy.jar",
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
java_library(
|
java_library(
|
||||||
|
@@ -4,17 +4,9 @@ load(
|
|||||||
"default_java_toolchain",
|
"default_java_toolchain",
|
||||||
)
|
)
|
||||||
load("@rules_java//java:defs.bzl", "java_package_configuration")
|
load("@rules_java//java:defs.bzl", "java_package_configuration")
|
||||||
load("@rules_python//python:defs.bzl", "py_binary")
|
|
||||||
|
|
||||||
exports_files(["nongoogle.bzl"])
|
exports_files(["nongoogle.bzl"])
|
||||||
|
|
||||||
py_binary(
|
|
||||||
name = "merge_jars",
|
|
||||||
srcs = ["merge_jars.py"],
|
|
||||||
main = "merge_jars.py",
|
|
||||||
visibility = ["//visibility:public"],
|
|
||||||
)
|
|
||||||
|
|
||||||
default_java_toolchain(
|
default_java_toolchain(
|
||||||
name = "error_prone_warnings_toolchain",
|
name = "error_prone_warnings_toolchain",
|
||||||
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
|
bootclasspath = ["@bazel_tools//tools/jdk:platformclasspath.jar"],
|
||||||
|
@@ -1,49 +0,0 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# Copyright (C) 2015 The Android Open Source Project
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
import collections
|
|
||||||
import sys
|
|
||||||
import zipfile
|
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
|
||||||
print('usage: %s <out.zip> <in.zip>...' % sys.argv[0], file=sys.stderr)
|
|
||||||
exit(1)
|
|
||||||
|
|
||||||
outfile = sys.argv[1]
|
|
||||||
infiles = sys.argv[2:]
|
|
||||||
seen = set()
|
|
||||||
SERVICES = 'META-INF/services/'
|
|
||||||
|
|
||||||
try:
|
|
||||||
with zipfile.ZipFile(outfile, 'w') as outzip:
|
|
||||||
services = collections.defaultdict(lambda: '')
|
|
||||||
for infile in infiles:
|
|
||||||
with zipfile.ZipFile(infile) as inzip:
|
|
||||||
for info in inzip.infolist():
|
|
||||||
n = info.filename
|
|
||||||
if n in seen:
|
|
||||||
continue
|
|
||||||
elif n.startswith(SERVICES):
|
|
||||||
# Concatenate all provider configuration files.
|
|
||||||
services[n] += inzip.read(n).decode("UTF-8")
|
|
||||||
continue
|
|
||||||
outzip.writestr(info, inzip.read(n))
|
|
||||||
seen.add(n)
|
|
||||||
|
|
||||||
for n, v in list(services.items()):
|
|
||||||
outzip.writestr(n, v)
|
|
||||||
except Exception as err:
|
|
||||||
exit('Failed to merge jars: %s' % err)
|
|
Reference in New Issue
Block a user