| # 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. | |
| # | |
| # If a dependent library is undergoing active development it must be | |
| # recompiled and the change must be reflected in the Buck build process. For | |
| # example testing Gerrit against changed JGit snapshot version. After building | |
| # JGit library, the artifacts are created in local Maven build directory. | |
| # | |
| # To shorten that workflow and take the installation of the artifacts to the | |
| # local Maven repository and fetching it again from there out of the picture, | |
| # `local_jar()` method is used: | |
| # | |
| # Example: | |
| # | |
| # local_jar( | |
| # name = 'jgit', | |
| # jar = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT.jar', | |
| # src_jar = '/home/<user>/projects/jgit/org.eclipse.jgit/target/org.eclipse.jgit-3.3.0-SNAPSHOT-sources.jar', | |
| # deps = [':ewah'] | |
| # ) | |
| # | |
| def local_jar( | |
| name, | |
| jar, | |
| src_jar = None, | |
| deps = [], | |
| visibility = ['PUBLIC']): | |
| binjar = name + '.jar' | |
| srcjar = name + '-src.jar' | |
| genrule( | |
| name = name + '__local_bin', | |
| cmd = 'ln -s %s $OUT' % jar, | |
| out = binjar) | |
| if src_jar: | |
| genrule( | |
| name = name + '__local_src', | |
| cmd = 'ln -s %s $OUT' % src_jar, | |
| out = srcjar) | |
| prebuilt_jar( | |
| name = name + '_src', | |
| deps = [':' + name + '__local_src'], | |
| binary_jar = genfile(srcjar), | |
| visibility = visibility, | |
| ) | |
| else: | |
| srcjar = None | |
| prebuilt_jar( | |
| name = name, | |
| deps = deps + [':' + name + '__local_bin'], | |
| binary_jar = genfile(binjar), | |
| source_jar = genfile(srcjar) if srcjar else None, | |
| visibility = visibility, | |
| ) |