|
| 1 | +#!/bin/bash |
| 2 | +# Copyright 2020 Google LLC |
| 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 | +set -eo pipefail |
| 17 | + |
| 18 | +## Get the directory of the build script |
| 19 | +scriptDir=$(realpath $(dirname "${BASH_SOURCE[0]}")) |
| 20 | +function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } |
| 21 | +function msg() { println "$*" >&2; } |
| 22 | +function println() { printf '%s\n' "$(now) $*"; } |
| 23 | + |
| 24 | +function cleanup() { |
| 25 | + rm .org-list.txt .new-list.txt .diff.txt |
| 26 | +} |
| 27 | + |
| 28 | +## cd to the parent directory, i.e. the root of the git repo |
| 29 | +cd ${scriptDir}/.. |
| 30 | + |
| 31 | +## Locally install artifacts |
| 32 | +#mvn verify -DskipTests |
| 33 | + |
| 34 | +## Find client directory that continas flattened pom and cd into it |
| 35 | +clientDir=$(find -iname ".flattened-pom.xml" | cut -d"/" -f1-2) |
| 36 | +cd "$clientDir" |
| 37 | + |
| 38 | +## Run dependency list completeness check |
| 39 | + |
| 40 | +# Output dep list with compile scope generated using the original pom |
| 41 | +msg "Generating dependency list using original pom..." |
| 42 | +mvn dependency:list -f pom.xml -Dsort=true | grep '\[INFO] .*:.*:.*:.*:compile' >.org-list.txt |
| 43 | + |
| 44 | +# Output dep list with compile scope generated using the flattened pom |
| 45 | +msg "Generating dependency list using flattened pom..." |
| 46 | +mvn dependency:list -f .flattened-pom.xml -Dsort=true | grep '\[INFO] .*:.*:.*:.*:compile' >.new-list.txt |
| 47 | + |
| 48 | +# Compare two dependency lists |
| 49 | +msg "Comparing dependency lists..." |
| 50 | +diff .org-list.txt .new-list.txt >.diff.txt && (msg "Success. No diff!" && cleanup) || (msg "Diff found: " && cat .diff.txt) |
0 commit comments