|
70 | 70 | # Author: Curtis Rueden |
71 | 71 | # ============================================================================ |
72 | 72 |
|
| 73 | +# -- Constants -- |
| 74 | + |
| 75 | +meltingPotCache="$HOME/.scijava/melting-pot" |
| 76 | + |
73 | 77 | # -- Functions -- |
74 | 78 |
|
75 | 79 | stderr() { >&2 echo "$@"; } |
@@ -423,18 +427,31 @@ retrieveSource() { |
423 | 427 | test "$scmURL" || die "Cannot glean SCM URL for $1" 10 |
424 | 428 | local scmBranch |
425 | 429 | test "$2" && scmBranch="$2" || scmBranch="$(scmTag "$1")" |
426 | | - local dir="$(groupId "$1")/$(artifactId "$1")" |
427 | | - debug "git clone \"$scmURL\" --branch \"$scmBranch\" --depth 1 \"$dir\"" |
428 | | - git clone "$scmURL" --branch "$scmBranch" --depth 1 "$dir" 2> /dev/null || |
429 | | - die "Could not fetch project source for $1" 3 |
| 430 | + local g=$(groupId "$1") |
| 431 | + local a=$(artifactId "$1") |
| 432 | + local v=$(version "$1") |
| 433 | + local sourceDir="$meltingPotCache/$g/$a/$v" |
| 434 | + if [ -d "$sourceDir" ] |
| 435 | + then |
| 436 | + debug "Using previously fetched project source at $sourceDir" |
| 437 | + else |
| 438 | + # Source has never been fetched before. Save it into ~/.scijava/melting-pot. |
| 439 | + debug "git clone \"$scmURL\" --branch \"$scmBranch\" --depth 1 \"$sourceDir\"" |
| 440 | + git clone "$scmURL" --branch "$scmBranch" --depth 1 "$sourceDir" 2> /dev/null || |
| 441 | + die "Could not fetch project source for $1" 3 |
| 442 | + fi |
| 443 | + # Copy the pristine cached source directory into the melting-pot structure. |
| 444 | + local destDir="$g/$a" |
| 445 | + mkdir -p "$(dirname "$destDir")" |
| 446 | + cp -rp "$sourceDir" "$destDir" |
430 | 447 |
|
431 | 448 | # Now verify that the cloned pom.xml contains the expected version! |
432 | 449 | local expectedVersion=$(version "$1") |
433 | | - local actualVersion=$(xpath "$dir/pom.xml" project version) |
| 450 | + local actualVersion=$(xpath "$destDir/pom.xml" project version) |
434 | 451 | test "$expectedVersion" = "$actualVersion" || |
435 | 452 | die "POM for $1 contains wrong version: $actualVersion" 14 |
436 | 453 |
|
437 | | - echo "$dir" |
| 454 | + echo "$destDir" |
438 | 455 | } |
439 | 456 |
|
440 | 457 | # Gets the list of dependencies for the project in the CWD. |
|
0 commit comments