Permalink
Browse files

Add a REPL for JXMPP

  • Loading branch information...
Flowdalic committed Jan 1, 2017
1 parent 14c1d04 commit 6b4efae4a50828049dfbabb0fee68cce7e8a5b37
@@ -0,0 +1,18 @@
ext {
scalaVersion = '2.11.7'
}

dependencies {
compile project(':jxmpp-core')
compile project(':jxmpp-jid')
compile project(':jxmpp-stringprep-icu4j')
compile project(':jxmpp-stringprep-libidn')
compile project(':jxmpp-util-cache')
compile "com.lihaoyi:ammonite_$scalaVersion:0.8.0"
testCompile project(path: ":jxmpp-core", configuration: "testRuntime")
testCompile project(path: ":jxmpp-core", configuration: "archives")
}

task printClasspath(dependsOn: assemble) << {
println sourceSets.main.runtimeClasspath.asPath
}
@@ -0,0 +1,6 @@
org.jxmpp.repl.JxmppRepl.init()

import org.jxmpp.repl.JxmppRepl._
import org.jxmpp._
import org.jxmpp.jid._
import org.jxmpp.jid.impl._
@@ -0,0 +1,47 @@
/**
*
* Copyright 2017 Florian Schmaus
*
* Licensed 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.
*/
package org.jxmpp.repl;

import org.jxmpp.stringprep.icu4j.Icu4jXmppStringprep;
import org.jxmpp.stringprep.libidn.LibIdnXmppStringprep;

/**
* Supporting class for JXMPP's REPL.
*
*/
public class JxmppRepl {

/**
* Initializes the REPL.
*/
public static void init() {
}

/**
* Use ICU4J as stringprep facility.
*/
public static void useIcu4J() {
Icu4jXmppStringprep.setup();
}

/**
* Use LibIDN as stringprep facility.
*/
public static void useLibidn() {
LibIdnXmppStringprep.setup();
}
}
@@ -0,0 +1,21 @@
/**
*
* Copyright 2015 Florian Schmaus
*
* Licensed 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.
*/

/**
* The JXMPP REPL (Read-eval-print Loop).
*/
package org.jxmpp.repl;
34 repl
@@ -0,0 +1,34 @@
#!/usr/bin/env bash
set -e
set -u
set -o pipefail


while getopts d OPTION "$@"; do
case $OPTION in
d)
set -x
;;
esac
done

PROJECT_ROOT=$(dirname "${BASH_SOURCE[0]}")
cd "${PROJECT_ROOT}"

echo "Compiling and computing classpath (May take a while)"
# Sadly even with the --quiet option Gradle (or some component of)
# will print the number of warnings/errors to stdout if there are
# any. So the result could look like
# 52 warnings\n1 warning\n12 warnings\n
# /smack/smack-repl/build/classes/main:/smack/smack-repl/build/
# resources/main:/smack/smack-tcp/build/libs/smack-tcp-4.2.0-alpha4-SNAPSHOT.jar
# So perform a "tail -n1" on the output of gradle
GRADLE_CLASSPATH="$(gradle :jxmpp-repl:printClasspath --quiet |\
tail -n1)"
echo "Finished, starting REPL"

java \
-Dscala.usejavacp=true \
-classpath "${GRADLE_CLASSPATH}" \
ammonite.Main \
-f jxmpp-repl/scala.repl
@@ -2,4 +2,5 @@ include 'jxmpp-core',
'jxmpp-jid',
'jxmpp-stringprep-icu4j',
'jxmpp-stringprep-libidn',
'jxmpp-util-cache'
'jxmpp-util-cache',
'jxmpp-repl'

0 comments on commit 6b4efae

Please sign in to comment.