Sean Condon | 6a2e8fa | 2018-01-17 17:04:40 +0000 | [diff] [blame] | 1 | # |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | # |
| 16 | # Bucklet to create Java Code from XSD using the 'xjc' tool from the JAXB API v2. |
| 17 | # The genrule() creates the Java code, zips it and puts it in the output of jaxb2-xjc |
| 18 | # The osgi_jar_with_tests() takes the sources in this ZIP and adds them to what ever |
| 19 | # sources were used in the call to this method, and compiles all of them and adds |
| 20 | # them to a JAR file in the output folder |
| 21 | |
| 22 | include_defs('//onos.defs') |
| 23 | include_defs('//bucklets/onos.bucklet') |
| 24 | |
| 25 | def _get_name(): |
| 26 | base_path = get_base_path() |
| 27 | return ONOS_ARTIFACT_BASE + base_path.replace('/', '-') #TODO Unix-separator |
| 28 | |
| 29 | def jaxb2_xjc_osgi_jar( |
| 30 | name, |
| 31 | srcs, |
| 32 | xsd, |
| 33 | bindinfo=None, |
| 34 | destdir='.', |
| 35 | deps=[], |
| 36 | test_deps=[], |
| 37 | visibility = [], |
| 38 | **kwargs |
| 39 | ): |
| 40 | if name is None: |
| 41 | name = _get_name() |
| 42 | |
| 43 | cmd = 'xjc '+xsd |
| 44 | if bindinfo is not None: |
| 45 | cmd=cmd+' -b '+bindinfo |
| 46 | cmd=cmd+' -d '+destdir |
| 47 | |
| 48 | genrule( |
| 49 | name = 'jaxb2-xjc', |
| 50 | srcs = glob(['src/main/resources/*.xsd','src/main/resources/*.xjb']), |
| 51 | bash = cmd + ' && zip $OUT -r *', |
| 52 | out = name+'.src.zip', |
| 53 | visibility = [ ], |
| 54 | ) |
| 55 | |
| 56 | osgi_jar_with_tests ( |
| 57 | deps = [":jaxb2-xjc"] + deps, |
| 58 | srcs = [':jaxb2-xjc'] + srcs, |
| 59 | test_deps = test_deps, |
| 60 | do_javadocs = False, |
| 61 | do_checkstyle = False, |
| 62 | **kwargs |
| 63 | ) |
| 64 | |