blob: 3ea506c8069561b1041773d25d1b6a4a0a6adb3e [file] [log] [blame]
Ray Milkeyf80bbb22016-03-11 10:16:22 -08001# Copyright (C) 2013 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15# These definitions support building a runnable version of Gerrit.
16
17DOCS_HTML = '//Documentation:html'
18DOCS_LIB = '//Documentation:index_lib'
19LIBS = [
20 '//gerrit-war:log4j-config',
21 '//gerrit-war:init',
22 '//lib:postgresql',
23 '//lib/log:impl_log4j',
24]
25PGMLIBS = ['//gerrit-pgm:pgm']
26
27def scan_plugins():
28 import os
29 deps = []
30 for n in os.listdir('plugins'):
31 if os.path.exists(os.path.join('plugins', n, 'BUCK')):
32 deps.append('//plugins/%s:%s__plugin' % (n, n))
33 return deps
34
35def war(
36 name,
37 libs = [],
38 pgmlibs = [],
39 context = [],
40 visibility = [],
41 docs = False
42 ):
43 cmd = ['$(exe //tools:pack_war)', '-o', '$OUT', '--tmp', '$TMP']
44 for l in libs:
45 cmd.extend(['--lib', '$(classpath %s)' % l])
46 for l in pgmlibs:
47 cmd.extend(['--pgmlib', '$(classpath %s)' % l])
48
49 if docs:
50 cmd.append('$(location %s)' % DOCS_HTML)
51 cmd.extend(['--lib', '$(classpath %s)' % DOCS_LIB])
52 if context:
53 for t in context:
54 cmd.append('$(location %s)' % t)
55
56 genrule(
57 name = name,
58 cmd = ' '.join(cmd),
59 out = name + '.war',
60 visibility = visibility,
61 )
62
63def gerrit_war(name, ui = 'ui_optdbg', context = [], docs = False, visibility = []):
64 ui_deps = []
65 if ui:
66 if ui == 'polygerrit' or ui == 'ui_optdbg' or ui == 'ui_optdbg_r':
67 ui_deps.append('//polygerrit-ui/app:polygerrit_ui')
68 if ui != 'polygerrit':
69 ui_deps.append('//gerrit-gwtui:%s' % ui)
70 war(
71 name = name,
72 libs = LIBS + ['//gerrit-war:version'],
73 pgmlibs = PGMLIBS,
74 context = ui_deps + context + [
75 '//gerrit-main:main_bin',
76 '//gerrit-war:webapp_assets',
77 ],
78 docs = docs,
79 visibility = visibility,
80 )