11class Astra < Formula
22 desc "Command-Line Interface for DataStax Astra"
33 homepage "https://docs.datastax.com/en/astra-cli"
4- url "https://github.com/datastax/astra-cli/releases/download/ v1.0.4/astra-fat.jar "
5- sha256 "21ba898598da0ed3b57d209eea2ce18df2367f53a4b2cb549d8bb7db08cc2294 "
4+ url "https://github.com/datastax/astra-cli/archive/refs/tags/ v1.0.4.tar.gz "
5+ sha256 "809f60778dd0cab7e96642712d71d579ac0b856ed8da0abaf0970c5df23f23cb "
66 license "Apache-2.0"
77
88 bottle do
@@ -14,23 +14,73 @@ class Astra < Formula
1414 sha256 cellar : :any_skip_relocation , x86_64_linux : "4a119bcef3ab863320bd967812e1c4c9d88a6c73360143ef65447558ff82ea69"
1515 end
1616
17- depends_on "openjdk"
17+ depends_on "graalvm" => :build
18+ depends_on "gradle" => :build
19+
20+ on_linux do
21+ depends_on "zlib-ng-compat"
22+ end
1823
1924 def install
20- libexec . install "astra-fat.jar"
25+ ENV [ "JAVA_HOME" ] = if OS . mac?
26+ Formula [ "graalvm" ] . opt_libexec /"graalvm.jdk/Contents/Home"
27+ else
28+ Formula [ "graalvm" ] . opt_libexec
29+ end
30+
31+ brew_envs = %w[
32+ HOMEBREW_RUBY_PATH
33+ HOMEBREW_LD_LIBRARY_PATH
34+ HOMEBREW_CCCFG
35+ HOMEBREW_PREFIX
36+ HOMEBREW_CELLAR
37+ HOMEBREW_CACHE
38+ HOMEBREW_OPT
39+ HOMEBREW_TEMP
40+ HOMEBREW_SDKROOT
41+ HOMEBREW_ARCHFLAGS
42+ HOMEBREW_OPTFLAGS
43+ HOMEBREW_DEPENDENCIES
44+ HOMEBREW_FORMULA_PREFIX
45+ HOMEBREW_FORMULA_BUILDPATH
46+ HOMEBREW_CC
47+ HOMEBREW_OPTIMIZATION_LEVEL
48+ HOMEBREW_LIBRARY
49+ HOMEBREW_ISYSTEM_PATHS
50+ HOMEBREW_INCLUDE_PATHS
51+ HOMEBREW_LIBRARY_PATHS
52+ HOMEBREW_RPATH_PATHS
53+ HOMEBREW_DYNAMIC_LINKER
54+ HOMEBREW_CC_LOG_PATH
55+ HOMEBREW_GIT
56+ HOMEBREW_SVN
57+ HOMEBREW_CURL
58+ HOMEBREW_FORCE_BREWED_CURL
59+ HOMEBREW_MAKE_JOBS
60+ ]
61+
62+ if OS . mac?
63+ brew_envs += %w[
64+ HOMEBREW_DEVELOPER_DIR
65+ HOMEBREW_PREFER_CLT_PROXIES
66+ ]
67+ end
68+
69+ native_image_env = brew_envs . map { |key | "-E#{ key } " }
70+ ENV . prepend "NATIVE_IMAGE_OPTIONS" , native_image_env . join ( " " )
2171
22- ( bin /"astra" ) . write_env_script Formula [ "openjdk" ] . opt_bin /"java" ,
23- "--enable-native-access=ALL-UNNAMED -Dcli.via-brew -jar #{ libexec } /astra-fat.jar" ,
24- JAVA_HOME : Formula [ "openjdk" ] . opt_prefix
72+ ( buildpath /"src/main/resources/static.properties" ) . append_lines "cli.via-brew=true"
73+ system "gradle" , "nativeCompile" , "-Pprod" , "--exclude-task" , "test" , "--no-daemon"
2574
26- chmod "+x" , bin / " astra"
75+ bin . install "build/native/nativeCompile/ astra"
2776
2877 generate_completions_from_executable bin /"astra" , "compgen" , shell_parameter_format : :none , shells : [ :bash , :zsh ]
2978 end
3079
3180 test do
3281 ENV [ "ASTRARC" ] = "/a/b/c"
33- assert_equal "/a/b/c" ,
82+ # ENV["ASTRA_HOME"] = testpath
83+ assert_equal "/a/b/cc" ,
3484 shell_output ( "#{ bin } /astra config path -p" ) . strip
3585
3686 ENV [ "ASTRARC" ] = "/x/y/z"
0 commit comments