Skip to content

Commit e6b32c0

Browse files
committed
[ZEPPELIN-2139] Interpreters based on scala_2.11 aren't installed correctly
### What is this PR for? pom variables such as `${scala.version}` are not replaced to value when you do `mvn install`. This makes leaf poms to look for this value in parent pom, which is always `2.10.5` for `${scala.version}` and it causes scala library dependency conflict. For example, zeppelin-flink_2.11 will have scala 2.10.5 as dependency. This PR fixes this problem by using maven flatten plugin. ### What type of PR is it? Bug Fix ### What is the Jira issue? [ZEPPELIN-2139](https://issues.apache.org/jira/browse/ZEPPELIN-2139) ### How should this be tested? ``` $ ./dev/change_scala_version.sh 2.11 $ mvn clean install -pl 'zeppelin-server,zeppelin-zengine,zeppelin-interpreter,flink' -am -DskipRat -DskipTests -Pscala-2.11 ``` Open `~/.m2/repository/org/apache/zeppelin/zeppelin-flink_2.11/0.8.0-SNAPSHOT/zeppelin-flink_2.11-0.8.0-SNAPSHOT.pom` file and see if scala related libraries dependency version is set to 2.11.7 ### Screenshots (if appropriate) ### Questions: * Does the licenses files need update? no * Is there breaking changes for older versions? no * Does this needs documentation? no Author: Mina Lee <[email protected]> Closes apache#2059 from minahlee/ZEPPELIN-2139 and squashes the following commits: 62d852a [Mina Lee] Change <scala.version> property in parent pom file 489c843 [Mina Lee] Use maven flatten plugin to make pom.xml variables to be replaced by value 783c014 [Mina Lee] Fix indentation and add default properties to be used in flattened-pom
1 parent 77778e3 commit e6b32c0

File tree

4 files changed

+599
-559
lines changed

4 files changed

+599
-559
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,9 @@ Thumbs.db
100100
target/
101101
**/target/
102102

103+
# maven flattened pom files
104+
**/.flattened-pom.xml
105+
103106
# Generated by Jekyll
104107
docs/_site/
105108

dev/change_scala_version.sh

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,22 @@ if [[ ($# -ne 1) || ( $1 == "--help") || $1 == "-h" ]]; then
3434
usage
3535
fi
3636

37-
TO_VERSION=$1
37+
TO_VERSION="$1"
3838

3939
check_scala_version() {
4040
for i in ${VALID_VERSIONS[*]}; do [ $i = "$1" ] && return 0; done
4141
echo "Invalid Scala version: $1. Valid versions: ${VALID_VERSIONS[*]}" 1>&2
4242
exit 1
4343
}
4444

45-
check_scala_version "$TO_VERSION"
45+
check_scala_version "${TO_VERSION}"
4646

47-
if [ $TO_VERSION = "2.11" ]; then
47+
if [ "${TO_VERSION}" = "2.11" ]; then
4848
FROM_VERSION="2.10"
49+
SCALA_LIB_VERSION="2.11.7"
4950
else
5051
FROM_VERSION="2.11"
52+
SCALA_LIB_VERSION="2.10.5"
5153
fi
5254

5355
sed_i() {
@@ -57,11 +59,17 @@ sed_i() {
5759
export -f sed_i
5860

5961
BASEDIR=$(dirname $0)/..
60-
find "$BASEDIR" -name 'pom.xml' -not -path '*target*' -print \
61-
-exec bash -c "sed_i 's/\(artifactId.*\)_'$FROM_VERSION'/\1_'$TO_VERSION'/g' {}" \;
62+
find "${BASEDIR}" -name 'pom.xml' -not -path '*target*' -print \
63+
-exec bash -c "sed_i 's/\(artifactId.*\)_'${FROM_VERSION}'/\1_'${TO_VERSION}'/g' {}" \;
6264

63-
# Also update <scala.binary.version> in parent POM
65+
# update <scala.binary.version> in parent POM
6466
# Match any scala binary version to ensure idempotency
65-
sed_i '1,/<scala\.binary\.version>[0-9]*\.[0-9]*</s/<scala\.binary\.version>[0-9]*\.[0-9]*</<scala.binary.version>'$TO_VERSION'</' \
66-
"$BASEDIR/pom.xml"
67+
sed_i '1,/<scala\.binary\.version>[0-9]*\.[0-9]*</s/<scala\.binary\.version>[0-9]*\.[0-9]*</<scala.binary.version>'${TO_VERSION}'</' \
68+
"${BASEDIR}/pom.xml"
6769

70+
# update <scala.version> in parent POM
71+
# This is to make variables in leaf pom to be substituted to real value when flattened-pom is created.
72+
# maven-flatten plugin doesn't take properties defined under profile even if scala-2.11/scala-2.10 is activated via -Pscala-2.11/-Pscala-2.10,
73+
# and use default defined properties to create flatten pom.
74+
sed_i '1,/<scala\.version>[0-9]*\.[0-9]*\.[0-9]*</s/<scala\.version>[0-9]*\.[0-9]*\.[0-9]*</<scala.version>'${SCALA_LIB_VERSION}'</' \
75+
"${BASEDIR}/pom.xml"

0 commit comments

Comments
 (0)