Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,24 +23,47 @@ default: compile
all: compile build build-startup-script build-executable-script build-test-script

compile:
@echo "no op compile"
kb-sdk compile $(SPEC_FILE) \
--out $(LIB_DIR) \
--plclname $(SERVICE_CAPS)::$(SERVICE_CAPS)Client \
--jsclname javascript/Client \
--pyclname $(SERVICE_CAPS).$(SERVICE_CAPS)Client \
--javasrc src \
--java \
--javasrv \
--javapackage .;

build:
$(ANT) war -Djars.dir=$(JARS_DIR)
chmod +x $(SCRIPTS_DIR)/entrypoint.sh
@echo "no opt build"

build-executable-script:
@echo "no op build executable script"
mkdir -p $(LBIN_DIR)
$(ANT) build-executable-script -Djars.dir=$(JARS_DIR) -Dexec.cmd.file=$(EXECUTABLE_SCRIPT_NAME)
chmod +x $(LBIN_DIR)/$(EXECUTABLE_SCRIPT_NAME)

build-startup-script:
@echo "no op build-startup-script"
mkdir -p $(LBIN_DIR)
echo '#!/bin/bash' > $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'script_dir=$$(dirname "$$(readlink -f "$$0")")' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'cd $(SCRIPTS_DIR)' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
echo 'java -cp $(JARS_DIR)/jetty/jetty-start-7.0.0.jar:$(JARS_DIR)/jetty/jetty-all-7.0.0.jar:$(JARS_DIR)/servlet/servlet-api-2.5.jar \
-DKB_DEPLOYMENT_CONFIG=$$script_dir/../deploy.cfg -Djetty.port=5000 org.eclipse.jetty.start.Main jetty.xml' >> $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)
chmod +x $(SCRIPTS_DIR)/$(STARTUP_SCRIPT_NAME)

build-test-script:
@echo "no opt build-test-script"
echo '#!/bin/bash' > $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'script_dir=$$(dirname "$$(readlink -f "$$0")")' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export KB_DEPLOYMENT_CONFIG=$$script_dir/../deploy.cfg' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export KB_AUTH_TOKEN=`cat /kb/module/work/token`' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo 'export JAVA_HOME=$(JAVA_HOME)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
echo '$(ANT) test -Djars.dir=$(JARS_DIR)' >> $(TEST_DIR)/$(TEST_SCRIPT_NAME)
chmod +x $(TEST_DIR)/$(TEST_SCRIPT_NAME)

test:
@echo "nothint to test"
if [ ! -f /kb/module/work/token ]; then echo -e '\nOutside a docker container please run "kb-sdk test" rather than "make test"\n' && exit 1; fi
bash $(TEST_DIR)/$(TEST_SCRIPT_NAME)

clean:
@echo "nothing to clean"
rm -rfv $(LBIN_DIR)

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
# EditorApps
---

This modules services as a source of simple editor apps which do not require a back end service.
This is the basic readme for this module. Include any usage or deployment instructions and links to other documentation here.
114 changes: 114 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<project name="EditorApps" default="compile" basedir=".">

<description>
Build JAR and WAR files for EditorApps
</description>

<!-- set global properties for this build -->
<property name="src" location="lib/src"/>
<property name="test.src" location="test/src"/>
<property name="dist" location="dist"/>
<property name="classes" location="classes"/>
<property name="bin" location="bin"/>
<property name="jar.file" value="EditorApps.jar"/>
<property name="jars.dir" value="/kb/deployment/lib/jars"/>
<property name="war.file" value="EditorApps.war"/>
<property name="scripts" location="scripts"/>
<property name="web.xml" location="${scripts}/web.xml"/>
<property name="exec.cmd.file" value="run_EditorApps_async_job.sh"/>
<property name="startup.cmd.file" value="start_server.sh"/>

<fileset dir="${jars.dir}" id="lib">
<include name="ini4j/ini4j-0.5.2.jar"/>
<include name="jackson/jackson-annotations-2.2.3.jar"/>
<include name="jackson/jackson-core-2.2.3.jar"/>
<include name="jackson/jackson-databind-2.2.3.jar"/>
<include name="jetty/jetty-all-7.0.0.jar"/>
<include name="jna/jna-3.4.0.jar"/>
<include name="joda/joda-time-2.2.jar"/>
<include name="junit/junit-4.9.jar"/>
<include name="kbase/auth/kbase-auth-0.4.1.jar"/>
<include name="kbase/common/kbase-common-0.0.20.jar"/>
<include name="logback/logback-core-1.1.2.jar"/>
<include name="logback/logback-classic-1.1.2.jar"/>
<include name="servlet/servlet-api-2.5.jar"/>
<include name="slf4j/slf4j-api-1.7.7.jar"/>
<include name="syslog4j/syslog4j-0.9.46.jar"/>
<include name="kbase/workspace/WorkspaceClient-0.4.1.jar"/>
</fileset>

<path id="compile.classpath">
<fileset refid="lib"/>
</path>

<path id="src.path">
<pathelement location="${src}" />
<pathelement location="${test.src}" />
</path>

<target name="compile" description="compile the source">
<mkdir dir="${classes}"/>
<mkdir dir="${dist}"/>
<exec executable="git" outputproperty="git.url"><arg line="config --get remote.origin.url"/></exec>
<exec executable="git" outputproperty="git.branch"><arg line="rev-parse --abbrev-ref HEAD"/></exec>
<exec executable="git" outputproperty="git.commit"><arg line="rev-parse HEAD"/></exec>
<echo file="${src}/git.properties">giturl=${git.url}
branch=${git.branch}
commit=${git.commit}</echo>
<!-- Compile class files-->
<javac destdir="${classes}" includeantruntime="false"
target="1.7" source="1.7" debug="true"
classpathref="compile.classpath" compiler="modern">
<src refid="src.path"/>
</javac>
<!-- Copy resource files-->
<copy todir="${classes}">
<fileset dir="${src}">
</fileset>
</copy>
<jar destfile="${dist}/${jar.file}" basedir="${classes}"/>
<delete dir="${classes}"/>
</target>

<target name="war" depends="compile" description="build the WAR file. Assumes compile has been run">
<!-- make the war file for the server-->
<mkdir dir="${dist}/lib"/>
<copy todir="${dist}/lib/" flatten="true">
<fileset refid="lib"/>
<resources>
<file file="${dist}/${jar.file}"/>
</resources>
</copy>
<war destfile="${dist}/${war.file}" webxml="${web.xml}">
<lib dir="${dist}/lib/"/>
</war>
<delete dir="${dist}/lib"/>
<mkdir dir="${scripts}/webapps"/>
<copy file="${dist}/${war.file}" tofile="${scripts}/webapps/root.war"/>
</target>

<target name="build-executable-script" description="create command-line script">
<mkdir dir="${bin}"/>
<property name="jar.absolute.path" location="${dist}/${jar.file}"/>
<pathconvert targetos="unix" property="lib.classpath" refid="compile.classpath"/>
<echo file="${bin}/${exec.cmd.file}">#!/bin/bash
java -cp ${jar.absolute.path}:${lib.classpath} editorapps.EditorAppsServer $1 $2 $3
</echo>
<chmod file="${bin}/${exec.cmd.file}" perm="a+x"/>
</target>

<target name="test" description="run all tests">
<junit printsummary="yes" haltonfailure="yes" fork="true">
<classpath>
<pathelement location="${dist}/${jar.file}"/>
<path refid="compile.classpath"/>
</classpath>
<formatter type="plain" usefile="false" />
<batchtest>
<fileset dir="${test.src}">
<include name="**/test/**Test.java"/>
</fileset>
</batchtest>
</junit>
</target>
</project>
2 changes: 1 addition & 1 deletion kbase.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module-name:
EditorApps

module-description:
A collection of Editor front end App specifications
A KBase module

service-language:
java
Expand Down
Loading