BUCK: deploy plugin api to local and remote maven repos
`buck build api_install` copies the artifacts to the local maven repository. `buck build api_deploy` uploads the artifacts to the remote maven repository. The type of the repo is induced from the Gerrit version name, i. e. * 2.8-SNAPSHOT: snapshot repo * 2.8: release repo Change-Id: I063834bb39311a4d92f5fdbb183f70b1fb8418b6
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
[alias]
|
||||
api = //:api
|
||||
api_deploy = //:api_deploy
|
||||
api_install = //:api_install
|
||||
download = //:download
|
||||
download_sources = //:download_sources
|
||||
gerrit = //:gerrit
|
||||
|
17
BUCK
17
BUCK
@@ -6,19 +6,24 @@ gerrit_war(name = 'firefox', ui = 'ui_firefox')
|
||||
gerrit_war(name = 'withdocs', context = DOCS)
|
||||
gerrit_war(name = 'release', context = DOCS + ['//plugins:core.zip'])
|
||||
|
||||
API_DEPS = [
|
||||
':extension-api',
|
||||
':extension-api-src',
|
||||
':plugin-api',
|
||||
':plugin-api-src',
|
||||
]
|
||||
|
||||
genrule(
|
||||
name = 'api',
|
||||
cmd = '',
|
||||
srcs = [],
|
||||
deps = [
|
||||
':extension-api',
|
||||
':extension-api-src',
|
||||
':plugin-api',
|
||||
':plugin-api-src',
|
||||
],
|
||||
deps = API_DEPS,
|
||||
out = '__fake.api__',
|
||||
)
|
||||
|
||||
maven_install(deps = API_DEPS)
|
||||
maven_deploy(deps = API_DEPS)
|
||||
|
||||
java_binary(name = 'extension-api', deps = [':extension-lib'])
|
||||
java_library(
|
||||
name = 'extension-lib',
|
||||
|
@@ -126,6 +126,21 @@ The output JAR files will be placed in:
|
||||
buck-out/gen/{extension,plugin}-api.jar
|
||||
----
|
||||
|
||||
Install {extension,plugin}-api to the local maven repository:
|
||||
|
||||
----
|
||||
buck build api_install
|
||||
----
|
||||
|
||||
Deploy {extension,plugin}-api to the remote maven repository
|
||||
|
||||
----
|
||||
buck build api_deploy
|
||||
----
|
||||
|
||||
The type of the repo is induced from the Gerrit version name, i.e.
|
||||
* 2.8-SNAPSHOT: shapshot repo
|
||||
* 2.8: release repo
|
||||
|
||||
Plugins
|
||||
~~~~~~~
|
||||
@@ -283,7 +298,9 @@ archetypes to support creating a new plugin, but existing plugins can
|
||||
develop against the API JAR(s) if they are installed into a Maven
|
||||
repository. tools/deploy_api.sh is how we did this for release
|
||||
versions of Gerrit. Something similar probably still be used with BUCK
|
||||
to publish the precompiled JARs.
|
||||
to publish the precompiled JARs. (Note: this is partially done with the
|
||||
target: `buck build api_install`; after issuing this command the new API
|
||||
version can be consumed by Maven driven custom plugins).
|
||||
+
|
||||
The third option is to support a BUCK based plugin build outside of
|
||||
the Gerrit tree. This is harder because there is functionality
|
||||
|
@@ -17,6 +17,13 @@ python_binary(
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
python_binary(
|
||||
name = 'maven_deploy',
|
||||
main = 'maven_deploy.py',
|
||||
deps = [':util'],
|
||||
visibility = ['PUBLIC'],
|
||||
)
|
||||
|
||||
python_library(
|
||||
name = 'util',
|
||||
srcs = ['util.py'],
|
||||
|
@@ -11,6 +11,7 @@
|
||||
# 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.
|
||||
include_defs('//VERSION')
|
||||
|
||||
DOCS = ['//Documentation:html.zip']
|
||||
LIBS = [
|
||||
@@ -77,3 +78,33 @@ def gerrit_war(name, ui = 'ui_optdbg', context = []):
|
||||
'//gerrit-gwtui:' + ui + '.zip',
|
||||
] + context,
|
||||
)
|
||||
|
||||
def maven_deploy(
|
||||
deps
|
||||
):
|
||||
_maven_util('deploy', deps)
|
||||
|
||||
def maven_install(
|
||||
deps
|
||||
):
|
||||
_maven_util(
|
||||
name = 'install',
|
||||
deps = deps)
|
||||
|
||||
def _maven_util(
|
||||
name,
|
||||
deps
|
||||
):
|
||||
cmd = [
|
||||
'${//tools:maven_deploy}',
|
||||
'-a', name,
|
||||
'-v', GERRIT_VER,
|
||||
'-d', '"$DEPS"'
|
||||
]
|
||||
genrule(
|
||||
name = 'api_%s' % name,
|
||||
cmd = ' '.join(cmd),
|
||||
srcs = [],
|
||||
deps = deps + ['//tools:maven_deploy'],
|
||||
out = '__fake.api_%s__' % name
|
||||
)
|
||||
|
92
tools/maven_deploy.py
Normal file
92
tools/maven_deploy.py
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/usr/bin/python
|
||||
# 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.
|
||||
|
||||
from __future__ import print_function
|
||||
from optparse import OptionParser
|
||||
from os.path import exists
|
||||
from sys import stderr
|
||||
from util import check_output
|
||||
|
||||
opts = OptionParser()
|
||||
opts.add_option('-a', help='action (valid actions are: install,deploy)')
|
||||
opts.add_option('-v', help='gerrit version')
|
||||
opts.add_option('-d', help='dependencies (jars artifacts)')
|
||||
|
||||
args, ctx = opts.parse_args()
|
||||
action = args.a
|
||||
if action not in ['deploy', 'install']:
|
||||
print("unknown action : %s" % action, file=stderr)
|
||||
exit(1)
|
||||
|
||||
deps = args.d.split()
|
||||
if not deps:
|
||||
print('dependencies are empty')
|
||||
exit(1)
|
||||
|
||||
extension_jar = [x for x in deps if "extension-api.jar" in x][0]
|
||||
extension_src = [x for x in deps if "extension-api-src.jar" in x][0]
|
||||
plugin_jar = [x for x in deps if "plugin-api.jar" in x][0]
|
||||
plugin_src = [x for x in deps if "plugin-api-src.jar" in x][0]
|
||||
|
||||
version = args.v
|
||||
if not version:
|
||||
print('version is empty')
|
||||
exit(1)
|
||||
|
||||
REPO_TYPE = 'snapshot' if version.endswith("SNAPSHOT") else 'release'
|
||||
URL = 's3://gerrit-api@commondatastorage.googleapis.com/%s' % REPO_TYPE
|
||||
|
||||
plugin = ['-DartifactId=gerrit-plugin-api']
|
||||
extension = ['-DartifactId=gerrit-extension-api']
|
||||
common = [
|
||||
'-DgroupId=com.google.gerrit',
|
||||
'-Dversion=%s' % version,
|
||||
]
|
||||
jar = ['-Dpackaging=jar']
|
||||
src = ['-Dpackaging=java-source']
|
||||
|
||||
cmd = {
|
||||
'deploy': ['mvn',
|
||||
'deploy:deploy-file',
|
||||
'-DrepositoryId=gerrit-api-repository',
|
||||
'-Durl=%s' % URL],
|
||||
'install': ['mvn',
|
||||
'install:install-file'],
|
||||
}
|
||||
|
||||
try:
|
||||
check_output(cmd[action] +
|
||||
plugin +
|
||||
common +
|
||||
jar +
|
||||
['-Dfile=%s' % plugin_jar])
|
||||
check_output(cmd[action] +
|
||||
plugin +
|
||||
common +
|
||||
src +
|
||||
['-Dfile=%s' % plugin_src])
|
||||
check_output(cmd[action] +
|
||||
extension +
|
||||
common +
|
||||
jar +
|
||||
['-Dfile=%s' % extension_jar])
|
||||
check_output(cmd[action] +
|
||||
extension +
|
||||
common +
|
||||
src +
|
||||
['-Dfile=%s' % extension_src])
|
||||
except Exception as e:
|
||||
print('%s command failed: %s' % (action, e), file=stderr)
|
||||
exit(1)
|
Reference in New Issue
Block a user