81dddc3bf8
Generated shell scripts for maven use a typical bash if syntax which is not recognised by sh. As a result the execution was failing on Gerrit CI. (see [1]) Use bash as script interpreter to assure the correct execution of the if statement. [1]: https://goo.gl/3T5w5u Change-Id: Id713a24d9cd6df145790769d014de6a66e64dace
96 lines
2.8 KiB
Plaintext
96 lines
2.8 KiB
Plaintext
# Copyright (C) 2013 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.
|
|
|
|
sh_bang_template = (' && '.join([
|
|
"echo '#!/bin/bash -eu' > $OUT",
|
|
'echo "# this script should run from the root of your workspace." >> $OUT',
|
|
'echo "" >> $OUT',
|
|
"echo 'if [[ -n \"$${VERBOSE:-}\" ]]; then set -x ; fi' >> $OUT",
|
|
'echo "" >> $OUT',
|
|
'echo %s >> $OUT',
|
|
'echo "" >> $OUT',
|
|
'echo %s >> $OUT',
|
|
# This is supposed to be handled by executable=True, but it doesn't
|
|
# work. Bug?
|
|
'chmod +x $OUT' ]))
|
|
|
|
def maven_package(
|
|
version,
|
|
repository = None,
|
|
url = None,
|
|
jar = {},
|
|
src = {},
|
|
doc = {},
|
|
war = {}):
|
|
|
|
build_cmd = ['buck', 'build']
|
|
|
|
# This is not using python_binary() to avoid the baggage and bugs
|
|
# that PEX brings along.
|
|
mvn_cmd = ['python', 'tools/maven/mvn.py', '-v', version]
|
|
api_cmd = mvn_cmd[:]
|
|
api_targets = []
|
|
for type,d in [('jar', jar), ('java-source', src), ('javadoc', doc)]:
|
|
for a,t in sorted(d.iteritems()):
|
|
api_cmd.append('-s %s:%s:$(location %s)' % (a,type,t))
|
|
api_targets.append(t)
|
|
|
|
genrule(
|
|
name = 'gen_api_install',
|
|
cmd = sh_bang_template % (
|
|
' '.join(build_cmd + api_targets),
|
|
' '.join(api_cmd + ['-a', 'install'])),
|
|
out = 'api_install.sh',
|
|
executable = True,
|
|
)
|
|
|
|
if repository and url:
|
|
genrule(
|
|
name = 'gen_api_deploy',
|
|
cmd = sh_bang_template % (
|
|
' '.join(build_cmd + api_targets),
|
|
' '.join(api_cmd + ['-a', 'deploy',
|
|
'--repository', repository,
|
|
'--url', url])),
|
|
out = 'api_deploy.sh',
|
|
executable = True,
|
|
)
|
|
|
|
war_cmd = mvn_cmd[:]
|
|
war_targets = []
|
|
for a,t in sorted(war.iteritems()):
|
|
war_cmd.append('-s %s:war:$(location %s)' % (a,t))
|
|
war_targets.append(t)
|
|
|
|
genrule(
|
|
name = 'gen_war_install',
|
|
cmd = sh_bang_template % (' '.join(build_cmd + war_targets),
|
|
' '.join(war_cmd + ['-a', 'install'])),
|
|
out = 'war_install.sh',
|
|
executable = True,
|
|
)
|
|
|
|
if repository and url:
|
|
genrule(
|
|
name = 'gen_war_deploy',
|
|
cmd = sh_bang_template % (
|
|
' '.join(build_cmd + war_targets),
|
|
' '.join(war_cmd + [
|
|
'-a', 'deploy',
|
|
'--repository', repository,
|
|
'--url', url])),
|
|
out = 'war_deploy.sh',
|
|
executable = True,
|
|
)
|