jruby 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. #!/usr/bin/env bash
  2. jruby_install_build_nailgun()
  3. {
  4. __rvm_cd "${rvm_src_path}/$rvm_ruby_string/tool/nailgun" &&
  5. case "$rvm_ruby_version" in
  6. 1.2*|1.3*)
  7. true
  8. ;;
  9. *)
  10. env "${rvm_configure_env[@]}" ./configure --prefix=$rvm_ruby_home
  11. ;;
  12. esac &&
  13. __rvm_make "${rvm_make_flags[@]}"
  14. }
  15. jruby_install_ant()
  16. {
  17. __rvm_log_command "ant.jar" "$rvm_ruby_string - #ant jar" __rvm_ant jar || return $?
  18. [[ -f "${rvm_src_path}/$rvm_ruby_string/bin/jruby" ]] ||
  19. {
  20. result=$?
  21. rvm_error "JRuby reported it was installed successfully, but RVM could not find proper installation,
  22. please check why '${rvm_src_path}/$rvm_ruby_string/bin/jruby' was not created,
  23. maybe here '$rvm_log_path/$rvm_ruby_string/ant.jar.log',
  24. also make sure to report an error here 'https://github.com/jruby/jruby/issues'
  25. about not returning non zero status in case of errors."
  26. return $result
  27. }
  28. if
  29. (( ${#rvm_configure_flags[@]} ))
  30. then
  31. __rvm_log_command "ant.jar.flags" "$rvm_ruby_string - #ant jar ${rvm_configure_flags[*]}" \
  32. __rvm_ant jar "${rvm_configure_flags[@]}" || return $?
  33. fi
  34. __rvm_log_command "ant.cext" "$rvm_ruby_string - #ant cext" __rvm_ant cext "${rvm_configure_flags[@]}" ||
  35. rvm_warn "cext is known to fail please report here: https://jira.codehaus.org/browse/JRUBY"
  36. __rvm_version_compare "$rvm_ruby_version" -ge "1.7.0" ||
  37. __rvm_log_command "nailgun" "$rvm_ruby_string - #nailgun" jruby_install_build_nailgun ||
  38. return $?
  39. }
  40. jruby_install_mvn_command()
  41. {
  42. __rvm_log_command "$mvn_label" "$rvm_ruby_string - #$mvn_label" "${mvn_command[@]}" || return $?
  43. }
  44. jruby_install_mvn()
  45. {
  46. \typeset -a mvn_command
  47. \typeset mvn_label
  48. mvn_command=( "${1:-mvn}" )
  49. mvn_label="{1:-mvn}"
  50. mvn_label="${mvn_command##*/}"
  51. jruby_install_mvn_command || return $?
  52. if
  53. (( ${#rvm_configure_flags[@]} ))
  54. then
  55. mvn_command+=( "${rvm_configure_flags[@]}" )
  56. mvn_label+="_flags"
  57. jruby_install_mvn_command || return $?
  58. fi
  59. }
  60. jruby_install_mvnw()
  61. {
  62. jruby_install_mvn "${rvm_src_path}/$rvm_ruby_string/mvnw" || return $?
  63. }
  64. jruby_install_check_java()
  65. {
  66. builtin command -v java > /dev/null ||
  67. {
  68. printf "%b" "java must be installed and in PATH for JRuby."
  69. return 1
  70. }
  71. }
  72. jruby_install_check_jruby_home()
  73. {
  74. if
  75. [[ -n "$JRUBY_HOME" ]]
  76. then
  77. printf "%b" "You have environment variable JRUBY_HOME set, please unset it before installing/using JRuby."
  78. return 2
  79. fi
  80. }
  81. jruby_install_check_java_home()
  82. {
  83. if
  84. [[ -z "${JAVA_HOME:-}" ]]
  85. then
  86. export JAVA_HOME="$(
  87. cd "${rvm_scripts_path}/extras/java_read_properties"
  88. java ReadProperties java.home
  89. )"
  90. if
  91. [[ -n "$JAVA_HOME" &&
  92. -x "$JAVA_HOME/../bin/javac" &&
  93. -f "$JAVA_HOME/../lib/tools.jar"
  94. ]]
  95. then
  96. rvm_debug "Detected JAVA_HOME=$JAVA_HOME has JDK level up"
  97. JAVA_HOME="${JAVA_HOME%/*}" # cd ..
  98. fi
  99. rvm_warn "\$JAVA_HOME was empty, setting up JAVA_HOME=$JAVA_HOME, if it fails try setting JAVA_HOME to something sane and try again."
  100. fi
  101. }
  102. jruby_install()
  103. {
  104. __rvm_setup_compile_environment "${rvm_ruby_string}" || return $?
  105. jruby_install_check_java || return $?
  106. jruby_install_check_jruby_home || return $?
  107. jruby_install_check_java_home
  108. __rvm_cd "${rvm_src_path}"
  109. rvm_ruby_tag="${rvm_ruby_version}"
  110. __rvm_fetch_ruby || return $?
  111. __rvm_cd "${rvm_src_path}/$rvm_ruby_string"
  112. __rvm_apply_patches
  113. \typeset method
  114. method=$( jruby_installation_method "${rvm_ruby_string}" "${rvm_ruby_version}" ) || return $?
  115. jruby_install_$method || return $?
  116. __rvm_rm_rf "$rvm_ruby_home" && \command \mkdir -p "$rvm_ruby_home" &&
  117. __rvm_log_command "install" "$rvm_ruby_string - #installing to $rvm_ruby_home" \
  118. __rvm_cp -Rf "${rvm_src_path}/$rvm_ruby_string"/{bin,lib} "$rvm_ruby_home"/ || return $?
  119. case ${rvm_ruby_string} in
  120. jruby-head*|jruby-1.7.*)
  121. (
  122. __rvm_cd "$rvm_ruby_home/bin/"
  123. for binary in irb ruby gem
  124. do
  125. [[ -f "${binary}" ]] || ln -fs "j${binary}" "${binary}"
  126. done
  127. )
  128. ;;
  129. *)
  130. (
  131. __rvm_cd "$rvm_ruby_home/bin/"
  132. for binary in jirb jruby jgem
  133. do
  134. ln -fs "$binary" "${binary#j}"
  135. done
  136. )
  137. ;;
  138. esac
  139. chmod +x "$rvm_ruby_home/bin/jruby"
  140. __rvm_initial_gemsets_create "$rvm_ruby_home/bin/ruby"
  141. case ${rvm_ruby_string} in
  142. jruby-head*|jruby-1.7.*)
  143. binaries=()
  144. ;;
  145. *)
  146. binaries=(jrubyc jirb_swing jirb jgem rdoc ri spec autospec testrb ast generate_yaml_index.rb rake)
  147. ;;
  148. esac
  149. __rvm_post_install
  150. __rvm_fetch_ruby_cleanup
  151. }