#!/bin/sh # Copyright © 2017 Red Hat, Inc. and others. # # This program and the accompanying materials are made available under the # terms of the Eclipse Public License v1.0 which accompanies this distribution, # and is available at http://www.eclipse.org/legal/epl-v10.html xmlstarlet sel -N "maven=http://maven.apache.org/POM/4.0.0" -t \ -m "maven:project/maven:dependencyManagement/maven:dependencies/maven:dependency" \ -v maven:groupId -o " " -v maven:artifactId -o " classifier=" -v maven:classifier -o " type=" -v maven:type \ -o " scope=" -v maven:scope -o " version=" -v maven:version -n \ ../odlparent/pom.xml | sort | awk ' BEGIN { predeps = 1 } FNR == NR && predeps && // { print predeps = 0 } FNR == NR && !predeps && /<\/dependencies>/ { postdeps=1 } FNR == NR && predeps FNR == NR && postdeps { footer=footer "\n" $0 } FNR < NR && !/org.opendaylight/ { printf " \n" printf " %s\n", $1 printf " %s\n", $2 needversion = 0 for (i = 3; i <= NF; i++) { equalidx = index($i, "=") if (equalidx != length($i)) { element = substr($i, 1, equalidx - 1) value = substr($i, equalidx + 1) if (element == "scope") { if (value == "import") { # Scope import dependencies need to have their version mentioned explicitly needversion = 1 } } else if (element != "version" || needversion) { printf " <%s>%s\n", element, value, element } } } printf " \n" } END { print footer } ' pom.xml - > pom.xml.new mv pom.xml.new pom.xml