HBASE-17997: In dev environment, add jruby-complete jar to classpath only when jruby is needed

Signed-off-by: tedyu <yuzhihong@gmail.com>
This commit is contained in:
Xiang Li 2017-05-24 14:57:37 +08:00 committed by tedyu
parent 3e426b2f85
commit 4ab94744e2
3 changed files with 48 additions and 9 deletions

View File

@ -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

View File

@ -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!
)
)
)
)

View File

@ -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