Skip to content
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

feat: add node and maven support #15

Merged
merged 24 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5464d4e
refactor cmd parser and ls fix
anusikh Jul 4, 2024
97693ee
refactor java version management
anusikh Jul 4, 2024
9c86374
added maven management for linux
anusikh Jul 4, 2024
1d25366
import fixes
anusikh Jul 4, 2024
c2d9578
added maven manag. for windows
anusikh Jul 4, 2024
f81cb50
added maven support macos
Jul 5, 2024
e839c1c
general refactor
Jul 6, 2024
6233692
(node) added commands for node, except install, uninstall and general…
Jul 7, 2024
23163b4
(node) all done, remaing install (windows, linux), removed serde, gen…
Jul 8, 2024
431b774
(node) pipeline failure fix
Jul 8, 2024
e0fc752
(node) wrong param passed
Jul 8, 2024
0223fd7
(node) use fs symlink instead of run command to create symlinks
Jul 13, 2024
a16a4c1
(node) check node exists (macos)
Jul 14, 2024
43a25ce
(node) fixing println error
Jul 14, 2024
be3a86e
(node) node version install and usev in linux
anusikh Jul 17, 2024
5ecb412
(node) node version install (windows)
anusikh Jul 17, 2024
5be9f2a
(node) group common unix code
anusikh Jul 17, 2024
52deef6
(node) installation path issue macos
Jul 18, 2024
b46ec9b
(test) added linux shell test
anusikh Jul 18, 2024
5422797
(test) fixed linux test and used direct paths
anusikh Jul 18, 2024
a97c429
(test) fix maven test for linux and action step rename
anusikh Jul 18, 2024
e9306eb
(test) i hope this fixes linux test :(
anusikh Jul 18, 2024
e3a5776
(chore) README update
anusikh Jul 19, 2024
cd23118
(chore) fixed imports and updated .gitignore
anusikh Jul 21, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions .github/workflows/build_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,14 @@ jobs:
needs: common-build
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: checkout code
uses: actions/checkout@v2
- name: build
- name: build and test
run: |
cargo build --all --release
bash src/tests/test.sh
- name: package
run: |
mv target/release/jvem target/release/jvem_amd64
mkdir source
mv target/release/jvem_amd64 source/
Expand All @@ -52,7 +55,7 @@ jobs:
needs: common-build
runs-on: windows-latest
steps:
- name: Checkout code
- name: checkout code
uses: actions/checkout@v2
- name: build
run: |
Expand All @@ -70,15 +73,15 @@ jobs:
needs: common-build
runs-on: macos-latest
steps:
- name: Checkout code
- name: checkout code
uses: actions/checkout@v2
- name: build
run: |
cargo build --all --release
mkdir source
mv target/release/jvem source/
tar -czvf ${{ env.MACOS_ARTIFACT }} -C source/ .
- name: Upload Artifact
- name: upload Artifact
uses: actions/upload-artifact@v2
with:
name: macos-artifact
Expand All @@ -88,19 +91,19 @@ jobs:
needs: [build-linux, build-win, build-macos]
runs-on: ubuntu-latest
steps:
- name: Checkout code
- name: checkout code
uses: actions/checkout@v2
- name: Download Linux Artifact
- name: download Linux Artifact
uses: actions/download-artifact@v2
with:
name: linux-artifact
path: .
- name: Download Windows Artifact
- name: download Windows Artifact
uses: actions/download-artifact@v2
with:
name: windows-artifact
path: .
- name: Download macOS Artifact
- name: download macOS Artifact
uses: actions/download-artifact@v2
with:
name: macos-artifact
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/target
/vendor
.vscode
.idea
23 changes: 1 addition & 22 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ edition = "2021"
clap = { version = "4.5.1", features = ["derive"] }
lazy_static = "1.4.0"
rand = "0.8.5"
serde = { version = "1.0.197", features = ["serde_derive"] }
tokio = { version = "1.36.0", features = ["full"] }

[profile.release]
Expand Down
134 changes: 32 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,113 +1,43 @@
# Java Version Manager (JVeM)
# JVeM

![JVeM](/public/final-logo-black.png)
![](/public/final-logo-black.png)

Java Version Manager (JVeM) is a cross-platform tool designed to simplify the management of multiple Java versions on your system. Whether you're a developer working on diverse projects or an enthusiast exploring different Java applications, JVeM makes it easy to switch between and manage various Java versions seamlessly.
a simple version manager for java, node and maven
- *cross-platform support:* consistent experience across different operating systems.
- *simple version switching:* easily switch between different java/node versions.

## Table of Contents
#### getting started:

1. [Features](#features)
2. [Supported Platforms](#supported-platforms)
3. [Getting Started](#getting-started)
- [Windows Installation](#windows-installation)
- [macOS Installation](#macos-installation)
- [Linux Installation](#linux-installation)
4. [Usage](#usage)
- [Commands and Descriptions](#commands-and-descriptions)
5. [Future Scope](#future-scope)
to get started with jvem, refer to the installation instructions and basic usage guidelines below.

## Features:
#### windows installation

- **Cross-Platform Support:** JVeM is compatible with macOS, Linux, and Windows, providing a consistent experience across different operating systems.
- **Simple Version Switching:** Easily switch between different Java versions with a single command, streamlining your development workflow.
- **Effortless Installation:** JVeM offers a straightforward installation process on supported platforms, ensuring quick setup without unnecessary complications.
- **Customizable Configuration:** Tailor JVeM to your specific needs by configuring environment variables and settings to suit your Java development environment.
- download the latest version from [releases](https://github.com/anusikh/jvem/releases)
- add these path to your environment variables:
```
C:\Users\<user>\.jvem\java\bin
C:\Users\<user>\.jvem\node
C:\Users\<user>\.jvem\maven
<path-to-extracted-binary>
```
#### macos/linux installation

## Supported Platforms:
- download the latest version from [releases](https://github.com/anusikh/jvem/releases)
- add the following lines to `~/.zshrc` or `~/.bashrc`
```
PATH="$M2_HOME/bin:$PATH"
PATH=$PATH:$HOME/.jvem/java/bin
PATH=$PATH:$HOME/.jvem/node/bin
JAVA_HOME=$HOME/.jvem/java
JDK_HOME=$HOME/.jvem/java
alias jvem=<path-to-extracted-binary>
```

- Windows
- Linux
- macOS
#### usage:

## Getting Started:
- just run the `jvem --help` command

To get started with JVeM, refer to the installation instructions and basic usage guidelines below.
#### note for macos:

#### Windows Installation

- Download the latest `jvem.zip` file from [Releases](https://github.com/anusikh/jvem/releases)
- Extract this file here.
- Add this path to your environment variables: `C:\Users\<user>\.jvem\java\bin`
- Add the path of the extracted folder to environment variables.

#### macOS Installation

- Download the latest `jvem_macos.tar.gz` file from [Releases](https://github.com/anusikh/jvem/releases)
- Extract the tarball file.
- Add this line to your zshrc/bashrc file: `export JAVA_HOME=$HOME/.jvem/java` and source it.
- Add an alias to use jvem easily. `alias jvem=~/Downloads/jvem`

#### Linux Installation

- Download the latest `jvem_linux.tar.gz` file from [Releases](https://github.com/anusikh/jvem/releases)
- Extract the tarball file.
- Add this line to your zshrc/bashrc file: `PATH=$PATH:$HOME/.jvem/java/bin`
- Also add this line `JAVA_HOME=$HOME/.jvem/java` and then source the rc file
- Add an alias to use jvem easily. `alias jvem=~/Downloads/jvem`

## Usage:

Once installed, use the following commands to manage your Java versions.
1. Check all versions of java supported by JVeM:
```
jvem lsrem
```
2. Install a new version on your system:
```
jvem install zulu17
```
3. Start using the java version installed
```
jvem usev zulu17
```
4. Check if java got installed:

If java versions < 8:
`java -version `
else:
`java --version`
5. Uninstall java
`jvem uninstall zulu17`


## Commands and Descriptions

| Command | Description |
| ------------------------------ | ---------------------------------------------- |
| `jvem lsrem` | List all JDK versions available for install. |
| `jvem ls` | List locally installed JDK versions. |
| `jvem install zulu21` | Install Zulu JDK version 21. |
| `jvem usev zulu17` | Use a specific JDK version after installation. |
| `jvem current` | Find the currently active JDK version. |
| `jvem deactivate` | Deactivate the currently active JDK. |
| `jvem uninstall zulu17` | Uninstall the specified JDK version. |
| `jvem help` | Display help information. |
| `jvem clean` | Clean empty folders in the .jvem directory. |
| `jvem --V` or `jvem --version` | Display the version of JVeM. |

## Future Scope:

JVeM is an evolving project, and future updates may include:

- Addition of more JDKs
- Addition of support for new platforms.
- Integration of test cases to enhance stability.
- Bug fixes and improvements based on user feedback.

Explore the full capabilities of JVeM to enhance your Java development experience!



### Note for MacOs:
This might show an error when trying to use it for the first time, you would need to allow it from settings > under privacy and security:
<img width="710" alt="Screenshot 2024-03-09 at 2 14 49 AM" src="https://github.com/anusikh/jvem/assets/64547846/0f37ea90-1b68-4272-a823-f8dd2390c324">
you would need to allow it from settings > under privacy and security:
<img alt="" src="https://github.com/anusikh/jvem/assets/64547846/0f37ea90-1b68-4272-a823-f8dd2390c324">
13 changes: 0 additions & 13 deletions src/commands/current.rs

This file was deleted.

2 changes: 1 addition & 1 deletion src/commands/clean.rs → src/commands/java/clean.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::utils::file_utils::clean_jvem;

pub fn clean() {
let _ = clean_jvem();
let _ = clean_jvem("java");
}
10 changes: 10 additions & 0 deletions src/commands/java/current.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
use crate::utils::file_utils::run_command;

pub fn current() {
let res = run_command("java", vec!["--version"]);
if res.status.success() {
println!("java version: {}", String::from_utf8_lossy(&res.stdout));
} else {
println!("failed: node not set");
}
}
12 changes: 1 addition & 11 deletions src/commands/deactivate.rs → src/commands/java/deactivate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,7 @@ fn deactivate_util() {
}
}

#[cfg(target_os = "linux")]
fn deactivate_util() {
let output = run_command("rm", vec!["-rf", &format!("{}/.jvem/java", get_home_dir())]);
if output.status.success() {
println!("deactivation successful ");
} else {
println!("deactivation failed");
}
}

#[cfg(target_os = "macos")]
#[cfg(unix)]
fn deactivate_util() {
let output = run_command("rm", vec!["-rf", &format!("{}/.jvem/java", get_home_dir())]);
if output.status.success() {
Expand Down
Loading
Loading