Update change_scala_version.py to also change scala.version property (#9897)
This commit is contained in:
parent
71d330afdc
commit
82d846bbeb
@ -3,18 +3,19 @@ import pathlib
|
|||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
|
||||||
try:
|
|
||||||
import sh
|
|
||||||
except ImportError as e:
|
|
||||||
raise ImportError(
|
|
||||||
"Please install sh in your Python environment.\n"
|
|
||||||
" - Pip: pip install sh\n"
|
|
||||||
" - Conda: conda install -c conda-forge sh"
|
|
||||||
) from e
|
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
if args.scala_version == "2.12":
|
||||||
|
scala_ver = "2.12"
|
||||||
|
scala_patchver = "2.12.18"
|
||||||
|
elif args.scala_version == "2.13":
|
||||||
|
scala_ver = "2.13"
|
||||||
|
scala_patchver = "2.13.11"
|
||||||
|
else:
|
||||||
|
raise ValueError(f"Unsupported Scala version: {args.scala_version}")
|
||||||
|
|
||||||
# Clean artifacts
|
# Clean artifacts
|
||||||
|
if args.purge_artifacts:
|
||||||
for target in pathlib.Path("jvm-packages/").glob("**/target"):
|
for target in pathlib.Path("jvm-packages/").glob("**/target"):
|
||||||
if target.is_dir():
|
if target.is_dir():
|
||||||
print(f"Removing {target}...")
|
print(f"Removing {target}...")
|
||||||
@ -23,17 +24,50 @@ def main(args):
|
|||||||
# Update pom.xml
|
# Update pom.xml
|
||||||
for pom in pathlib.Path("jvm-packages/").glob("**/pom.xml"):
|
for pom in pathlib.Path("jvm-packages/").glob("**/pom.xml"):
|
||||||
print(f"Updating {pom}...")
|
print(f"Updating {pom}...")
|
||||||
sh.sed(
|
with open(pom, "r", encoding="utf-8") as f:
|
||||||
[
|
lines = f.readlines()
|
||||||
"-i",
|
with open(pom, "w", encoding="utf-8") as f:
|
||||||
f"s/<artifactId>xgboost-jvm_[0-9\\.]*/<artifactId>xgboost-jvm_{args.scala_version}/g",
|
replaced_scalaver = False
|
||||||
str(pom),
|
replaced_scala_binver = False
|
||||||
]
|
for line in lines:
|
||||||
|
for artifact in [
|
||||||
|
"xgboost-jvm",
|
||||||
|
"xgboost4j",
|
||||||
|
"xgboost4j-gpu",
|
||||||
|
"xgboost4j-spark",
|
||||||
|
"xgboost4j-spark-gpu",
|
||||||
|
"xgboost4j-flink",
|
||||||
|
"xgboost4j-example",
|
||||||
|
]:
|
||||||
|
line = re.sub(
|
||||||
|
f"<artifactId>{artifact}_[0-9\\.]*",
|
||||||
|
f"<artifactId>{artifact}_{scala_ver}",
|
||||||
|
line,
|
||||||
)
|
)
|
||||||
|
# Only replace the first occurrence of scala.version
|
||||||
|
if not replaced_scalaver:
|
||||||
|
line, nsubs = re.subn(
|
||||||
|
r"<scala.version>[0-9\.]*",
|
||||||
|
f"<scala.version>{scala_patchver}",
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
if nsubs > 0:
|
||||||
|
replaced_scalaver = True
|
||||||
|
# Only replace the first occurrence of scala.binary.version
|
||||||
|
if not replaced_scala_binver:
|
||||||
|
line, nsubs = re.subn(
|
||||||
|
r"<scala.binary.version>[0-9\.]*",
|
||||||
|
f"<scala.binary.version>{scala_ver}",
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
if nsubs > 0:
|
||||||
|
replaced_scala_binver = True
|
||||||
|
f.write(line)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument("--purge-artifacts", action="store_true")
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--scala-version",
|
"--scala-version",
|
||||||
type=str,
|
type=str,
|
||||||
|
|||||||
@ -229,7 +229,7 @@ def main():
|
|||||||
print(
|
print(
|
||||||
"5. Remove the Scala 2.12 artifacts and build Scala 2.13 artifacts:\n"
|
"5. Remove the Scala 2.12 artifacts and build Scala 2.13 artifacts:\n"
|
||||||
" export MAVEN_SKIP_NATIVE_BUILD=1\n"
|
" export MAVEN_SKIP_NATIVE_BUILD=1\n"
|
||||||
" python dev/change_scala_version.py --scala-version 2.13\n"
|
" python dev/change_scala_version.py --scala-version 2.13 --purge-artifacts\n"
|
||||||
" GPG_TTY=$(tty) mvn deploy -Prelease-cpu-only,scala-2.13 -DskipTests"
|
" GPG_TTY=$(tty) mvn deploy -Prelease-cpu-only,scala-2.13 -DskipTests"
|
||||||
)
|
)
|
||||||
print(
|
print(
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>xgboost4j-example</name>
|
<name>xgboost4j-example</name>
|
||||||
<artifactId>xgboost4j-example_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-example_2.12</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<build>
|
<build>
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j-spark_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-spark_2.12</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j-flink_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-flink_2.12</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|||||||
@ -10,7 +10,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<name>xgboost4j-flink</name>
|
<name>xgboost4j-flink</name>
|
||||||
<artifactId>xgboost4j-flink_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-flink_2.12</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
<properties>
|
<properties>
|
||||||
<flink-ml.version>2.2.0</flink-ml.version>
|
<flink-ml.version>2.2.0</flink-ml.version>
|
||||||
@ -30,7 +30,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j_2.12</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
<artifactId>xgboost-jvm_2.12</artifactId>
|
<artifactId>xgboost-jvm_2.12</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>xgboost4j-gpu_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-gpu_2.12</artifactId>
|
||||||
<name>xgboost4j-gpu</name>
|
<name>xgboost4j-gpu</name>
|
||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>xgboost4j-spark-gpu</name>
|
<name>xgboost4j-spark-gpu</name>
|
||||||
<artifactId>xgboost4j-spark-gpu_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-spark-gpu_2.12</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j-gpu_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-gpu_2.12</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>xgboost4j-spark</name>
|
<name>xgboost4j-spark</name>
|
||||||
<artifactId>xgboost4j-spark_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j-spark_2.12</artifactId>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>ml.dmlc</groupId>
|
<groupId>ml.dmlc</groupId>
|
||||||
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j_2.12</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|||||||
@ -9,7 +9,7 @@
|
|||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
</parent>
|
</parent>
|
||||||
<name>xgboost4j</name>
|
<name>xgboost4j</name>
|
||||||
<artifactId>xgboost4j_${scala.binary.version}</artifactId>
|
<artifactId>xgboost4j_2.12</artifactId>
|
||||||
<version>2.0.3</version>
|
<version>2.0.3</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
|||||||
@ -8,13 +8,18 @@ echo "--- Build XGBoost JVM packages scala 2.12"
|
|||||||
tests/ci_build/ci_build.sh jvm docker tests/ci_build/build_jvm_packages.sh \
|
tests/ci_build/ci_build.sh jvm docker tests/ci_build/build_jvm_packages.sh \
|
||||||
${SPARK_VERSION}
|
${SPARK_VERSION}
|
||||||
|
|
||||||
|
echo "--- Stash XGBoost4J JARs (Scala 2.12)"
|
||||||
|
buildkite-agent artifact upload "jvm-packages/xgboost4j/target/*.jar"
|
||||||
|
buildkite-agent artifact upload "jvm-packages/xgboost4j-spark/target/*.jar"
|
||||||
|
buildkite-agent artifact upload "jvm-packages/xgboost4j-flink/target/*.jar"
|
||||||
|
buildkite-agent artifact upload "jvm-packages/xgboost4j-example/target/*.jar"
|
||||||
|
|
||||||
echo "--- Build XGBoost JVM packages scala 2.13"
|
echo "--- Build XGBoost JVM packages scala 2.13"
|
||||||
|
|
||||||
tests/ci_build/ci_build.sh jvm docker tests/ci_build/build_jvm_packages.sh \
|
tests/ci_build/ci_build.sh jvm docker tests/ci_build/build_jvm_packages.sh \
|
||||||
${SPARK_VERSION} "" "" "true"
|
${SPARK_VERSION} "" "" "true"
|
||||||
|
|
||||||
echo "--- Stash XGBoost4J JARs"
|
echo "--- Stash XGBoost4J JARs (Scala 2.13)"
|
||||||
buildkite-agent artifact upload "jvm-packages/xgboost4j/target/*.jar"
|
buildkite-agent artifact upload "jvm-packages/xgboost4j/target/*.jar"
|
||||||
buildkite-agent artifact upload "jvm-packages/xgboost4j-spark/target/*.jar"
|
buildkite-agent artifact upload "jvm-packages/xgboost4j-spark/target/*.jar"
|
||||||
buildkite-agent artifact upload "jvm-packages/xgboost4j-flink/target/*.jar"
|
buildkite-agent artifact upload "jvm-packages/xgboost4j-flink/target/*.jar"
|
||||||
|
|||||||
@ -27,6 +27,9 @@ fi
|
|||||||
mvn_profile_string=""
|
mvn_profile_string=""
|
||||||
if [ "x$use_scala213" != "x" ]; then
|
if [ "x$use_scala213" != "x" ]; then
|
||||||
export mvn_profile_string="-Pdefault,scala-2.13"
|
export mvn_profile_string="-Pdefault,scala-2.13"
|
||||||
|
cd ..
|
||||||
|
python dev/change_scala_version.py --scala-version 2.13 --purge-artifacts
|
||||||
|
cd jvm-packages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mvn --no-transfer-progress package $mvn_profile_string -Dspark.version=${spark_version} $gpu_options
|
mvn --no-transfer-progress package $mvn_profile_string -Dspark.version=${spark_version} $gpu_options
|
||||||
|
|||||||
@ -27,6 +27,9 @@ rm -rf ../build/
|
|||||||
# Deploy to S3 bucket xgboost-maven-repo
|
# Deploy to S3 bucket xgboost-maven-repo
|
||||||
mvn --no-transfer-progress package deploy -P default,gpu,release-to-s3 -Dspark.version=${spark_version} -DskipTests
|
mvn --no-transfer-progress package deploy -P default,gpu,release-to-s3 -Dspark.version=${spark_version} -DskipTests
|
||||||
# Deploy scala 2.13 to S3 bucket xgboost-maven-repo
|
# Deploy scala 2.13 to S3 bucket xgboost-maven-repo
|
||||||
|
cd ..
|
||||||
|
python dev/change_scala_version.py --scala-version 2.13 --purge-artifacts
|
||||||
|
cd jvm-packages/
|
||||||
mvn --no-transfer-progress package deploy -P release-to-s3,default,scala-2.13 -Dspark.version=${spark_version} -DskipTests
|
mvn --no-transfer-progress package deploy -P release-to-s3,default,scala-2.13 -Dspark.version=${spark_version} -DskipTests
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -21,9 +21,18 @@ if [ ! -z "$RUN_INTEGRATION_TEST" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# including maven profiles for different scala versions: 2.12 is the default at the moment.
|
# including maven profiles for different scala versions: 2.12 is the default at the moment.
|
||||||
for _maven_profile_string in "" "-Pdefault,scala-2.13"; do
|
for scala_binary_version in "2.12" "2.13"; do
|
||||||
|
cd ..
|
||||||
|
python dev/change_scala_version.py --scala-version ${scala_binary_version}
|
||||||
|
cd jvm-packages
|
||||||
scala_version=$(mvn help:evaluate $_maven_profile_string -Dexpression=scala.version -q -DforceStdout)
|
scala_version=$(mvn help:evaluate $_maven_profile_string -Dexpression=scala.version -q -DforceStdout)
|
||||||
scala_binary_version=$(mvn help:evaluate $_maven_profile_string -Dexpression=scala.binary.version -q -DforceStdout)
|
if [[ "$scala_binary_version" == "2.12" ]]; then
|
||||||
|
_maven_profile_string=""
|
||||||
|
elif [[ "$scala_binary_version" == "2.13" ]]; then
|
||||||
|
_maven_profile_string="-Pdefault,scala-2.13"
|
||||||
|
else
|
||||||
|
echo "Unexpected scala version: $scala_version ($scala_binary_version)."
|
||||||
|
fi
|
||||||
|
|
||||||
# Install XGBoost4J JAR into local Maven repository
|
# Install XGBoost4J JAR into local Maven repository
|
||||||
mvn --no-transfer-progress install:install-file -Dfile=./xgboost4j/target/xgboost4j_${scala_binary_version}-${xgboost4j_version}.jar -DgroupId=ml.dmlc -DartifactId=xgboost4j_${scala_binary_version} -Dversion=${xgboost4j_version} -Dpackaging=jar
|
mvn --no-transfer-progress install:install-file -Dfile=./xgboost4j/target/xgboost4j_${scala_binary_version}-${xgboost4j_version}.jar -DgroupId=ml.dmlc -DartifactId=xgboost4j_${scala_binary_version} -Dversion=${xgboost4j_version} -Dpackaging=jar
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user