Skip to content

Commit

Permalink
Add sqlline.bat.
Browse files Browse the repository at this point in the history
On cygwin, fix sqlline to work around jline/jline2#62.

sqlline now uses build-classpath on both linux and cygwin, in contrast to sqlline.bat, which uses copy-dependencies.
  • Loading branch information
julianhyde committed Mar 21, 2014
1 parent 10aeb5d commit 5a4126f
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 4 deletions.
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,15 @@
</execution>
</executions>
</plugin>

<!-- Not part of the standard build. sqlline.bat invokes copy-dependencies
because windows doesn't like long paths. -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
Expand Down
45 changes: 41 additions & 4 deletions sqlline
Original file line number Diff line number Diff line change
@@ -1,21 +1,58 @@
#!/bin/bash
# sqlline - Script to launch SQL shell
#
# Licensed to Julian Hyde under one or more contributor license
# agreements. See the NOTICE file distributed with this work for
# additional information regarding copyright ownership.
#
# Julian Hyde 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.
#
# Example:
# $ ./sqlline
# sqlline> !connect jdbc:optiq: admin admin

# Deduce whether we are running cygwin
case $(uname -s) in
(CYGWIN*) cygwin=true;;
(*) cygwin=;;
esac

# Build classpath on first call. (To force rebuild, remove .classpath.txt.)
cd $(dirname $0)
if [ ! -f .fullclasspath.txt ]; then
mvn dependency:build-classpath -Dmdep.outputFile=.classpath.txt
awk -v RS=: -v ORS=: '{if(!m[$0]) {m[$0]=1; print}}' .classpath.txt */.classpath.txt > .fullclasspath.txt
mvn dependency:build-classpath -Dmdep.outputFile=target/classpath.txt
awk -v RS=: -v ORS=: '{if(!m[$0]) {m[$0]=1; print}}' \
target/classpath.txt \
*/target/classpath.txt > target/fullclasspath.txt
fi

CP=
for module in core mongodb spark splunk; do
for module in core avatica mongodb spark splunk; do
CP=${CP}${module}/target/classes:
CP=${CP}${module}/target/test-classes:
done
CP="${CP}$(cat target/fullclasspath.txt)"

VM_OPTS=
if [ "$cygwin" ]; then
CP=$(cygpath -wp "$CP")

# Work around https://github.com/jline/jline2/issues/62
VM_OPTS=-Djline.terminal=jline.UnixTerminal
fi

export JAVA_OPTS=-Djavax.xml.parsers.DocumentBuilderFactory=com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl

exec java -cp "${CP}$(cat .fullclasspath.txt)" $JAVA_OPTS sqlline.SqlLine "$@"
exec java $VM_OPTS -cp "${CP}" $JAVA_OPTS sqlline.SqlLine "$@"

# End sqlline
29 changes: 29 additions & 0 deletions sqlline.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@echo off
:: sqlline.bat - Windows script to launch SQL shell
::
:: Licensed to Julian Hyde under one or more contributor license
:: agreements. See the NOTICE file distributed with this work for
:: additional information regarding copyright ownership.
::
:: Julian Hyde 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.
::
:: Example:
:: > sqlline.bat
:: sqlline> !connect jdbc:optiq: admin admin

:: Copy dependency jars on first call. (To force jar refresh, remove target\dependencies)
if not exist target\dependencies (call mvn -B dependency:copy-dependencies -DoverWriteReleases=false -DoverWriteSnapshots=false -DoverWriteIfNewer=true -DoutputDirectory=target\dependencies)

java -Xmx1G -cp ".\target\dependencies\*;core\target\dependencies\*;avatica\target\dependencies\*;mongodb\target\dependencies\*;spark\target\dependencies\*;splunk\target\dependencies\*" sqlline.SqlLine --verbose=true %*

:: End sqlline.bat

0 comments on commit 5a4126f

Please sign in to comment.