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 # Uses wget to fetch a project's maven-metadata.xml files from a Maven repository.
14 # Check for "-f" maven param, indicating a change in pom location.
16 file_path=$(echo $MAVEN_PARAMS | grep -E "\-f \S+" | awk '{ print $2 }')
17 if [ ! -z $file_path ]; then
18 pom_path="$file_path/pom.xml"
21 # Ensure we fail the job if any steps fail.
24 project=$(xmlstarlet sel \
25 -N "x=http://maven.apache.org/POM/4.0.0" -t \
26 --if "/x:project/x:groupId" \
27 -v "/x:project/x:groupId" \
28 --elif "/x:project/x:parent/x:groupId" \
29 -v "/x:project/x:parent/x:groupId" \
30 --else -o "" $pom_path)
31 project_path="${project//.//}"
33 mkdir -p "$WORKSPACE/m2repo/$project_path"
34 pushd "$WORKSPACE/m2repo/$project_path"
35 # Temporarily disable failing for wget
36 # If 404 happens we don't care because it might be a new project.
38 wget -nv --recursive \
39 --accept maven-metadata.xml \
41 --execute robots=off \
43 --no-host-directories \
44 --cut-dirs="$NEXUS_CUT_DIRS" \
45 "$NEXUS_URL/content/repositories/$NEXUS_REPO/$project_path/"
49 # Backup metadata - Used later to find metadata files that have not been modified
50 mkdir -p "$WORKSPACE/m2repo-backup"
51 cp -a "$WORKSPACE/m2repo/"* "$WORKSPACE/m2repo-backup"