# -*- mode: ruby -*-
# vi: set ft=ruby :
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements.  See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership.  The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

Vagrant.configure("2") do |config|
  config.vm.box = "jonatasbaldin/solaris11"
  #config.ssh.password = "v@grant"

  config.vm.provider "virtualbox" do |v|
    v.memory = 2048
    v.cpus = 2
  end

  config.vm.provision "file", source:"apache-maven-3.3.9.patch", destination:"apache-maven-3.3.9.patch"
  config.vm.provision "shell", inline: <<-SHELL
    sudo sudo pkg install --accept jdk-7 git &&\
    wget --no-check-certificate https://archive.apache.org/dist/maven/maven-3/3.3.9/binaries/apache-maven-3.3.9-bin.tar.gz &&\
    gunzip -c apache-maven-3.3.9-bin.tar.gz | sudo sh -c "cd /opt; tar xf - " 2>&1 &&\
    sudo patch -i apache-maven-3.3.9.patch /opt/apache-maven-3.3.9/bin/mvn &&\
    sudo ln -s /opt/apache-maven-3.3.9/bin/mvn /usr/bin/mvn &&\
    rm -rf apache-maven-3.3.9-bin.tar.gz apache-maven-3.3.9.patch &&\
    sudo sh -c "echo JAVA_HOME=/usr/jdk/latest >> /etc/profile" &&\
    sudo sh -c "echo export JAVA_HOME >> /etc/profile" &&\
    sudo sh -c "echo MAVEN_HOME=/opt/apache-maven-3.3.9 >> /etc/profile" &&\
    sudo sh -c "echo export MAVEN_HOME >> /etc/profile" &&\
    sudo sh -c "echo PATH=${MAVEN_HOME}/bin:${PATH} >> /etc/profile" &&\
    sudo sh -c "echo export PATH >> /etc/profile"
  SHELL

end
