ARROW-6103: [Release][Java] Remove mvn release plugin

We want to stop using the maven release plugin because it commits to the repo both in the `prepare` and `perform` tasks and adds complexity to the release process.

This PR removes the plugin and updates the release preparation script to use the maven versions plugin to update the version number in the pom files.

We will need to run `mvn deploy` to publish the artifacts and I'm not sure where that needs to happen (`mvn release:perform` was previously invoking the `deploy` phase).

Closes #9155 from andygrove/remove-mvn-release-plugin

Lead-authored-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
Co-authored-by: Andy Grove <andygrove73@gmail.com>
Signed-off-by: Krisztián Szűcs <szucs.krisztian@gmail.com>
diff --git a/dev/release/01-perform.sh b/dev/release/01-perform.sh
deleted file mode 100755
index 94ae61f..0000000
--- a/dev/release/01-perform.sh
+++ /dev/null
@@ -1,50 +0,0 @@
-#!/bin/bash
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements.  See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership.  The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License.  You may obtain a copy of the License at
-#
-#   http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied.  See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
-set -e
-
-SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
-
-pushd "${SOURCE_DIR}/../../java"
-git submodule update --init --recursive
-
-profile=arrow-jni # this includes components which depend on arrow cpp.
-
-cpp_dir="${PWD}/../cpp"
-cpp_build_dir=$(mktemp -d -t "apache-arrow-cpp.XXXXX")
-pushd ${cpp_build_dir}
-cmake \
-  -DARROW_GANDIVA=ON \
-  -DARROW_GANDIVA_JAVA=ON \
-  -DARROW_JNI=ON \
-  -DARROW_ORC=ON \
-  -DCMAKE_BUILD_TYPE=release \
-  -G Ninja \
-  "${cpp_dir}"
-ninja
-popd
-
-export ARROW_TEST_DATA=${PWD}/../testing/data
-mvn \
-  release:perform \
-  -Darguments=-Darrow.cpp.build.dir=${cpp_build_dir}/release \
-  -P ${profile}
-rm -rf ${cpp_build_dir}
-
-popd
diff --git a/dev/release/00-prepare-test.rb b/dev/release/01-prepare-test.rb
similarity index 99%
rename from dev/release/00-prepare-test.rb
rename to dev/release/01-prepare-test.rb
index 9e2a798..b316ad2 100644
--- a/dev/release/00-prepare-test.rb
+++ b/dev/release/01-prepare-test.rb
@@ -31,7 +31,7 @@
       Dir.chdir(@test_git_repository) do
         @tag_name = "apache-arrow-#{@release_version}"
         @release_branch = "release-#{@release_version}-rc0"
-        @script = "dev/release/00-prepare.sh"
+        @script = "dev/release/01-prepare.sh"
         git("checkout", "-b", @release_branch, @current_commit)
         yield
       end
@@ -54,7 +54,7 @@
       env["PREPARE_#{target}"] = "1"
     end
     env = env.merge(additional_env)
-    sh(env, @script, @release_version, @next_version)
+    sh(env, @script, @release_version, @next_version, "0")
   end
 
   def parse_patch(patch)
diff --git a/dev/release/00-prepare.sh b/dev/release/01-prepare.sh
similarity index 83%
rename from dev/release/00-prepare.sh
rename to dev/release/01-prepare.sh
index 3e3ce19..80703c2 100755
--- a/dev/release/00-prepare.sh
+++ b/dev/release/01-prepare.sh
@@ -21,8 +21,8 @@
 
 SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
 
-if [ "$#" -ne 2 ]; then
-  echo "Usage: $0 <version> <next_version>"
+if [ "$#" -ne 3 ]; then
+  echo "Usage: $0 <version> <next_version> <rc-num>"
   exit 1
 fi
 
@@ -172,17 +172,47 @@
 
 version=$1
 next_version=$2
-next_version_snapshot=${next_version}-SNAPSHOT
-tag=apache-arrow-${version}
+next_version_snapshot="${next_version}-SNAPSHOT"
+rc_number=$3
+
+release_tag="apache-arrow-${version}"
+release_branch="release-${version}"
+release_candidate_branch="release-${version}-rc${rc_number}"
 
 : ${PREPARE_DEFAULT:=1}
 : ${PREPARE_CHANGELOG:=${PREPARE_DEFAULT}}
 : ${PREPARE_LINUX_PACKAGES:=${PREPARE_DEFAULT}}
 : ${PREPARE_VERSION_PRE_TAG:=${PREPARE_DEFAULT}}
+: ${PREPARE_BRANCH:=${PREPARE_DEFAULT}}
 : ${PREPARE_TAG:=${PREPARE_DEFAULT}}
 : ${PREPARE_VERSION_POST_TAG:=${PREPARE_DEFAULT}}
 : ${PREPARE_DEB_PACKAGE_NAMES:=${PREPARE_DEFAULT}}
 
+if [ ${PREPARE_TAG} -gt 0 ]; then
+  if [ $(git tag -l "${release_tag}") ]; then
+    echo "Delete existing git tag $release_tag"
+    git tag -d "${release_tag}"
+  fi
+fi
+
+if [ ${PREPARE_BRANCH} -gt 0 ]; then
+  if [[ $(git branch -l "${release_candidate_branch}") ]]; then
+    next_rc_number=$(($rc_number+1))
+    echo "Branch ${release_candidate_branch} already exists, so create a new release candidate:"
+    echo "1. Checkout the master branch for major releases and maint-<version> for patch releases."
+    echo "2. Execute the script again with bumped RC number."
+    echo "Commands:"
+    echo "   git checkout master"
+    echo "   dev/release/01-prepare.sh ${version} ${next_version} ${next_rc_number}"
+    exit 1
+  fi
+
+  echo "Create local branch ${release_candidate_branch} for release candidate ${rc_number}"
+  git checkout -b ${release_candidate_branch}
+fi
+
+############################## Pre-Tag Commits ##############################
+
 if [ ${PREPARE_CHANGELOG} -gt 0 ]; then
   echo "Updating changelog for $version"
   # Update changelog
@@ -204,40 +234,16 @@
 fi
 
 if [ ${PREPARE_VERSION_PRE_TAG} -gt 0 ]; then
-  echo "prepare release ${version} on tag ${tag} then reset to version ${next_version_snapshot}"
+  echo "Prepare release ${version} on tag ${release_tag} then reset to version ${next_version_snapshot}"
 
   update_versions "${version}" "${next_version}" "release"
   git commit -m "[Release] Update versions for ${version}"
 fi
 
+############################## Tag the Release ##############################
+
 if [ ${PREPARE_TAG} -gt 0 ]; then
-  profile=arrow-jni # this includes components which depend on arrow cpp.
-  pushd "${SOURCE_DIR}/../../java"
-  git submodule update --init --recursive
-  cpp_dir="${PWD}/../cpp"
-  cpp_build_dir=$(mktemp -d -t "apache-arrow-cpp.XXXXX")
-  pushd ${cpp_build_dir}
-  cmake \
-    -DARROW_GANDIVA=ON \
-    -DARROW_GANDIVA_JAVA=ON \
-    -DARROW_JNI=ON \
-    -DARROW_ORC=ON \
-    -DCMAKE_BUILD_TYPE=release \
-    -G Ninja \
-    "${cpp_dir}"
-  ninja
-  popd
-  mvn release:clean
-  mvn \
-    release:prepare \
-    -Darguments=-Darrow.cpp.build.dir=${cpp_build_dir}/release \
-    -DautoVersionSubmodules \
-    -DdevelopmentVersion=${next_version_snapshot} \
-    -DreleaseVersion=${version} \
-    -Dtag=${tag} \
-    -P ${profile}
-  rm -rf ${cpp_build_dir}
-  popd
+  git tag -a "${release_tag}" -m "[Release] Apache Arrow Release ${version}"
 fi
 
 ############################## Post-Tag Commits #############################
@@ -283,5 +289,3 @@
     cd -
   fi
 fi
-
-echo "Finish staging binary artifacts by running: dev/release/01-perform.sh"
diff --git a/dev/release/03-binary-submit.sh b/dev/release/03-binary-submit.sh
new file mode 100755
index 0000000..1bdbc20
--- /dev/null
+++ b/dev/release/03-binary-submit.sh
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+
+if [ "$#" -ne 2 ]; then
+  echo "Usage: $0 <version> <rc-num>"
+  exit
+fi
+
+version=$1
+rc_number=$2
+version_with_rc="${version}-rc${rc_number}"
+crossbow_job_prefix="release-${version_with_rc}"
+
+release_tag="apache-arrow-${version}"
+release_candidate_branch="release-${version}-rc${rc_number}"
+
+: ${GIT_REMOTE:="origin"}
+
+git checkout ${release_candidate_branch}
+git push -u ${GIT_REMOTE} ${release_candidate_branch}
+
+# archery will submit a job with id: "${crossbow_job_prefix}-0" unless there
+# are jobs submitted with the same prefix (the integer at the end is auto
+# incremented)
+archery crossbow submit \
+    --job-prefix ${crossbow_job_prefix} \
+    --arrow-version ${version_with_rc} \
+    --group packaging
diff --git a/dev/release/04-binary-download.sh b/dev/release/04-binary-download.sh
new file mode 100755
index 0000000..d0b61b0
--- /dev/null
+++ b/dev/release/04-binary-download.sh
@@ -0,0 +1,38 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+set -e
+
+if [ "$#" -ne 2 ]; then
+  echo "Usage: $0 <version> <rc-num>"
+  exit
+fi
+
+version=$1
+rc_number=$2
+version_with_rc="${version}-rc${rc_number}"
+crossbow_job_prefix="release-${version_with_rc}"
+
+# archery will submit a job with id: "${crossbow_job_prefix}-0" unless there
+# are jobs submitted with the same prefix (the integer at the end is auto
+# incremented)
+: ${CROSSBOW_JOB_ID:="${crossbow_job_prefix}-0"}
+
+archery crossbow download-artifacts ${CROSSBOW_JOB_ID}
diff --git a/dev/release/03-binary.sh b/dev/release/05-binary-upload.sh
similarity index 91%
rename from dev/release/03-binary.sh
rename to dev/release/05-binary-upload.sh
index 3b845a1..4a360c2 100755
--- a/dev/release/03-binary.sh
+++ b/dev/release/05-binary-upload.sh
@@ -23,19 +23,20 @@
 
 SOURCE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 
-if [ "$#" -ne 3 ]; then
-  echo "Usage: $0 <version> <rc-num> <artifact-dir>"
+if [ "$#" -ne 2 ]; then
+  echo "Usage: $0 <version> <rc-num>"
   exit
 fi
 
 version=$1
 rc=$2
-artifact_dir=$3
 
-if [ -z "$artifact_dir" ]; then
-  echo "artifact_dir is empty"
-  exit 1
-fi
+version_with_rc="${version}-rc${rc}"
+crossbow_job_prefix="release-${version_with_rc}"
+crossbow_package_dir="${SOURCE_DIR}/../../packages"
+
+: ${CROSSBOW_JOB_ID:="${crossbow_job_prefix}-0"}
+artifact_dir="${crossbow_package_dir}/${CROSSBOW_JOB_ID}"
 
 if [ ! -e "$artifact_dir" ]; then
   echo "$artifact_dir does not exist"
@@ -47,8 +48,6 @@
   exit 1
 fi
 
-artifact_dir="$(pwd)/${artifact_dir}"
-
 cd "${SOURCE_DIR}"
 
 : ${BINTRAY_REPOSITORY_CUSTOM:=${BINTRAY_REPOSITORY:-}}
diff --git a/dev/release/post-11-java.sh b/dev/release/post-11-java.sh
new file mode 100755
index 0000000..d9dc32a
--- /dev/null
+++ b/dev/release/post-11-java.sh
@@ -0,0 +1,69 @@
+#!/bin/bash
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+set -e
+set -o pipefail
+
+SOURCE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
+
+if [ "$#" -ne 1 ]; then
+  echo "Usage: $0 <version>"
+  exit
+fi
+
+version=$1
+archive_name=apache-arrow-${version}
+tar_gz=${archive_name}.tar.gz
+
+rm -f ${tar_gz}
+curl \
+  --remote-name \
+  --fail \
+  https://downloads.apache.org/arrow/arrow-${version}/${tar_gz}
+rm -rf ${archive_name}
+tar xf ${tar_gz}
+
+# build the jni bindings similarly like the 01-perform.sh does
+mkdir -p ${archive_name}/cpp/java-build
+pushd ${archive_name}/cpp/java-build
+cmake \
+  -DARROW_GANDIVA=ON \
+  -DARROW_GANDIVA_JAVA=ON \
+  -DARROW_JNI=ON \
+  -DARROW_ORC=ON \
+  -DCMAKE_BUILD_TYPE=release \
+  -G Ninja \
+  ..
+ninja
+popd
+
+# go in the java subfolder
+pushd ${archive_name}/java
+# stage the artifacts using both the apache-release and arrow-jni profiles
+mvn -Papache-release,arrow-jni -Darrow.cpp.build.dir=$(realpath ../cpp/java-build) deploy
+popd
+
+echo "Success! The maven artifacts have been stated. Proceed with the following steps:"
+echo "1. Login to the apache repository: https://repository.apache.org/#stagingRepositories"
+echo "2. Select the arrow staging repository you just just created: orgapachearrow-100x"
+echo "3. Click the \"close\" button"
+echo "4. Once validation has passed, click the \"release\" button"
+echo ""
+echo "Note, that you must set up Maven to be able to publish to Apache's repositories."
+echo "Read more at https://www.apache.org/dev/publishing-maven-artifacts.html."
diff --git a/java/pom.xml b/java/pom.xml
index c776b83..35a87cb 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -401,17 +401,7 @@
             <argLine>-Darrow.vector.max_allocation_bytes=1048576</argLine>
           </configuration>
         </plugin>
-        <plugin>
-          <groupId>org.apache.maven.plugins</groupId>
-          <artifactId>maven-release-plugin</artifactId>
-          <version>2.5.2</version>
-          <configuration>
-            <useReleaseProfile>false</useReleaseProfile>
-            <pushChanges>false</pushChanges>
-            <goals>deploy</goals>
-            <arguments>-Papache-release ${arguments}</arguments>
-          </configuration>
-        </plugin>
+
 
         <!--This plugin's configuration is used to store Eclipse m2e settings
           only. It has no influence on the Maven build itself. -->