1#!/bin/sh 2 3# Copyright 2014 Google Inc. All rights reserved. 4# 5# Licensed under the Apache License, Version 2.0 (the "License"); 6# you may not use this file except in compliance with the License. 7# You may obtain a copy of the License at 8# 9# http://www.apache.org/licenses/LICENSE-2.0 10# 11# Unless required by applicable law or agreed to in writing, software 12# distributed under the License is distributed on an "AS IS" BASIS, 13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14# See the License for the specific language governing permissions and 15# limitations under the License. 16 17echo Compile then run the Kotlin test. 18 19testdir=$(dirname $0) 20targetdir="${testdir}/kotlin" 21 22if [[ -e "${targetdir}" ]]; then 23 echo "cleaning target" 24 rm -rf "${targetdir}" 25fi 26 27mkdir -v "${targetdir}" 28 29if ! find "${testdir}/../java" -type f -name "*.class" -delete; then 30 echo "failed to clean .class files from java directory" >&2 31 exit 1 32fi 33 34all_kt_files=`find . -name "*.kt" -print` 35 36# Compile java FlatBuffer library 37javac ${testdir}/../java/com/google/flatbuffers/*.java -d $targetdir 38# Compile Kotlin files 39kotlinc $all_kt_files -classpath $targetdir -include-runtime -d $targetdir 40# Make jar 41jar cvf ${testdir}/kotlin_test.jar -C $targetdir . > /dev/null 42# Run test 43kotlin -J"-ea" -cp ${testdir}/kotlin_test.jar KotlinTest 44# clean up 45rm -rf $targetdir 46rm ${testdir}/kotlin_test.jar 47