Skip to content

Commit

Permalink
Added sound player stuff. More importantly, changed build process to …
Browse files Browse the repository at this point in the history
…work on OS X 10.7+ with Java 7+.
  • Loading branch information
alvinj committed Oct 7, 2013
1 parent 611b45d commit 6ab99c2
Show file tree
Hide file tree
Showing 25 changed files with 826 additions and 130 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
custom.old/
lib-hmmm/
/bin
/target
/project
Expand Down
31 changes: 31 additions & 0 deletions DEVELOPER-NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,37 @@ I used to have a class named Mouth, and may return to that design.
An important concept is that the mouth can only say one thing at a time.


-- Plugins --

* Always call the brain on a thread, such as through an Akka Future:

implicit val actorSystem = ActorSystem("CurrentTimeActorSystem")
val f = Future { brain ! PleaseSay("The current time is " + currentTime) }

Calls not made in this way seem to have a slightly higher priority, as if they're
made on the main Java thread, and it has a higher priority. For example, this is a
problem if you want to say "Stand by", and then speak your results a few moments
later, presumably after you've retrieved them from the internet.

This approach requires the following import statements:

import akka.dispatch.{ Await, Future }
import akka.util.duration._
import akka.actor.ActorSystem

















Expand Down
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ voice/speech, and robotics.

MORE INFORMATION

Sarah was created by Alvin Alexander of http://www.devdaily.com/
Sarah was created by Alvin Alexander of http://alvinalexander.com

Please see the devdaily.com website for more information.

Expand Down
76 changes: 76 additions & 0 deletions README-Building.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
How to Build the Mac App (Latest)
---------------------------------

This is a little convoluted, but:

1 First run 'sbt compile' in the root directory of the project.
2 cd into the 'custom' directory.
3 Run 'ant'. This builds release/Sarah.app under custom.

Notes
-----

I was using sbt-assembly, but I ran into name collisions that
would probably keep the Java 'mail' jars from working.

The custom/build.xml file requires JAVA_HOME to be set.

The custom/build.xml file need some love.

Requirements (AppBundler)
-------------------------

The Ant build process requires the AppBundler jar to work
on OS X 10.7 and newer along with Java 7 and newer. Here's
some info:

* https://java.net/projects/appbundler/pages/Home
* https://java.net/downloads/appbundler/appbundler.html
* http://intransitione.com/blog/take-java-to-app-store/ (very helpful)
* http://docs.oracle.com/javase/7/docs/technotes/guides/jweb/packagingAppsForMac.html

Assuming this process works, you can safely ignore everything else
that I've written below.


Old Instructions for Using sbt-assembly
---------------------------------------

The instructions below discuss how to build the application with
sbt-assembly. As long as the directions above work properly, there's
no need to worry about the stuff below.


HOW TO BUILD THE MAC APP
------------------------

1) First run "sbt assembly" in the project's root directory.
That creates a single JAR file for the entire application.
(More on this shortly.)

2) Move into the 'custom' directory. Make sure JAVA_HOME is set
properly, and then run "ant". This should create a 'Sarah.app' subdirectory
under 'custom'.

IMPORTANT NOTES
---------------

* I configured sbt-assembly in the build.sbt file to handle problems where several
jars contain the same filenames and paths. This may cause problems. The email jars
are the primary culprits.

* The 'custom' directory was changed because I need to use 'AppBundler' with Java 7
instead of the older JarBundler, which I used previously. (JarBundler won't work with
Java 7.)

* sbt-assembly 'Merge' notes: This URL was helpful:
http://nicta.github.io/scoobi/guide/com.nicta.scoobi.guide.Deployment.html

HOW TO INSTALL SARAH
--------------------

* At this time the install files are in the Install subdirectory of this directory.
This is still a work in progress, but I'm aiming to put Sarah's data files in this dir:
$HOME/Library/Application Support/devdaily.com/Sarah


14 changes: 14 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
import AssemblyKeys._

// sbt-assembly
assemblySettings

name := "Sarah"

version := "0.1"
Expand All @@ -8,4 +13,13 @@ resolvers += "Typesafe Repository" at "http://repo.typesafe.com/typesafe/release

libraryDependencies += "com.typesafe.akka" % "akka-actor" % "2.0.2"

mergeStrategy in assembly <<= (mergeStrategy in assembly) { mergeStrategy => {
case entry => {
val strategy = mergeStrategy(entry)
if (strategy == MergeStrategy.deduplicate) MergeStrategy.first
else strategy
}
}
}


25 changes: 0 additions & 25 deletions custom/README

This file was deleted.

85 changes: 57 additions & 28 deletions custom/build.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<project name="Sarah" default="create-bundle" basedir=".">

<taskdef name="jarbundler" classname="net.sourceforge.jarbundler.JarBundler" />
<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask"/>
<property environment="env"/>

<!-- input stuff -->
<property name="classes.dir" value="../target/scala-2.9.1.final/classes" />
Expand Down Expand Up @@ -58,36 +59,64 @@
</copy>
</target>

<!-- CREATE MAC BUNDLE -->
<!-- CREATE MAC BUNDLE (NEW) -->

<target name="create-bundle" depends="create-jar">
<jarbundler dir="${release.dir}"
name="Sarah"
shortname="Sarah"
signature="Alvin Alexander, devdaily.com"
mainclass="com.devdaily.sarah.Sarah"
icon="sarah.icns"
jvmversion="1.6+"
version="0.1"
infostring="Sarah, v0.1, January, 2012"
build="1001"
bundleid="com.devdaily.sarah.Sarah" >

<jarfileset dir="jar">
<include name="**/*.jar" />
<exclude name="**/CVS" />
</jarfileset>

<javaproperty name="com.apple.mrj.application.apple.menu.about.name" value="Sarah"/>
<javaproperty name="apple.laf.useScreenMenuBar" value="true"/>
<javaproperty name="apple.awt.brushMetal" value="true"/>
<javaproperty name="apple.awt.showGrowBox" value="true"/>
<javaproperty name="apple.awt.textantialiasing" value="true"/>
</jarbundler>
<bundleapp outputdirectory="${release.dir}"
name="Sarah"
displayname="Sarah"
identifier="com.devdaily.sarah.Sarah"
shortversion="0.2"
applicationCategory="public.app-category.developer-tools"
mainclassname="com/devdaily/sarah/Sarah">

<runtime dir="${env.JAVA_HOME}" />

<!-- need an entry for each jar file (!) -->
<classpath file="jar/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar" />
<classpath file="jar/akka-actor-2.0.2.jar" />
<classpath file="jar/basicplayer3.0.jar" />
<classpath file="jar/commons-codec-1.4.jar" />
<classpath file="jar/commons-lang3-3.1.jar" />
<classpath file="jar/commons-logging-1.1.1.jar" />
<classpath file="jar/dsn.jar" />
<classpath file="jar/htmlcleaner-2.2.jar" />
<classpath file="jar/httpclient-4.1.2.jar" />
<classpath file="jar/httpclient-cache-4.1.2.jar" />
<classpath file="jar/httpcore-4.1.2.jar" />
<classpath file="jar/httpmime-4.1.2.jar" />
<classpath file="jar/imap.jar" />
<classpath file="jar/jl1.0.1-orig.jar" />
<classpath file="jar/js.jar" />
<classpath file="jar/jsapi.jar" />
<classpath file="jar/junit-4.8.1.jar" />
<classpath file="jar/kj_dsp1.1.jar" />
<classpath file="jar/lift-json_2.9.0-1-2.4-M2.jar" />
<classpath file="jar/mailapi.jar" />
<classpath file="jar/mp3spi1.9.4.jar" />
<classpath file="jar/paranamer-2.1.jar" />
<classpath file="jar/pop3.jar" />
<classpath file="jar/sarah.jar" />
<classpath file="jar/scala-library.jar" />
<classpath file="jar/slf4j-api-1.6.4.jar" />
<classpath file="jar/slf4j-simple-1.6.4.jar" />
<classpath file="jar/slf4s_2.9.1-1.0.7.jar" />
<classpath file="jar/smtp.jar" />
<classpath file="jar/snakeyaml-1.9.jar" />
<classpath file="jar/sphinx4.jar" />
<classpath file="jar/tritonus_share.jar" />

<!-- option value="-Xdock:icon=../Resources/sarah.icns"></option> -->
<option value="-Xdock:icon=Contents/Resources/sarah.icns"/>
<option value="-Dapple.laf.useScreenMenuBar=true"/>
<option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
<option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
<option value="-Dapple.awt.application.name=MyApp"/>
<option value="-Dcom.apple.smallTabs=true"/>

</bundleapp>
</target>

</project>





119 changes: 119 additions & 0 deletions custom/build.xml.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
<project name="Sarah" default="create-bundle" basedir=".">

<taskdef name="bundleapp" classname="com.oracle.appbundler.AppBundlerTask"/>

<!-- input stuff -->
<property name="classes.dir" value="../target/scala-2.9.1.final/classes" />
<property name="lib.dir" value="../lib" />
<property name="current.dir" value="." />
<property name="scala-lib.dir" value="scala-libs" />

<!-- output stuff -->
<property name="jar.dir" value="jar" />
<property name="release.dir" value="release" />
<property name="jar.filename" value="sarah.jar" />

<target name="init">
<tstamp/>
</target>

<!-- CLEAN -->
<target name="clean">
<!-- these are just needed for the first-time setup -->
<mkdir dir="${jar.dir}"/>
<mkdir dir="${release.dir}"/>
<!-- remove all the old jars from the jar directory -->
<delete>
<fileset dir="${jar.dir}">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
</delete>
<!-- remove the old version of the app -->
<delete>
<fileset dir="${release.dir}">
<include name="**/*.app"/>
</fileset>
</delete>
</target>

<!-- CREATE JAR -->
<target name="create-jar" depends="clean">
<!-- copy the application classes -->
<jar basedir="${classes.dir}"
jarfile="${jar.dir}/${jar.filename}"
manifest="${current.dir}/sarah.manifest"/>

<!-- copy the application jars -->
<copy todir="${jar.dir}">
<fileset dir="${lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
<!-- copy the scala jars -->
<copy todir="${jar.dir}">
<fileset dir="${scala-lib.dir}">
<include name="**/*.jar"/>
</fileset>
</copy>
</target>

<!-- CREATE MAC BUNDLE (NEW) -->

<target name="create-bundle" depends="create-jar">
<bundleapp outputdirectory="${release.dir}"
name="Sarah"
displayname="Sarah"
identifier="com.devdaily.sarah.Sarah"
shortversion="0.2"
applicationCategory="public.app-category.developer-tools"
mainclassname="com/devdaily/sarah/Sarah">

<runtime dir="${env.JAVA_HOME}" />

<!-- need an entry for each jar file (!) -->
<classpath file="lib/WSJ_8gau_13dCep_16k_40mel_130Hz_6800Hz.jar" />
<classpath file="lib/akka-actor-2.0.2.jar" />
<classpath file="lib/basicplayer3.0.jar" />
<classpath file="lib/commons-codec-1.4.jar" />
<classpath file="lib/commons-lang3-3.1.jar" />
<classpath file="lib/commons-logging-1.1.1.jar" />
<classpath file="lib/dsn.jar" />
<classpath file="lib/htmlcleaner-2.2.jar" />
<classpath file="lib/httpclient-4.1.2.jar" />
<classpath file="lib/httpclient-cache-4.1.2.jar" />
<classpath file="lib/httpcore-4.1.2.jar" />
<classpath file="lib/httpmime-4.1.2.jar" />
<classpath file="lib/imap.jar" />
<classpath file="lib/jl1.0.1-orig.jar" />
<classpath file="lib/js.jar" />
<classpath file="lib/jsapi.jar" />
<classpath file="lib/junit-4.8.1.jar" />
<classpath file="lib/kj_dsp1.1.jar" />
<classpath file="lib/lift-json_2.9.0-1-2.4-M2.jar" />
<classpath file="lib/mailapi.jar" />
<classpath file="lib/mp3spi1.9.4.jar" />
<classpath file="lib/paranamer-2.1.jar" />
<classpath file="lib/pop3.jar" />
<classpath file="lib/sarah.jar" />
<classpath file="lib/scala-library.jar" />
<classpath file="lib/slf4j-api-1.6.4.jar" />
<classpath file="lib/slf4j-simple-1.6.4.jar" />
<classpath file="lib/slf4s_2.9.1-1.0.7.jar" />
<classpath file="lib/smtp.jar" />
<classpath file="lib/snakeyaml-1.9.jar" />
<classpath file="lib/sphinx4.jar" />
<classpath file="lib/tritonus_share.jar" />

<option value="-Dapple.laf.useScreenMenuBar=true"/>
<option value="-Dcom.apple.macos.use-file-dialog-packages=true"/>
<option value="-Dcom.apple.macos.useScreenMenuBar=true"/>
<option value="-Dapple.awt.application.name=MyApp"/>
<option value="-Dcom.apple.smallTabs=true"/>

</bundleapp>
</target>

</project>


Loading

0 comments on commit 6ab99c2

Please sign in to comment.