diff --git a/Jenkinsfile b/Jenkinsfile index a285009921e0..e4209bda1b0b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -94,6 +94,17 @@ pipeline { milestone ordinal: 4 } } + stage('Jenkins Linux: Deploy') { + agent none + steps { + script { + parallel ([ + 'deploy-jvm-packages': { DeployJVMPackages(spark_version: '2.4.3') } + ]) + } + milestone ordinal: 5 + } + } } } @@ -383,3 +394,18 @@ def TestR(args) { deleteDir() } } + +def DeployJVMPackages(args) { + node('linux && cpu') { + unstash name: 'srcs' + if (env.BRANCH_NAME == 'master' || env.BRANCH_NAME.startsWith('release')) { + echo 'Deploying to xgboost-maven-repo S3 repo...' + def container_type = "jvm" + def docker_binary = "docker" + sh """ + ${dockerRun} ${container_type} ${docker_binary} tests/ci_build/deploy_jvm_packages.sh ${args.spark_version} + """ + } + deleteDir() + } +} diff --git a/doc/jvm/index.rst b/doc/jvm/index.rst index 436311d25bba..69e4569c3a97 100644 --- a/doc/jvm/index.rst +++ b/doc/jvm/index.rst @@ -8,128 +8,189 @@ XGBoost JVM Package Build Status - GitHub license + GitHub license You have found the XGBoost JVM Package! +.. _install_jvm_packages: + ************ Installation ************ -Installation from source -======================== - -Building XGBoost4J using Maven requires Maven 3 or newer, Java 7+ and CMake 3.3+ for compiling the JNI bindings. - -Before you install XGBoost4J, you need to define environment variable ``JAVA_HOME`` as your JDK directory to ensure that your compiler can find ``jni.h`` correctly, since XGBoost4J relies on JNI to implement the interaction between the JVM and native libraries. +.. contents:: + :local: + :backlinks: none -After your ``JAVA_HOME`` is defined correctly, it is as simple as run ``mvn package`` under jvm-packages directory to install XGBoost4J. You can also skip the tests by running ``mvn -DskipTests=true package``, if you are sure about the correctness of your local setup. +Installation from Maven repository +================================== -To publish the artifacts to your local maven repository, run +Access release version +---------------------- +You can use XGBoost4J in your Java/Scala application by adding XGBoost4J as a dependency: -.. code-block:: bash +.. code-block:: xml + :caption: Maven + + + ... + + 2.12 + + + + ... + + ml.dmlc + xgboost4j_${scala.binary.version} + latest_version_num + + + ml.dmlc + xgboost4j-spark_${scala.binary.version} + latest_version_num + + - mvn install +.. code-block:: scala + :caption: sbt -Or, if you would like to skip tests, run + libraryDependencies ++= Seq( + "ml.dmlc" %% "xgboost4j" % "latest_version_num", + "ml.dmlc" %% "xgboost4j-spark" % "latest_version_num" + ) -.. code-block:: bash +This will check out the latest stable version from the Maven Central. - mvn -DskipTests install +For the latest release version number, please check `here `_. -This command will publish the xgboost binaries, the compiled java classes as well as the java sources to your local repository. Then you can use XGBoost4J in your Java projects by including the following dependency in ``pom.xml``: +.. note:: Using Maven repository hosted by the XGBoost project -.. code-block:: xml + There may be some delay until a new release becomes available to Maven Central. If you would like to access the latest release immediately, add the Maven repository hosted by the XGBoost project: - - ml.dmlc - xgboost4j - latest_source_version_num - + .. code-block:: xml + :caption: Maven -For sbt, please add the repository and dependency in build.sbt as following: + + XGBoost4J Release Repo + XGBoost4J Release Repo + https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/release/ + -.. code-block:: scala + .. code-block:: scala + :caption: sbt - resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository" + resolvers += "XGBoost4J Release Repo" at "https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/release/" - "ml.dmlc" % "xgboost4j" % "latest_source_version_num" +Access SNAPSHOT version +----------------------- -If you want to use XGBoost4J-Spark, replace ``xgboost4j`` with ``xgboost4j-spark``. +First add the following Maven repository hosted by the XGBoost project: -.. note:: XGBoost4J-Spark requires Apache Spark 2.3+ +.. code-block:: xml + :caption: Maven - XGBoost4J-Spark now requires **Apache Spark 2.3+**. Latest versions of XGBoost4J-Spark uses facilities of `org.apache.spark.ml.param.shared` extensively to provide for a tight integration with Spark MLLIB framework, and these facilities are not fully available on earlier versions of Spark. + + XGBoost4J Snapshot Repo + XGBoost4J Snapshot Repo + https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/snapshot/ + - Also, make sure to install Spark directly from `Apache website `_. **Upstream XGBoost is not guaranteed to work with third-party distributions of Spark, such as Cloudera Spark.** Consult appropriate third parties to obtain their distribution of XGBoost. +.. code-block:: scala + :caption: sbt -Installation from maven repo -============================ + resolvers += "XGBoost4J Snapshot Repo" at "https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/snapshot/" -Access release version ----------------------- +Then add XGBoost4J as a dependency: .. code-block:: xml :caption: maven - - ml.dmlc - xgboost4j - latest_version_num - + + ... + + 2.12 + + + + ... + + ml.dmlc + xgboost4j_${scala.binary.version} + latest_version_num-SNAPSHOT + + + ml.dmlc + xgboost4j-spark_${scala.binary.version} + latest_version_num-SNAPSHOT + + .. code-block:: scala :caption: sbt - "ml.dmlc" % "xgboost4j" % "latest_version_num" + libraryDependencies ++= Seq( + "ml.dmlc" %% "xgboost4j" % "latest_version_num-SNAPSHOT", + "ml.dmlc" %% "xgboost4j-spark" % "latest_version_num-SNAPSHOT" + ) -This will checkout the latest stable version from the Maven Central. +Look up the ``version`` field in `pom.xml `_ to get the correct version number. -For the latest release version number, please check `here `_. +The SNAPSHOT JARs are hosted by the XGBoost project. Every commit in the ``master`` branch will automatically trigger generation of a new SNAPSHOT JAR. You can control how often Maven should upgrade your SNAPSHOT installation by specifying ``updatePolicy``. See `here `_ for details. -if you want to use XGBoost4J-Spark, replace ``xgboost4j`` with ``xgboost4j-spark``. +You can browse the file listing of the Maven repository at https://s3-us-west-2.amazonaws.com/xgboost-maven-repo/list.html. -Access SNAPSHOT version ------------------------ +.. note:: Windows not supported by published JARs -You need to add GitHub as repo: + The published JARs from the Maven Central and GitHub currently only supports Linux and MacOS. Windows users should consider building XGBoost4J / XGBoost4J-Spark from the source. Alternatively, checkout pre-built JARs from `criteo-forks/xgboost-jars `_. -.. code-block:: xml - :caption: maven +Installation from source +======================== - - GitHub Repo - GitHub Repo - https://raw.githubusercontent.com/CodingCat/xgboost/maven-repo/ - +Building XGBoost4J using Maven requires Maven 3 or newer, Java 7+ and CMake 3.3+ for compiling the JNI bindings. -.. code-block:: scala - :caption: sbt +Before you install XGBoost4J, you need to define environment variable ``JAVA_HOME`` as your JDK directory to ensure that your compiler can find ``jni.h`` correctly, since XGBoost4J relies on JNI to implement the interaction between the JVM and native libraries. + +After your ``JAVA_HOME`` is defined correctly, it is as simple as run ``mvn package`` under jvm-packages directory to install XGBoost4J. You can also skip the tests by running ``mvn -DskipTests=true package``, if you are sure about the correctness of your local setup. + +To publish the artifacts to your local maven repository, run + +.. code-block:: bash + + mvn install - resolvers += "GitHub Repo" at "https://raw.githubusercontent.com/CodingCat/xgboost/maven-repo/" +Or, if you would like to skip tests, run + +.. code-block:: bash -Then add dependency as following: + mvn -DskipTests install + +This command will publish the xgboost binaries, the compiled java classes as well as the java sources to your local repository. Then you can use XGBoost4J in your Java projects by including the following dependency in ``pom.xml``: .. code-block:: xml - :caption: maven - ml.dmlc - xgboost4j - latest_version_num + ml.dmlc + xgboost4j + latest_source_version_num +For sbt, please add the repository and dependency in build.sbt as following: + .. code-block:: scala - :caption: sbt - "ml.dmlc" % "xgboost4j" % "latest_version_num" + resolvers += "Local Maven Repository" at "file://"+Path.userHome.absolutePath+"/.m2/repository" -For the latest release version number, please check `here `_. + "ml.dmlc" % "xgboost4j" % "latest_source_version_num" -.. note:: Windows not supported by published JARs +If you want to use XGBoost4J-Spark, replace ``xgboost4j`` with ``xgboost4j-spark``. - The published JARs from the Maven Central and GitHub currently only supports Linux and MacOS. Windows users should consider building XGBoost4J / XGBoost4J-Spark from the source. Alternatively, checkout pre-built JARs from `criteo-forks/xgboost-jars `_. +.. note:: XGBoost4J-Spark requires Apache Spark 2.3+ + + XGBoost4J-Spark now requires **Apache Spark 2.3+**. Latest versions of XGBoost4J-Spark uses facilities of `org.apache.spark.ml.param.shared` extensively to provide for a tight integration with Spark MLLIB framework, and these facilities are not fully available on earlier versions of Spark. + + Also, make sure to install Spark directly from `Apache website `_. **Upstream XGBoost is not guaranteed to work with third-party distributions of Spark, such as Cloudera Spark.** Consult appropriate third parties to obtain their distribution of XGBoost. Enabling OpenMP for Mac OS -------------------------- diff --git a/doc/jvm/xgboost4j_spark_tutorial.rst b/doc/jvm/xgboost4j_spark_tutorial.rst index 8389aa703d72..67817613ade1 100644 --- a/doc/jvm/xgboost4j_spark_tutorial.rst +++ b/doc/jvm/xgboost4j_spark_tutorial.rst @@ -27,39 +27,7 @@ Build an ML Application with XGBoost4J-Spark Refer to XGBoost4J-Spark Dependency =================================== -Before we go into the tour of how to use XGBoost4J-Spark, we would bring a brief introduction about how to build a machine learning application with XGBoost4J-Spark. The first thing you need to do is to refer to the dependency in Maven Central. - -You can add the following dependency in your ``pom.xml``. - -.. code-block:: xml - - - ml.dmlc - xgboost4j-spark - latest_version_num - - -For the latest release version number, please check `here `_. - -We also publish some functionalities which would be included in the coming release in the form of snapshot version. To access these functionalities, you can add dependency to the snapshot artifacts. We publish snapshot version in github-based repo, so you can add the following repo in ``pom.xml``: - -.. code-block:: xml - - - XGBoost4J-Spark Snapshot Repo - XGBoost4J-Spark Snapshot Repo - https://raw.githubusercontent.com/CodingCat/xgboost/maven-repo/ - - -and then refer to the snapshot dependency by adding: - -.. code-block:: xml - - - ml.dmlc - xgboost4j-spark - next_version_num-SNAPSHOT - +Before we go into the tour of how to use XGBoost4J-Spark, you should first consult :ref:`Installation from Maven repository ` in order to add XGBoost4J-Spark as a dependency for your project. We provide both stable releases and snapshots. .. note:: XGBoost4J-Spark requires Apache Spark 2.4+ diff --git a/jvm-packages/pom.xml b/jvm-packages/pom.xml index aac20a41802a..bb593bf5e006 100644 --- a/jvm-packages/pom.xml +++ b/jvm-packages/pom.xml @@ -205,6 +205,29 @@ + + release-to-s3 + + + maven-s3-snapshot-repo + s3://xgboost-maven-repo/snapshot + + + maven-s3-release-repo + s3://xgboost-maven-repo/release + + + + + maven-s3-snapshot-repo + https://s3.amazonaws.com/xgboost-maven-repo/snapshot + + + maven-s3-release-repo + https://s3.amazonaws.com/xgboost-maven-repo/release + + + @@ -324,6 +347,13 @@ + + + org.kuali.maven.wagons + maven-s3-wagon + 1.2.1 + + diff --git a/tests/ci_build/deploy_jvm_packages.sh b/tests/ci_build/deploy_jvm_packages.sh new file mode 100755 index 000000000000..cd74da370daa --- /dev/null +++ b/tests/ci_build/deploy_jvm_packages.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e +set -x + +if [ $# -ne 1 ]; then + echo "Usage: $0 [spark version]" + exit 1 +fi + +spark_version=$1 + +# Initialize local Maven repository +./tests/ci_build/initialize_maven.sh + +rm -rf build/ +cd jvm-packages +# re-build package without Mock Rabit +mvn --no-transfer-progress package -Dspark.version=${spark_version} -DskipTests + +# deploy to S3 bucket xgboost-maven-repo +mvn --no-transfer-progress deploy -P release-to-s3 -DskipTests + +set +x +set +e