2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
12 # This file contains a list of variables that are generally useful in many
13 # scripts. It is meant to be sourced in other scripts so that the variables can
16 MAVEN_OPTIONS="$(echo --show-version \
19 -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn \
20 -Dmaven.repo.local=/tmp/r \
21 -Dorg.ops4j.pax.url.mvn.localRepository=/tmp/r)"
24 # Activates the lftools virtualenv
26 virtualenv --quiet "/tmp/v/lftools"
27 set +u # Ignore unbound variables in activate
28 # shellcheck source=/tmp/v/lftools/bin/activate disable=SC1091
29 source "/tmp/v/lftools/bin/activate"
30 set -u # Restore unbound variable checking
33 # Check maven-metadata.xml for any unexpected timestamp mismatches
34 maven_metadata_validate() {
38 echo "Usage: maven_metadata_validate STAGE_REPO_DIR"
43 mapfile -t files < <(find "$stage_dir" -name maven-metadata.xml | grep SNAPSHOT)
45 for f in "${files[@]}"; do
46 timestamp=$(xmlstarlet sel \
47 -t -v "/metadata/versioning/snapshot/timestamp" "$f")
49 # Scan all snapshot versions but ignore javadoc and source jars
50 mapfile -t ext_timestamps < <(xmlstarlet sel \
51 -t -m "/metadata/versioning/snapshotVersions/snapshotVersion" \
53 --if "classifier='javadoc'" \
55 --elif "classifier='sources'" \
58 -o "extension:" -v extension \
59 -o " value:" -v value \
60 -o " updated:" -v updated \
63 for t in "${ext_timestamps[@]}"; do
64 # Ignore blank timestamps caused by xmlstarlet ignores
65 if [[ -z "$t" ]]; then
70 if [[ $t != *"$timestamp"* ]]; then
71 echo "Metadata $f 'value:$timestamp' mismatch vs '$t'"
74 # Updated is timestamp without the dot character
75 if [[ $t != *"${timestamp//\./}"* ]]; then
76 echo "Metadata $f 'updated:${timestamp//\./}' mismatch vs '$t'"
80 if [[ $timestamp_error != 0 ]]; then
87 if [ $error_detected -ne 0 ]; then
88 echo "ERROR: Mismatches in maven-metadata discovered. Quitting..."