Skip to content

Commit

Permalink
feat: added graalvm support (#13)
Browse files Browse the repository at this point in the history
* added graalvm support

* macos fix for graalvm

* patch upgrade

---------

Co-authored-by: Anusikh Panda <anusikh.panda@autodesk.com>
  • Loading branch information
anusikh and Anusikh Panda authored Apr 29, 2024
1 parent 2e2d0ed commit e429804
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "jvem"
version = "0.2.1"
version = "0.2.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand Down
19 changes: 14 additions & 5 deletions src/commands/usev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,17 +86,26 @@ pub async fn usev_util(name: String) {

#[cfg(target_os = "macos")]
pub async fn usev_util(name: String) {
use crate::utils::file_utils::check_path_exists;

let _ = run_command("rm", vec!["-rf", &format!("{}/.jvem/java", get_home_dir())]);

// check if Contents folder present inside extracted files (required for Graal VM support)
let con_path = format!("{}/Contents", get_installation_dir(&name));
let if_contents_exists = check_path_exists(&con_path);
let final_path;

if if_contents_exists == true {
final_path = format!("{}/Contents/Home", get_installation_dir(&name));
} else {
final_path = format!("{}/Home", get_installation_dir(&name));
};

let output = run_command(
"sh",
vec![
"-c",
&format!(
"ln -s {} {}/.jvem/java",
format!("{}/Contents/Home", get_installation_dir(&name)),
get_home_dir()
),
&format!("ln -s {} {}/.jvem/java", final_path, get_home_dir()),
],
);

Expand Down
56 changes: 50 additions & 6 deletions src/constants/versions.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
pub mod constants {
pub const LINUX_ARTIFACT: &str = "jvem.tar.gz";
pub const WINDOWS_ARTIFACT: &str = "jvem.zip";
pub const AVAILABLE_VERSIONS: &str = "ZULU8,ZULU11,ZULU17,ZULU21,OPENJDK11,OPENJDK17,OPENJDK21";

pub const AVAILABLE_VERSIONS: &str =
"ZULU8,ZULU11,ZULU17,ZULU21,OPENJDK11,OPENJDK17,OPENJDK21,GRAAL17,GRAAL21,GRAAL22";

// zulu jdk's
pub const ZULU21_LINUX: &str =
"https://cdn.azul.com/zulu/bin/zulu21.32.17-ca-jdk21.0.2-linux_x64.tar.gz";
Expand All @@ -24,7 +25,7 @@ pub mod constants {
pub const ZULU8_WINDOWS: &str ="https://cdn.azul.com/zulu/bin/zulu8.76.0.17-ca-jdk8.0.402-win_x64.zip?_gl=1*i45ppb*_ga*MTg0NTAyMjU0LjE3MDg3MDUwMzU.*_ga_42DEGWGYD5*MTcwODcwNTAzNS4xLjEuMTcwODcwNTIxMy4xNy4wLjA.";
pub const ZULU8_MACOS_AARCH64: &str = "https://cdn.azul.com/zulu/bin/zulu8.76.0.17-ca-jdk8.0.402-macosx_aarch64.tar.gz?_gl=1*18knssl*_ga*MTU1MDc4NTgxMS4xNzA5NzU3MDc2*_ga_42DEGWGYD5*MTcwOTc1NzA3NS4xLjEuMTcwOTc1ODA1MS41MC4wLjA.";
pub const ZULU8_MACOS_X86_64: &str = "https://cdn.azul.com/zulu/bin/zulu8.76.0.17-ca-jdk8.0.402-macosx_x64.tar.gz?_gl=1*18knssl*_ga*MTU1MDc4NTgxMS4xNzA5NzU3MDc2*_ga_42DEGWGYD5*MTcwOTc1NzA3NS4xLjEuMTcwOTc1ODA1MS41MC4wLjA.";

// openjdk jdk's
pub const OPENJDK21_LINUX: &str = "https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_linux-x64_bin.tar.gz";
pub const OPENJDK21_WINDOWS: &str = "https://download.java.net/java/GA/jdk21.0.2/f2283984656d49d69e91c558476027ac/13/GPL/openjdk-21.0.2_windows-x64_bin.zip";
Expand All @@ -34,9 +35,38 @@ pub mod constants {
pub const OPENJDK17_WINDOWS: &str = "https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_windows-x64_bin.zip";
pub const OPENJDK17_MACOS_AARCH64: &str = "https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_macos-aarch64_bin.tar.gz";
pub const OPENJDK17_MACOS_X86_64: &str = "https://download.java.net/java/GA/jdk17.0.1/2a2082e5a09d4267845be086888add4f/12/GPL/openjdk-17.0.1_macos-x64_bin.tar.gz";
pub const OPENJDK11_LINUX: &str = "https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz";
pub const OPENJDK11_WINDOWS: &str = "https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_windows-x64_bin.zip";
pub const OPENJDK11_MACOS_X86_64: &str = "https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz";
pub const OPENJDK11_LINUX: &str =
"https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_linux-x64_bin.tar.gz";
pub const OPENJDK11_WINDOWS: &str =
"https://download.java.net/java/GA/jdk11/13/GPL/openjdk-11.0.1_windows-x64_bin.zip";
pub const OPENJDK11_MACOS_X86_64: &str =
"https://download.java.net/java/GA/jdk11/9/GPL/openjdk-11.0.2_osx-x64_bin.tar.gz";

// graalvm jdk's
pub const GRAAL22_LINUX: &str =
"https://download.oracle.com/graalvm/22/latest/graalvm-jdk-22_linux-x64_bin.tar.gz";
pub const GRAAL22_WINDOWS: &str =
"https://download.oracle.com/graalvm/22/latest/graalvm-jdk-22_windows-x64_bin.zip";
pub const GRAAL22_MACOS_AARCH64: &str =
"https://download.oracle.com/graalvm/22/latest/graalvm-jdk-22_macos-aarch64_bin.tar.gz";
pub const GRAAL22_MACOS_X86_64: &str =
"https://download.oracle.com/graalvm/22/latest/graalvm-jdk-22_macos-x64_bin.tar.gz";
pub const GRAAL21_LINUX: &str =
"https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_linux-x64_bin.tar.gz";
pub const GRAAL21_WINDOWS: &str =
"https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_windows-x64_bin.zip";
pub const GRAAL21_MACOS_AARCH64: &str =
"https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_macos-aarch64_bin.tar.gz";
pub const GRAAL21_MACOS_X86_64: &str =
"https://download.oracle.com/graalvm/21/latest/graalvm-jdk-21_macos-x64_bin.tar.gz";
pub const GRAAL17_LINUX: &str =
"https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_linux-x64_bin.tar.gz";
pub const GRAAL17_WINDOWS: &str =
"https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_windows-x64_bin.zip";
pub const GRAAL17_MACOS_AARCH64: &str =
"https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_macos-aarch64_bin.tar.gz";
pub const GRAAL17_MACOS_X86_64: &str =
"https://download.oracle.com/graalvm/17/latest/graalvm-jdk-17_macos-x64_bin.tar.gz";

pub fn get_constant(key: &str) -> Option<&'static str> {
match key {
Expand Down Expand Up @@ -75,6 +105,20 @@ pub mod constants {
"OPENJDK11_WINDOWS" => Some(OPENJDK11_WINDOWS),
"OPENJDK11_MACOS_X86_64" => Some(OPENJDK11_MACOS_X86_64),

// graalvm jdk's
"GRAAL22_LINUX" => Some(GRAAL22_LINUX),
"GRAAL22_WINDOWS" => Some(GRAAL22_WINDOWS),
"GRAAL22_MACOS_AARCH64" => Some(GRAAL22_MACOS_AARCH64),
"GRAAL22_MACOS_X86_64" => Some(GRAAL22_MACOS_X86_64),
"GRAAL21_LINUX" => Some(GRAAL21_LINUX),
"GRAAL21_WINDOWS" => Some(GRAAL21_WINDOWS),
"GRAAL21_MACOS_AARCH64" => Some(GRAAL21_MACOS_AARCH64),
"GRAAL21_MACOS_X86_64" => Some(GRAAL21_MACOS_X86_64),
"GRAAL17_LINUX" => Some(GRAAL17_LINUX),
"GRAAL17_WINDOWS" => Some(GRAAL17_WINDOWS),
"GRAAL17_MACOS_AARCH64" => Some(GRAAL17_MACOS_AARCH64),
"GRAAL17_MACOS_X86_64" => Some(GRAAL17_MACOS_X86_64),

_ => None,
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/utils/file_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ pub fn check_jdk_exists(name: &str) -> bool {
}
}

pub fn check_path_exists(path: &str) -> bool {
match Path::new(&path).exists() {
true => true,
false => false,
}
}

pub fn create_java_dir(name: &str) {
let new_dir_path = format!("{}/.jvem/{}", *HOME_DIR, name);
fs::create_dir_all(new_dir_path).unwrap();
Expand Down

0 comments on commit e429804

Please # to comment.