-
-
Notifications
You must be signed in to change notification settings - Fork 637
Add Homebrew support #1042
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Add Homebrew support #1042
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2ee5704
Add Homebrew formula template
f4f40bb
Remove unused templates
b8fcf68
Remove comment
239afe8
Add brew packager
732b1b0
Remove selfupdate functionality when installed via Homebrew
e18fccd
Add config flag for disabling selfupdates
36ba344
Keep support for sdkman_selfupdate_enable for backwards-compatibilty
d5be30b
Add tests for sdkman_selfupdate_feature
9503c62
Add more tests
a326899
Enable sdkman_selfupdate_feature by default
3b54af3
Do not enable sdkman_selfupdate_feature by default
66d42b0
Set sdkman_selfupdate_feature to true in SdkmanBashEnvBuilder's confi…
3b2661a
Configure JRELEASER_HOMEBREW_GITHUB_TOKEN
b457505
Order configuration alphabetically
e68f6bd
Merge remote-tracking branch 'upstream/master' into homebrew-publication
feaa133
Remove unneeded check
276ab0e
Exclude selfupdate_enable flag from SelfupdateSpec
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # SDKMAN! Homebrew Tap | ||
|
|
||
| A Homebrew tap containing the Formula for the SDKMAN! CLI. | ||
|
|
||
| ## Installation | ||
|
|
||
| ```sh | ||
| $ brew tap sdkman/tap | ||
| $ brew install sdkman | ||
| ``` | ||
|
|
||
| After successful installation add the following lines to the end of your `.bash_profile` | ||
|
|
||
| ```sh | ||
| export SDKMAN_DIR=$(brew --prefix sdkman)/libexec | ||
| [[ -s "${SDKMAN_DIR}/bin/sdkman-init.sh" ]] && source "${SDKMAN_DIR}/bin/sdkman-init.sh" | ||
| ``` | ||
|
|
||
| Open a new terminal and type | ||
|
|
||
| ```sh | ||
| sdk version | ||
| ``` | ||
|
|
||
| The output should look similar to this | ||
|
|
||
| ```sh | ||
| SDKMAN {{version}} | ||
| ``` |
35 changes: 35 additions & 0 deletions
35
src/jreleaser/distributions/sdkman-cli/brew/formula.rb.tpl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| class {{brewFormulaName}} < Formula | ||
| desc "{{projectDescription}}" | ||
| homepage "{{projectWebsite}}" | ||
| url "{{distributionUrl}}" | ||
| version "{{projectVersion}}" | ||
| sha256 "{{distributionChecksumSha256}}" | ||
| license "{{projectLicense}}" | ||
|
|
||
| def install | ||
| libexec.install Dir["*"] | ||
|
|
||
| %w[tmp ext etc var archives candidates].each { |dir| mkdir libexec/dir } | ||
|
|
||
| system "curl", "-s", "https://api.sdkman.io/2/candidates/all", "-o", libexec/"var/candidates" | ||
|
|
||
| (libexec/"etc/config").write <<~EOS | ||
| sdkman_auto_answer=false | ||
| sdkman_auto_complete=true | ||
| sdkman_auto_env=false | ||
| sdkman_auto_update=false | ||
| sdkman_beta_channel=false | ||
| sdkman_colour_enable=true | ||
| sdkman_curl_connect_timeout=7 | ||
| sdkman_curl_max_time=10 | ||
| sdkman_debug_mode=false | ||
| sdkman_insecure_ssl=false | ||
| sdkman_rosetta2_compatible=false | ||
| sdkman_selfupdate_feature=false | ||
| EOS | ||
| end | ||
|
|
||
| test do | ||
| assert_match {{projectVersion}}, shell_output("export SDKMAN_DIR=#{libexec} && source #{libexec}/bin/sdkman-init.sh && sdk version") | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| package sdkman.specs | ||
|
|
||
| import sdkman.support.SdkmanEnvSpecification | ||
|
|
||
| import java.time.Instant | ||
|
|
||
| import static java.time.temporal.ChronoUnit.DAYS | ||
|
|
||
| class SelfupdateSpec extends SdkmanEnvSpecification { | ||
| static final String CANDIDATES_API = "http://localhost:8080/2" | ||
| static final String BROADCAST_API_LATEST_ID_ENDPOINT = "$CANDIDATES_API/broadcast/latest/id" | ||
| static final String VERSION_ENDPOINT = "$CANDIDATES_API/broker/download/sdkman/version/stable" | ||
|
|
||
| def setup() { | ||
| curlStub.primeWith(BROADCAST_API_LATEST_ID_ENDPOINT, "echo dbfb025be9f97fda2052b5febcca0155") | ||
| curlStub.primeWith(VERSION_ENDPOINT, "echo 5.0.0") | ||
| } | ||
|
|
||
| def "should list selfupdate as a valid command when the selfupdate feature is toggled on"() { | ||
| given: | ||
| bash = sdkmanBashEnvBuilder | ||
| .withConfiguration("sdkman_selfupdate_feature", selfUpdateFeature) | ||
| .build() | ||
|
|
||
| bash.start() | ||
| bash.execute("source $bootstrapScript") | ||
|
|
||
| when: | ||
| bash.execute("sdk help") | ||
|
|
||
| then: | ||
| verifyOutput(bash.output) | ||
|
|
||
| where: | ||
| selfUpdateFeature | verifyOutput | ||
| "false" | { !it.contains("selfupdate") } | ||
| "true" | { it.contains("selfupdate") } | ||
| } | ||
|
|
||
| def "should source sdkman-selfupdate.sh when the selfupdate feature is toggled on"() { | ||
| given: | ||
| bash = sdkmanBashEnvBuilder | ||
| .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) | ||
| .build() | ||
|
|
||
| bash.start() | ||
| bash.execute("source $bootstrapScript") | ||
|
|
||
| when: | ||
| bash.execute("sdk selfupdate") | ||
|
|
||
| then: | ||
| verifyOutput(bash.output) | ||
|
|
||
| where: | ||
| selfupdateFeature | verifyOutput | ||
| "false" | { it.contains("Invalid command: selfupdate") } | ||
| "true" | { it.contains("No update available at this time.") } | ||
| } | ||
|
|
||
| def "should perform an autoupdate when the selfupdate feature is toggled on and autoupdate is enabled"() { | ||
| given: | ||
| new File("$sdkmanDotDirectory/var/delay_upgrade").with { | ||
| parentFile.mkdirs() | ||
| createNewFile() | ||
| lastModified = Instant.now().minus(2, DAYS).toEpochMilli() | ||
| } | ||
|
|
||
| bash = sdkmanBashEnvBuilder | ||
| .withSdkmanVersion("4.0.0") | ||
| .withConfiguration("sdkman_selfupdate_feature", selfupdateFeature) | ||
| .withConfiguration("sdkman_auto_update", autoUpdateEnabled) | ||
| .withConfiguration("sdkman_auto_answer", "true") | ||
| .build() | ||
|
|
||
| bash.start() | ||
| bash.execute("source $bootstrapScript") | ||
|
|
||
| when: | ||
| bash.execute("sdk version") | ||
|
|
||
| then: | ||
| verifyOutput(bash.output) | ||
|
|
||
| where: | ||
| selfupdateFeature | autoUpdateEnabled | verifyOutput | ||
| "true" | "true" | { it.contains("ATTENTION: A new version of SDKMAN is available...") } | ||
| "true" | "false" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } | ||
| "false" | "true" | { !it.contains("ATTENTION: A new version of SDKMAN is available...") } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.