@@ -87,7 +87,7 @@ error() {
8787}
8888
8989die () {
90- code=" $1 "
90+ local code=" $1 "
9191 shift
9292 error $@
9393 exit " $code "
@@ -204,12 +204,12 @@ groupId() {
204204}
205205
206206artifactId () {
207- result=" ${1#*: } " # strip groupId
207+ local result=" ${1#*: } " # strip groupId
208208 echo " ${result%%:* } "
209209}
210210
211211version () {
212- result=" ${1#*: } " # strip groupId
212+ local result=" ${1#*: } " # strip groupId
213213 case " $result " in
214214 * :* )
215215 result=" ${result#*: } " # strip artifactId
@@ -234,15 +234,15 @@ version() {
234234
235235# Converts the given GAV into a path in the local repository cache.
236236repoPath () {
237- gPath=" $( echo " $( groupId " $1 " ) " | tr :. /) "
238- aPath=" $( artifactId " $1 " ) "
239- vPath=" $( version " $1 " ) "
237+ local gPath=" $( echo " $( groupId " $1 " ) " | tr :. /) "
238+ local aPath=" $( artifactId " $1 " ) "
239+ local vPath=" $( version " $1 " ) "
240240 echo " $repoBase /$gPath /$aPath /$vPath "
241241}
242242
243243# Gets the path to the given GAV's POM file in the local repository cache.
244244pomPath () {
245- pomFile=" $( artifactId " $1 " ) -$( version " $1 " ) .pom"
245+ local pomFile=" $( artifactId " $1 " ) -$( version " $1 " ) .pom"
246246 echo " $( repoPath " $1 " ) /$pomFile "
247247}
248248
@@ -258,14 +258,14 @@ downloadPOM() {
258258
259259# Gets the POM path for the given GAV, ensuring it exists locally.
260260pom () {
261- pomPath=" $( pomPath " $1 " ) "
261+ local pomPath=" $( pomPath " $1 " ) "
262262 test -f " $pomPath " || downloadPOM " $1 "
263263 echo " $pomPath "
264264}
265265
266266# Gets the SCM URL for the given GAV.
267267scmURL () {
268- scmXPath=" //*[local-name()='project']/*[local-name()='scm']/*[local-name()='connection']"
268+ local scmXPath=" //*[local-name()='project']/*[local-name()='scm']/*[local-name()='connection']"
269269 xmllint --xpath " $scmXPath " " $( pom " $1 " ) " | sed -E ' s/.*>scm:git:(.*)<.*/\1/'
270270}
271271
@@ -276,9 +276,9 @@ scmTag() {
276276
277277# Fetches the source code for the given GAV. Returns the directory.
278278retrieveSource () {
279- scmURL=" $( scmURL " $1 " ) "
280- scmTag=" $( scmTag " $1 " ) "
281- dir=" $( groupId " $1 " ) /$( artifactId " $1 " ) "
279+ local scmURL=" $( scmURL " $1 " ) "
280+ local scmTag=" $( scmTag " $1 " ) "
281+ local dir=" $( groupId " $1 " ) /$( artifactId " $1 " ) "
282282 git clone " $scmURL " --branch " $scmTag " --depth 1 " $dir " 2> /dev/null
283283 echo " $dir "
284284}
@@ -290,12 +290,12 @@ deps() {
290290
291291# Checks whether the given GA(V) matches the specified filter pattern.
292292gaMatch () {
293- ga=" $1 "
294- filter=" $2 "
295- g=" $( groupId " $ga " ) "
296- a=" $( artifactId " $ga " ) "
297- fg=" $( groupId " $filter " ) "
298- fa=" $( artifactId " $filter " ) "
293+ local ga=" $1 "
294+ local filter=" $2 "
295+ local g=" $( groupId " $ga " ) "
296+ local a=" $( artifactId " $ga " ) "
297+ local fg=" $( groupId " $filter " ) "
298+ local fa=" $( artifactId " $filter " ) "
299299 test " $fg " = " $g " -o " $fg " = " *" || return
300300 test " $fa " = " $a " -o " $fa " = " *" || return
301301 echo 1
@@ -305,6 +305,7 @@ gaMatch() {
305305isChanged () {
306306 local IFS=" ,"
307307
308+ local change
308309 for change in $changes
309310 do
310311 test " $( gaMatch " $1 " " $change " ) " && echo 1 && return
@@ -319,13 +320,15 @@ isIncluded() {
319320 local IFS=" ,"
320321
321322 # ensure GA is not excluded
323+ local exclude
322324 for exclude in $excludes
323325 do
324326 test " $( gaMatch " $1 " " $exclude " ) " && return
325327 done
326328
327329 # ensure GA is included
328330 test -z " $includes " && echo 1 && return
331+ local include
329332 for include in $includes
330333 do
331334 test " $( gaMatch " $1 " " $include " ) " && echo 1 && return
@@ -349,6 +352,7 @@ generatePOM() {
349352 echo ' <name>Melting Pot</name>' >> pom.xml
350353 echo >> pom.xml
351354 echo ' <modules>' >> pom.xml
355+ local dir
352356 for dir in * /*
353357 do
354358 test -d " $dir " &&
@@ -365,24 +369,25 @@ generatePOM() {
365369meltDown () {
366370 # Fetch the project source code.
367371 debug " $1 : fetching project source"
368- dir=" $( retrieveSource " $1 " ) "
372+ local dir=" $( retrieveSource " $1 " ) "
369373
370374 # Get the project dependencies.
371375 debug " $1 : determining project dependencies"
372376 cd " $dir "
373- deps=" $( deps) "
377+ local deps=" $( deps) "
374378 cd - > /dev/null
375379
376380 args=" -Denforcer.skip"
377381
378382 # Process the dependencies.
379383 debug " $1 : processing project dependencies"
384+ local dep
380385 for dep in $deps
381386 do
382- g=" $( groupId " $dep " ) "
383- a=" $( artifactId " $dep " ) "
384- v=" $( version " $dep " ) "
385- gav=" $g :$a :$v "
387+ local g=" $( groupId " $dep " ) "
388+ local a=" $( artifactId " $dep " ) "
389+ local v=" $( version " $dep " ) "
390+ local gav=" $g :$a :$v "
386391
387392 test -z " $( isChanged " $gav " ) " &&
388393 args=" $args -D$a .version=$v "
@@ -397,10 +402,11 @@ meltDown() {
397402 # Override versions of changed GAVs.
398403 debug " $1 : processing changed components"
399404 local TLS=,
405+ local gav
400406 for gav in $changes
401407 do
402- a=" $( artifactId " $gav " ) "
403- v=" $( version " $gav " ) "
408+ local a=" $( artifactId " $gav " ) "
409+ local v=" $( version " $gav " ) "
404410 args=" $args -D$a .version=$v "
405411 done
406412 unset TLS
0 commit comments