d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# ----------------------------------------------------------------------------
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# Licensed to the Apache Software Foundation (ASF) under one
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# or more contributor license agreements. See the NOTICE file
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# distributed with this work for additional information
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# regarding copyright ownership. The ASF licenses this file
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# to you under the Apache License, Version 2.0 (the
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# "License"); you may not use this file except in compliance
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# with the License. You may obtain a copy of the License at
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# Unless required by applicable law or agreed to in writing,
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# software distributed under the License is distributed on an
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# KIND, either express or implied. See the License for the
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# specific language governing permissions and limitations
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# under the License.
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# ----------------------------------------------------------------------------
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# ----------------------------------------------------------------------------
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# Maven2 Start Up Batch script
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# Required ENV vars:
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# ------------------
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# JAVA_HOME - location of a JDK home dir
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# Optional ENV vars
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# -----------------
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# M2_HOME - location of maven2's installed home dir
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# MAVEN_OPTS - parameters passed to the Java VM when running Maven
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# e.g. to debug Maven itself, use
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# ----------------------------------------------------------------------------
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ -z "$MAVEN_SKIP_RC" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -f "$HOME/.mavenrc" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# OS specific support. $var _must_ be set to either true or false.
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # Look for the Apple JDKs first to preserve the existing behaviour, and then look
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # for the new JDKs provided by Oracle.
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -z "$JAVA_HOME" ] && [ -L /System/Library/Java/JavaVirtualMachines/CurrentJDK ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria export JAVA_HOME=/System/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -z "$JAVA_HOME" ] && [ -L "/Library/Java/JavaVirtualMachines/CurrentJDK" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # Oracle JDKs
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria export JAVA_HOME=/Library/Java/JavaVirtualMachines/CurrentJDK/Contents/Home
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -z "$JAVA_HOME" ] && [ -x "/usr/libexec/java_home" ]; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ -z "$JAVA_HOME" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ -z "$M2_HOME" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria ## resolve links - $0 may be a link to maven's home
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # need this for relative symlinks
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria while [ -h "$PRG" ] ; do
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # make it fully qualified
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # echo Using m2 at $M2_HOME
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# For Cygwin, ensure paths are in UNIX format before anything is touched
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# For Migwn, ensure paths are in UNIX format before anything is touched
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # TODO classpath?
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ -z "$JAVA_HOME" ]; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # readlink(1) is not available as standard on Solaris 10.
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria javaExecutable="`readlink -f \"$javaExecutable\"`"
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ -z "$JAVACMD" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -n "$JAVA_HOME" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria # IBM's JDK on AIX uses strange locations for the executables
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ ! -x "$JAVACMD" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria echo "Error: JAVA_HOME is not defined correctly." >&2
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaif [ -z "$JAVA_HOME" ] ; then
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria echo "Warning: JAVA_HOME environment variable is not set."
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid ZakariaCLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# For Cygwin, switch paths to Windows format before running java
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# traverses directory structure from process work directory to filesystem root
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# first directory with .mvn subdirectory is considered project base directory
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# concatenates all lines of a file
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakariaexport MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-$(find_maven_basedir)}
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid ZakariaMAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# Provide a "standardized" way to retrieve the CLI args that will
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria# work with both Windows and non-Windows executions.
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid ZakariaWRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
d69d2e025b2dbe63dda1853449f935e1efc2cd5dFarid Zakaria "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \