#!/bin/bash
# Bash/Zsh Maven Environment Switch - {{env_name}}
# Generated by fnva

# Clean previous fnva-managed path, then set new MAVEN_HOME / M2_HOME
if [ -n "${FNVA_MAVEN_BIN:-}" ]; then
    PATH="${PATH//${FNVA_MAVEN_BIN}:/}"
fi
export FNVA_MAVEN_BIN="{{maven_bin}}"
export MAVEN_HOME="{{maven_home}}"
export M2_HOME="{{maven_home}}"
export PATH="$FNVA_MAVEN_BIN:$PATH"

# Set MAVEN_OPTS (clear previous then apply this environment's config)
{{#if has_maven_opts}}
export MAVEN_OPTS="{{maven_opts_value}}"
{{else}}
unset MAVEN_OPTS
{{/if}}

# Set fnva environment tracking
export FNVA_CURRENT_MAVEN="{{env_name}}"
export FNVA_ENV_TYPE="Maven"

# Verify the switch
if [[ -z "$_FNVA_QUIET" ]]; then
    printf '\033[32m✓\033[0m Switched to Maven: {{env_name}}\n'
fi
