HBASE-17997: In dev environment, add jruby-complete jar to classpath only when jruby is needed
Signed-off-by: tedyu <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/4ab94744 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/4ab94744 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/4ab94744 Branch: refs/heads/HBASE-14614 Commit: 4ab94744e2e17a9ec4614ebb5ad80598e5dfbcd5 Parents: 3e426b2 Author: Xiang Li <[email protected]> Authored: Wed May 24 14:57:37 2017 +0800 Committer: tedyu <[email protected]> Committed: Thu May 25 08:07:50 2017 -0700 ---------------------------------------------------------------------- bin/hbase | 19 ++++++++++++++----- bin/hbase.cmd | 21 +++++++++++++++++---- hbase-assembly/pom.xml | 17 +++++++++++++++++ 3 files changed, 48 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/4ab94744/bin/hbase ---------------------------------------------------------------------- diff --git a/bin/hbase b/bin/hbase index fa70f6e..d7a8069 100755 --- a/bin/hbase +++ b/bin/hbase @@ -320,11 +320,20 @@ if [[ $jruby_needed ]]; then HBASE_OPTS="$HBASE_OPTS -Djruby.home=$JRUBY_HOME -Djruby.lib=$JRUBY_HOME/lib" else # JRUBY_HOME is not specified explicitly - # add jruby packaged with HBase to CLASSPATH - JRUBY_PACKAGED_WITH_HBASE="$HBASE_HOME/lib/ruby/*.jar" - for jruby_jar in $JRUBY_PACKAGED_WITH_HBASE; do - CLASSPATH=$jruby_jar:$CLASSPATH; - done + if $in_dev_env; then # in dev environment + F_JRUBY="${HBASE_HOME}/target/cached_classpath_jruby.txt" + if [ ! -f "${F_JRUBY}" ]; then + echo "As this is a development environment, we need ${F_JRUBY} to be generated from maven (command: mvn install -DskipTests)" + exit 1 + fi + CLASSPATH=$(cat "${F_JRUBY}"):$CLASSPATH; + else # not in dev environment + # add jruby packaged with HBase to CLASSPATH + JRUBY_PACKAGED_WITH_HBASE="$HBASE_HOME/lib/ruby/*.jar" + for jruby_jar in $JRUBY_PACKAGED_WITH_HBASE; do + CLASSPATH=$jruby_jar:$CLASSPATH; + done + fi fi fi http://git-wip-us.apache.org/repos/asf/hbase/blob/4ab94744/bin/hbase.cmd ---------------------------------------------------------------------- diff --git a/bin/hbase.cmd b/bin/hbase.cmd index 67a3bc1..457e4f7 100644 --- a/bin/hbase.cmd +++ b/bin/hbase.cmd @@ -286,10 +286,23 @@ if defined jruby-needed ( @rem JRUBY_HOME is not defined if not defined JRUBY_HOME ( - @rem add jruby packaged with HBase to CLASSPATH - set JRUBY_PACKAGED_WITH_HBASE=%HBASE_HOME%\lib\ruby\* - if defined jruby-needed ( - set CLASSPATH=!JRUBY_PACKAGED_WITH_HBASE!;!CLASSPATH! + @rem in dev environment + if "%in_dev_env%"=="true" ( + set cached_classpath_jruby_filename=%HBASE_HOME%\target\cached_classpath_jruby.txt + if not exist "!cached_classpath_jruby_filename!" ( + echo "As this is a development environment, we need !cached_classpath_jruby_filename! to be generated from maven (command: mvn install -DskipTests)" + goto :eof + ) + for /f "delims=" %%i in ('type "!cached_classpath_jruby_filename!"') do set CLASSPATH=%%i;%CLASSPATH% + ) + + @rem not in dev environment + if "%in_dev_env%"=="false" ( + @rem add jruby packaged with HBase to CLASSPATH + set JRUBY_PACKAGED_WITH_HBASE=%HBASE_HOME%\lib\ruby\* + if defined jruby-needed ( + set CLASSPATH=!JRUBY_PACKAGED_WITH_HBASE!;!CLASSPATH! + ) ) ) ) http://git-wip-us.apache.org/repos/asf/hbase/blob/4ab94744/hbase-assembly/pom.xml ---------------------------------------------------------------------- diff --git a/hbase-assembly/pom.xml b/hbase-assembly/pom.xml index 79d154d..b65a9b7 100644 --- a/hbase-assembly/pom.xml +++ b/hbase-assembly/pom.xml @@ -103,8 +103,25 @@ </goals> <configuration> <outputFile>${project.parent.basedir}/target/cached_classpath.txt</outputFile> + <excludeArtifactIds>jruby-complete</excludeArtifactIds> </configuration> </execution> + + <execution> + <!-- Generates a file containing jruby jar. + In dev environment, bin/hbase will read the file and add the jar into classpath when jruby is needed + --> + <id>create-hbase-generated-classpath-jruby</id> + <phase>test</phase> + <goals> + <goal>build-classpath</goal> + </goals> + <configuration> + <outputFile>${project.parent.basedir}/target/cached_classpath_jruby.txt</outputFile> + <includeArtifactIds>jruby-complete</includeArtifactIds> + </configuration> + </execution> + <!-- Build an aggregation of our templated NOTICE file and the NOTICE files in our dependencies. If MASSEMBLY-382 is fixed we could do this in the assembly
