Skip to content

Commit 52cb511

Browse files
committed
Handle relative path for local installation.
1 parent 7831f0a commit 52cb511

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/main/bash/sdkman-install.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ function __sdkman_install_local_version {
8585

8686
mkdir -p "${SDKMAN_CANDIDATES_DIR}/${candidate}"
8787

88+
# handle relative paths
89+
if [[ "$folder" != /* ]]; then
90+
folder="$(pwd)/$folder"
91+
fi
92+
8893
__sdkman_echo_green "Linking ${candidate} ${version} to ${folder}"
8994
ln -s "$folder" "${SDKMAN_CANDIDATES_DIR}/${candidate}/${version}"
9095
__sdkman_echo_green "Done installing!"

src/test/cucumber/local_developement_versions.feature

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ Feature: Local Development Versions
5151
Then I see "Using groovy version 2.1-SNAPSHOT in this shell"
5252
And the candidate "groovy" version "2.1-SNAPSHOT" should be in use
5353

54-
@review
5554
Scenario: Install a local development version from a relative path
5655
Given the candidate "groovy" version "2.1-SNAPSHOT" is not available for download
56+
And I have a local candidate "groovy" version "2.1-SNAPSHOT" at relative path "some/relative/path/to/groovy"
5757
And the system is bootstrapped
58-
When I enter "sdk install groovy 2.1-SNAPSHOT groovy-core/target"
59-
Then I see "Not linking groovy 2.1.-SNAPSHOT. Only absolute paths permitted"
60-
And the candidate "groovy" version "2.1-SNAPSHOT" is not installed
58+
When I enter "sdk install groovy 2.1-SNAPSHOT some/relative/path/to/groovy"
59+
Then I see "Linking groovy 2.1-SNAPSHOT"
60+
And the candidate "groovy" version "2.1-SNAPSHOT" is linked to the relative path "some/relative/path/to/groovy"

src/test/groovy/sdkman/steps/installation_steps.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,21 @@ And(~'^I have a local candidate "([^"]*)" version "([^"]*)" at "([^"]*)"$') { St
5050
prepareCandidateBinFolder directory, candidate, version
5151
}
5252

53+
And(~'^I have a local candidate "([^"]*)" version "([^"]*)" at relative path "([^"]*)"$') { String candidate, String version, String relativePath ->
54+
def fullPath = new File(sdkmanBaseDir.absolutePath, relativePath)
55+
prepareCandidateBinFolder fullPath.absolutePath, candidate, version
56+
}
57+
58+
And(~'^the candidate "([^"]*)" version "([^"]*)" is linked to the relative path "([^"]*)"$') { String candidate, String version, String relativePath ->
59+
def fullPath = new File(sdkmanBaseDir.absolutePath, relativePath)
60+
assertLinkedCandidate(fullPath.absolutePath, candidate, version)
61+
}
62+
5363
And(~'^the candidate "([^"]*)" version "([^"]*)" is linked to "([^"]*)"$') { String candidate, String version, String directory ->
64+
assertLinkedCandidate(directory, candidate, version)
65+
}
66+
67+
def assertLinkedCandidate(String directory, String candidate, String version) {
5468
def fileSystem = FileSystems.default
5569

5670
def versionLocation = "$candidatesDir/$candidate/$version"

0 commit comments

Comments
 (0)