Skip to content

Commit a2262cd

Browse files
andrewor14pwendell
authored andcommitted
[SPARK-1735] Add the missing special profiles to make-distribution.sh
73b0cbc introduced a few special profiles that are not covered in the `make-distribution.sh`. This affects hadoop versions 2.2.x, 2.3.x, and 2.4.x. Without these special profiles, a java version error for protobufs is thrown at run time. I took the opportunity to rewrite the way we construct the maven command. Previously, the only hadoop version that triggered the `yarn-alpha` profile was 0.23.x, which was inconsistent with the [docs](https://github.com/apache/spark/blob/master/docs/building-with-maven.md). This is now generalized to hadoop versions from 0.23.x to 2.1.x. Author: Andrew Or <andrewor14@gmail.com> Closes #660 from andrewor14/hadoop-distribution and squashes the following commits: 6740126 [Andrew Or] Generalize the yarn profile to hadoop versions 2.2+ 88f192d [Andrew Or] Add the required special profiles to make-distribution.sh
1 parent 6d721c5 commit a2262cd

File tree

1 file changed

+27
-20
lines changed

1 file changed

+27
-20
lines changed

make-distribution.sh

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ set -o pipefail
4747
VERSION=$(mvn help:evaluate -Dexpression=project.version 2>/dev/null | grep -v "INFO" | tail -n 1)
4848
if [ $? != 0 ]; then
4949
echo -e "You need Maven installed to build Spark."
50-
echo -e "Download Maven from https://maven.apache.org."
50+
echo -e "Download Maven from https://maven.apache.org/"
5151
exit -1;
5252
fi
5353

@@ -131,27 +131,34 @@ cd $FWDIR
131131

132132
export MAVEN_OPTS="-Xmx2g -XX:MaxPermSize=512M -XX:ReservedCodeCacheSize=512m"
133133

134-
if [ "$SPARK_HIVE" == "true" ]; then
135-
MAYBE_HIVE="-Phive"
136-
else
137-
MAYBE_HIVE=""
138-
fi
139-
140-
if [ "$SPARK_YARN" == "true" ]; then
141-
if [[ "$SPARK_HADOOP_VERSION" =~ "0.23." ]]; then
142-
mvn clean package -DskipTests -Pyarn-alpha -Dhadoop.version=$SPARK_HADOOP_VERSION \
143-
-Dyarn.version=$SPARK_HADOOP_VERSION $MAYBE_HIVE -Phadoop-0.23
144-
else
145-
mvn clean package -DskipTests -Pyarn -Dhadoop.version=$SPARK_HADOOP_VERSION \
146-
-Dyarn.version=$SPARK_HADOOP_VERSION $MAYBE_HIVE
147-
fi
148-
else
149-
if [[ "$SPARK_HADOOP_VERSION" =~ "0.23." ]]; then
150-
mvn clean package -Phadoop-0.23 -DskipTests -Dhadoop.version=$SPARK_HADOOP_VERSION $MAYBE_HIVE
151-
else
152-
mvn clean package -DskipTests -Dhadoop.version=$SPARK_HADOOP_VERSION $MAYBE_HIVE
134+
BUILD_COMMAND="mvn clean package"
135+
136+
# Use special profiles for hadoop versions 0.23.x, 2.2.x, 2.3.x, 2.4.x
137+
if [[ "$SPARK_HADOOP_VERSION" =~ ^0\.23\. ]]; then BUILD_COMMAND="$BUILD_COMMAND -Phadoop-0.23"; fi
138+
if [[ "$SPARK_HADOOP_VERSION" =~ ^2\.2\. ]]; then BUILD_COMMAND="$BUILD_COMMAND -Phadoop-2.2"; fi
139+
if [[ "$SPARK_HADOOP_VERSION" =~ ^2\.3\. ]]; then BUILD_COMMAND="$BUILD_COMMAND -Phadoop-2.3"; fi
140+
if [[ "$SPARK_HADOOP_VERSION" =~ ^2\.4\. ]]; then BUILD_COMMAND="$BUILD_COMMAND -Phadoop-2.4"; fi
141+
if [[ "$SPARK_HIVE" == "true" ]]; then BUILD_COMMAND="$BUILD_COMMAND -Phive"; fi
142+
if [[ "$SPARK_YARN" == "true" ]]; then
143+
# For hadoop versions 0.23.x to 2.1.x, use the yarn-alpha profile
144+
if [[ "$SPARK_HADOOP_VERSION" =~ ^0\.2[3-9]\. ]] ||
145+
[[ "$SPARK_HADOOP_VERSION" =~ ^0\.[3-9][0-9]\. ]] ||
146+
[[ "$SPARK_HADOOP_VERSION" =~ ^1\.[0-9]\. ]] ||
147+
[[ "$SPARK_HADOOP_VERSION" =~ ^2\.[0-1]\. ]]; then
148+
BUILD_COMMAND="$BUILD_COMMAND -Pyarn-alpha"
149+
# For hadoop versions 2.2+, use the yarn profile
150+
elif [[ "$SPARK_HADOOP_VERSION" =~ ^2.[2-9]. ]]; then
151+
BUILD_COMMAND="$BUILD_COMMAND -Pyarn"
153152
fi
153+
BUILD_COMMAND="$BUILD_COMMAND -Dyarn.version=$SPARK_HADOOP_VERSION"
154154
fi
155+
BUILD_COMMAND="$BUILD_COMMAND -Dhadoop.version=$SPARK_HADOOP_VERSION"
156+
BUILD_COMMAND="$BUILD_COMMAND -DskipTests"
157+
158+
# Actually build the jar
159+
echo -e "\nBuilding with..."
160+
echo -e "\$ $BUILD_COMMAND\n"
161+
${BUILD_COMMAND}
155162

156163
# Make directories
157164
rm -rf "$DISTDIR"

0 commit comments

Comments
 (0)