@@ -75,7 +75,7 @@ function banner {
7575}
7676
7777function  log  {
78-   echo  " $( date -u +" %Y-%m-%dT%H:%M:%SZ" ) ${1}  " 
78+   echo  " $( date -u +" %Y-%m-%dT%H:%M:%SZ" ) $*  " 
7979}
8080
8181#  current number of seconds since epoch
@@ -298,12 +298,11 @@ EOF
298298  fi 
299299  GPG_ARGS=(" ${GPG_ARGS[@]} " " ${GPG_KEY} " 
300300
301-   if  !  is_dry_run;  then 
302-     if  [ -z  " $ASF_PASSWORD " ;  then 
303-       stty -echo &&  printf  " ASF_PASSWORD: " &&  read  -r ASF_PASSWORD &&  printf  ' \n' &&  stty echo 
304-     fi 
305-   else 
306-     ASF_PASSWORD=" ***INVALID***" 
301+   #  The nexus staging plugin needs the password to contact to remote server even if
302+   #  skipRemoteStaging is set to true, not sure why so here we need the password even
303+   #  if this is a dry run
304+   if  [ -z  " $ASF_PASSWORD " ;  then 
305+     stty -echo &&  printf  " ASF_PASSWORD: " &&  read  -r ASF_PASSWORD &&  printf  ' \n' &&  stty echo 
307306  fi 
308307
309308  export  ASF_PASSWORD
@@ -561,7 +560,6 @@ function get_jira_name {
561560function  update_releasenotes  {
562561  local  project_dir=" $1 " 
563562  local  jira_fix_version=" $2 " 
564-   local  previous_jira_fix_version=" $3 " 
565563  local  jira_project
566564  local  timing_token
567565  timing_token=" $( start_step) " 
@@ -583,15 +581,15 @@ function update_releasenotes {
583581        " ${project_dir} /CHANGES.md" ||  true 
584582  else 
585583    #  should be hbase 3.x, will copy CHANGES.md from archive.a.o/dist
586-     curl --location --fail --silent --show-error --output ${project_dir} /CHANGES.md " https://archive.apache.org/dist/hbase/${previous_jira_fix_version } /CHANGES.md" 
584+     curl --location --fail --silent --show-error --output ${project_dir} /CHANGES.md " https://archive.apache.org/dist/hbase/${PREV_VERSION } /CHANGES.md" 
587585  fi 
588586  if  [ -f  " ${project_dir} /RELEASENOTES.md" ;  then 
589587    sed -i -e \
590588        " /^# ${jira_project}   ${jira_fix_version}  Release Notes/,/^# ${jira_project} /{//!d; /^# ${jira_project}   ${jira_fix_version}  Release Notes/d;}" 
591589        " ${project_dir} /RELEASENOTES.md" ||  true 
592590  else 
593591    #  should be hbase 3.x, will copy CHANGES.md from archive.a.o/dist
594-     curl --location --fail --silent --show-error --output ${project_dir} /RELEASENOTES.md " https://archive.apache.org/dist/hbase/${previous_jira_fix_version } /RELEASENOTES.md" 
592+     curl --location --fail --silent --show-error --output ${project_dir} /RELEASENOTES.md " https://archive.apache.org/dist/hbase/${PREV_VERSION } /RELEASENOTES.md" 
595593  fi 
596594
597595  #  Yetus will not generate CHANGES if no JIRAs fixed against the release version
@@ -645,39 +643,30 @@ make_src_release() {
645643  stop_step " ${timing_token} " 
646644}
647645
648- #  Make binary release.
649- #  Takes as arguments first the project name -- e.g. hbase or hbase-operator-tools
650- #  -- and then the version string. Expects to find checkout adjacent to this script
651- #  named for 'project', the first arg passed.
652- #  Expects the following three defines in the environment:
653- #  - GPG needs to be defined, with the path to GPG: defaults 'gpg'.
654- #  - GIT_REF which is the tag to create the tgz from: defaults to 'master'.
655- #  - MVN Default is "mvn -B --settings $MAVEN_SETTINGS_FILE".
656- #  For example:
657- #  $ GIT_REF="master" make_src_release hbase-operator-tools 1.0.0
658- make_binary_release () {
646+ build_release_binary () {
659647  local  project=" ${1} " 
660648  local  version=" ${2} " 
661649  local  base_name=" ${project} -${version} " 
662-   local  timing_token 
663-   timing_token= " $( start_step ) " 
664-   rm -rf  " ${base_name} " -bin * 
665-   cd   " $project "   ||   exit 
650+   local  extra_flags=() 
651+   if  [[  " ${version} "   =   * -hadoop3 ]]  ||  [[  " ${version} "   =   * -hadoop3-SNAPSHOT ]] ;   then 
652+     extra_flags=( " -Drevision= ${version} "   " -Dhadoop.profile=3.0 " ) 
653+   fi 
666654
655+   cd  " $project " ||  exit 
667656  git clean -d -f -x
668657  #  Three invocations of maven. This seems to work. One to
669658  #  populate the repo, another to build the site, and then
670659  #  a third to assemble the binary artifact. Trying to do
671660  #  all in the one invocation fails; a problem in our
672661  #  assembly spec to in maven. TODO. Meantime, three invocations.
673-   cmd=(" ${MVN[@]} " 
662+   cmd=(" ${MVN[@]} " " ${extra_flags[@]} "   clean install -DskipTests)
674663  echo  " ${cmd[*]} " 
675664  " ${cmd[@]} " 
676-   cmd=(" ${MVN[@]} " 
665+   cmd=(" ${MVN[@]} " " ${extra_flags[@]} "   site -DskipTests)
677666  echo  " ${cmd[*]} " 
678667  " ${cmd[@]} " 
679668  kick_gpg_agent
680-   cmd=(" ${MVN[@]} " " ${PUBLISH_PROFILES[@]} " 
669+   cmd=(" ${MVN[@]} " " ${extra_flags[@]} "   install assembly:single -DskipTests -Dcheckstyle.skip=true " ${PUBLISH_PROFILES[@]} " 
681670  echo  " ${cmd[*]} " 
682671  " ${cmd[@]} " 
683672
@@ -694,6 +683,30 @@ make_binary_release() {
694683    cd  .. ||  exit 
695684    log " No ${f_bin_prefix} *-bin.tar.gz product; expected?" 
696685  fi 
686+ }
687+ 
688+ #  Make binary release.
689+ #  Takes as arguments first the project name -- e.g. hbase or hbase-operator-tools
690+ #  -- and then the version string. Expects to find checkout adjacent to this script
691+ #  named for 'project', the first arg passed.
692+ #  Expects the following three defines in the environment:
693+ #  - GPG needs to be defined, with the path to GPG: defaults 'gpg'.
694+ #  - GIT_REF which is the tag to create the tgz from: defaults to 'master'.
695+ #  - MVN Default is "mvn -B --settings $MAVEN_SETTINGS_FILE".
696+ #  For example:
697+ #  $ GIT_REF="master" make_src_release hbase-operator-tools 1.0.0
698+ make_binary_release () {
699+   local  project=" ${1} " 
700+   local  version=" ${2} " 
701+   local  base_name=" ${project} -${version} " 
702+   local  timing_token
703+   timing_token=" $( start_step) " 
704+   rm -rf " ${base_name} " * 
705+ 
706+   build_release_binary " ${project} " " ${version} " 
707+   if  should_build_with_hadoop3 " $project /pom.xml" ;  then 
708+     build_release_binary " ${project} " " $( get_hadoop3_version " ${version} " ) " 
709+   fi 
697710
698711  stop_step " ${timing_token} " 
699712}
@@ -746,6 +759,7 @@ function maven_deploy { #inputs: <snapshot|release> <log_file_path>
746759  #  Invoke with cwd=$PROJECT
747760  local  deploy_type=" $1 " 
748761  local  mvn_log_file=" $2 " # secondary log file used later to extract staged_repo_id
762+   local  staging_dir
749763  if  [[ " $deploy_type " !=  " snapshot" &&  " $deploy_type " !=  " release" ;  then 
750764    error " unrecognized deploy type, must be 'snapshot'|'release'" 
751765  fi 
@@ -759,6 +773,8 @@ function maven_deploy { #inputs: <snapshot|release> <log_file_path>
759773  elif  [[ " $deploy_type " ==  " release" &&  [[ " $RELEASE_VERSION " =~  SNAPSHOT ]];  then 
760774    error " Non-snapshot release version must not include the word 'SNAPSHOT'; you gave version '$RELEASE_VERSION '" 
761775  fi 
776+   #  Just output to parent directory, the staging directory has a staging prefix already
777+   staging_dir=" $( dirname " $( pwd) " ) " 
762778  #  Publish ${PROJECT} to Maven repo
763779  #  shellcheck disable=SC2154
764780  log " Publishing ${PROJECT}  checkout at '$GIT_REF ' ($git_hash )" 
@@ -767,20 +783,44 @@ function maven_deploy { #inputs: <snapshot|release> <log_file_path>
767783  maven_set_version " $RELEASE_VERSION " 
768784  #  Prepare for signing
769785  kick_gpg_agent
770-   declare  -a mvn_goals=(clean)
771-   if  !  is_dry_run;  then 
772-     mvn_goals=(" ${mvn_goals[@]} " 
786+   declare  -a mvn_extra_flags=()
787+   if  is_dry_run;  then 
788+     #  In dry run mode, skip deploying to remote repo
789+     mvn_extra_flags=(" ${mvn_extra_flags[@]} " 
773790  fi 
774-   log " ${MVN[@]} " " ${PUBLISH_PROFILES[@]} " " ${mvn_goals[@]} " 
791+   log " ${MVN[@]} " 
792+     -DaltStagingDirectory=" ${staging_dir} " " ${PUBLISH_PROFILES[@]} " " ${mvn_extra_flags[@]} " 
775793  log " Logging to ${mvn_log_file} .  This will take a while..." 
776794  rm -f " $mvn_log_file " 
777795  #  The tortuous redirect in the next command allows mvn's stdout and stderr to go to mvn_log_file,
778796  #  while also sending stderr back to the caller.
779797  #  shellcheck disable=SC2094
780-   if  !  " ${MVN[@]} " " ${PUBLISH_PROFILES[@]} " 
781-       " ${mvn_goals[@]} " 1>>  " $mvn_log_file " 2>  >(  tee -a " $mvn_log_file " >&2  ) ;  then 
798+   if  !  " ${MVN[@]} " " ${PUBLISH_PROFILES[@]} " 
799+       -DaltStagingDirectory=" ${staging_dir} " " ${PUBLISH_PROFILES[@]} " " ${mvn_extra_flags[@]} " 
800+       1>>  " $mvn_log_file " 2>  >(  tee -a " $mvn_log_file " >&2  ) ;  then 
782801    error " Deploy build failed, for details see log at '$mvn_log_file '." 
783802  fi 
803+   local  hadoop3_version
804+   if  should_build_with_hadoop3 pom.xml;  then 
805+     hadoop3_version=" $( get_hadoop3_version " ${RELEASE_VERSION} " ) " 
806+     hadoop3_staging_dir=" ${staging_dir} -hadoop3" 
807+     log " Deploying artifacts for hadoop3..." 
808+     log " ${MVN[@]} " 
809+       -Drevision=" ${hadoop3_version} " 
810+       -DaltStagingDirectory=" ${hadoop3_staging_dir} " " ${PUBLISH_PROFILES[@]} " " ${mvn_extra_flags[@]} " 
811+     {
812+       echo  " ========================================================================" 
813+       echo  " Deploy build for hadoop3" 
814+       echo  " ========================================================================" 
815+     } >>  " $mvn_log_file " 
816+     #  shellcheck disable=SC2094
817+     if  !  " ${MVN[@]} " " ${PUBLISH_PROFILES[@]} " 
818+         -Drevision=" ${hadoop3_version} " 
819+         -DaltStagingDirectory=" ${hadoop3_staging_dir} " " ${PUBLISH_PROFILES[@]} " " ${mvn_extra_flags[@]} " 
820+         1>>  " $mvn_log_file " 2>  >(  tee -a " $mvn_log_file " >&2  ) ;  then 
821+       error " Deploy build failed, for details see log at '$mvn_log_file '." 
822+     fi 
823+   fi 
784824  log " BUILD SUCCESS." 
785825  stop_step " ${timing_token} " 
786826  return  0
@@ -798,3 +838,36 @@ function is_tracked() {
798838  git ls-files --error-unmatch " $file " & > /dev/null
799839  return  $? 
800840}
841+ 
842+ #  When we have all the below conditions matched, we will build hadoop3 binaries
843+ #  1. Use $revision place holder as version in pom
844+ #  2. Has a hadoop-2.0 profile
845+ #  3. Has a hadoop-3.0 profile
846+ function  should_build_with_hadoop3()  {
847+   local  pom=" $1 " 
848+   maven_version=" $( parse_version <  " ${pom} " ) " 
849+   #  We do not want to expand ${revision} here, see https://maven.apache.org/maven-ci-friendly.html
850+   #  If we use ${revision} as placeholder, the way to bump maven version will be different
851+   #  shellcheck disable=SC2016
852+   if  [[ " ${maven_version} " !=  ' ${revision}' ;  then 
853+     return  1
854+   fi 
855+   if  !  xmllint --xpath " //*[local-name()='project']/*[local-name()='profiles']/*[local-name()='profile']/*[local-name()='id']/text()" " ${pom} " 
856+     |  grep -q ^hadoop-2.0$;  then 
857+     return  1
858+   fi 
859+   if  !  xmllint --xpath " //*[local-name()='project']/*[local-name()='profiles']/*[local-name()='profile']/*[local-name()='id']/text()" " ${pom} " 
860+     |  grep -q ^hadoop-3.0$;  then 
861+     return  1
862+   fi 
863+   return  0
864+ }
865+ 
866+ function  get_hadoop3_version()  {
867+   local  version=" $1 " 
868+   if  [[ " ${version} " =~  -S NAPSHOT$ ]];  then 
869+     echo  " ${version/ -SNAPSHOT/ -hadoop3-SNAPSHOT} " 
870+   else 
871+     echo  " ${version} -hadoop3" 
872+   fi 
873+ }
0 commit comments