Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ target/
/phantomjsdriver.log
/*-backup.sql*
/assets/project-root/
proguard-sbt.txt
13 changes: 13 additions & 0 deletions androidApp/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="space.woost">
<application android:label="Woost">
<activity android:name="MainActivity"
android:label="Woost">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
48 changes: 48 additions & 0 deletions androidApp/src/main/scala/wust/android/MainActivity.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package space.woost

import android.app.Activity
import android.os.Bundle
import android.widget.{Button, LinearLayout, TextView}
import macroid._
import macroid.contrib._
import macroid.FullDsl._

import wust.api

object OurTweaks {
def greeting(greeting: String)(implicit ctx: ContextWrapper) =
TextTweaks.large +
text(greeting) +
hide

def orient(implicit ctx: ContextWrapper) =
landscape ? horizontal | vertical
}

class MainActivity extends Activity with Contexts[Activity] {
var greeting = slot[TextView]

override def onCreate(savedInstanceState: Bundle) = {
super.onCreate(savedInstanceState)

setContentView {
Ui.get {
l[LinearLayout](
w[Button] <~
text("Click me") <~
On.click {
greeting <~ show
},
w[Button] <~
text("Click me 2") <~
On.click {
greeting <~ hide
},
w[TextView] <~
wire(greeting) <~
OurTweaks.greeting("Hello!" + api.ApiEvent.GraphContent)
) <~ OurTweaks.orient
}
}
}
}
120 changes: 74 additions & 46 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ dynver in ThisBuild ~= (_.replace('+', '-'))

lazy val isCI = sys.env.get("CI").isDefined // set by travis, TODO: https://github.com/sbt/sbt/issues/3653

scalaVersion in ThisBuild := "2.12.4"

import Def.{setting => dep}

lazy val commonSettings = Seq(
resolvers ++= (
/* ("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") :: */
Resolver.jcenterRepo ::
("jitpack" at "https://jitpack.io") ::
Nil
),
lazy val defaultScalaVersionSettings = Seq(
scalaVersion := "2.12.4",

addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M11" cross CrossVersion.full),
addCompilerPlugin("org.spire-math" %% "kind-projector" % "0.9.4"),
Expand All @@ -26,28 +21,6 @@ lazy val commonSettings = Seq(
//exclude source files generated by scala meta: https://github.com/scalameta/paradise/issues/56
coverageExcludedFiles := "<macro>",

libraryDependencies ++=
Deps.scribe.value ::
Deps.scalameta.value % Provided::
Deps.derive.value % Provided ::
Deps.scalatest.value % Test ::
Deps.mockito.value % Test ::
Nil,

dependencyOverrides ++=
Deps.circe.core.value ::
Deps.circe.parser.value ::
Deps.circe.generic.value ::
Deps.cats.core.value ::
Deps.akka.httpCore.value ::
Nil,

// do not run tests in assembly command
test in assembly := {},

// watch managed library dependencies https://github.com/sbt/sbt/issues/2834
watchSources ++= (managedClasspath in Compile).map(_.files).value,

scalacOptions ++=
// https://www.threatstack.com/blog/useful-scalac-options-for-better-scala-development-part-1/
// https://tpolecat.github.io/2017/04/25/scalac-flags.html
Expand All @@ -66,17 +39,48 @@ lazy val commonSettings = Seq(
"-Ywarn-infer-any" ::
"-Ywarn-nullary-override" ::
"-Ywarn-nullary-unit" ::
Nil,
Nil
)

lazy val commonSettings = Seq(
resolvers ++= (
/* ("Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots") :: */
Resolver.jcenterRepo ::
("jitpack" at "https://jitpack.io") ::
Nil
),

libraryDependencies ++=
Deps.scribe.value ::
Deps.scalameta.value % Provided::
Deps.derive.value % Provided ::
Deps.scalatest.value % Test ::
Deps.mockito.value % Test ::
Nil,

// dependencyOverrides ++=
// Deps.circe.core.value ::
// Deps.circe.parser.value ::
// Deps.circe.generic.value ::
// Deps.cats.core.value ::
// Deps.akka.httpCore.value ::
// Nil,

// do not run tests in assembly command
test in assembly := {},

// watch managed library dependencies https://github.com/sbt/sbt/issues/2834
watchSources ++= (managedClasspath in Compile).map(_.files).value
)

lazy val sourceMapSettings = Seq(
// To enable source map support, all sub-project folders are symlinked to assets/project-root.
// This folder is served via webpack devserver.
scalacOptions += {
val local = s"${(ThisBuild / baseDirectory).value.toURI}"
val local = s"${(baseDirectory in ThisBuild).value.toURI}"
val remote = s"/"
s"-P:scalajs:mapSourceURI:$local->$remote"
},
}
)

lazy val root = project.in(file("."))
Expand Down Expand Up @@ -106,7 +110,7 @@ lazy val root = project.in(file("."))
)

lazy val util = crossProject
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.jsSettings(sourceMapSettings)
.settings(
libraryDependencies ++= (
Expand All @@ -127,7 +131,7 @@ lazy val utilJVM = util.jvm

lazy val sdk = crossProject
.dependsOn(api)
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.jsSettings(sourceMapSettings)
.settings(
libraryDependencies ++= (
Expand All @@ -143,7 +147,7 @@ lazy val sdkJS = sdk.js
lazy val sdkJVM = sdk.jvm

lazy val ids = crossProject.crossType(CrossType.Pure)
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.jsSettings(sourceMapSettings)
.settings(
libraryDependencies ++= (
Expand All @@ -156,7 +160,7 @@ lazy val idsJS = ids.js
lazy val idsJVM = ids.jvm

lazy val graph = crossProject.crossType(CrossType.Pure)
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.jsSettings(sourceMapSettings)
.dependsOn(ids, util)
.settings(
Expand All @@ -169,9 +173,10 @@ lazy val graphJVM = graph.jvm

lazy val api = crossProject.crossType(CrossType.Pure)
.dependsOn(graph)
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.jsSettings(sourceMapSettings)
.settings(
crossScalaVersions := Seq("2.11.12"),
libraryDependencies ++=
Deps.boopickle.value % Optional ::
Deps.circe.core.value % Optional ::
Expand All @@ -182,7 +187,7 @@ lazy val apiJS = api.js
lazy val apiJVM = api.jvm

lazy val database = project
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.configs(IntegrationTest)
.settings(Defaults.itSettings)
.dependsOn(idsJVM, utilJVM)
Expand All @@ -194,7 +199,7 @@ lazy val database = project
)

lazy val backend = project
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.dependsOn(apiJVM, database)
.configs(IntegrationTest)
.settings(Defaults.itSettings)
Expand Down Expand Up @@ -222,7 +227,7 @@ lazy val copyFastOptJS = TaskKey[Unit]("copyFastOptJS", "Copy javascript files t
lazy val frontend = project
.enablePlugins(ScalaJSPlugin, ScalaJSBundlerPlugin)
.dependsOn(sdkJS, utilJS)
.settings(commonSettings, sourceMapSettings)
.settings(defaultScalaVersionSettings, commonSettings, sourceMapSettings)
.settings(
libraryDependencies ++= (
Deps.outwatch.value ::
Expand Down Expand Up @@ -269,12 +274,35 @@ lazy val frontend = project
val inDir = (crossTarget in (Compile, fastOptJS)).value
val outDir = (crossTarget in (Compile, fastOptJS)).value / "fastopt"
val files = Seq("frontend-fastopt-loader.js", "frontend-fastopt.js", "frontend-fastopt.js.map") map { p => (inDir / p, outDir / p) }
IO.copy(files, overwrite = true, preserveLastModified = true, preserveExecutable = true)
IO.copy(files, overwrite = true, preserveLastModified = true)
}
)

lazy val androidApp = project
.enablePlugins(AndroidApp)
.settings(scalaVersion := "2.11.12")
.dependsOn(apiJVM)
.settings(
// android does not support java8 bytecode, so no scala 2.12 so far...
android.useSupportVectors,
versionCode := Some(1),
version := "0.1-SNAPSHOT",
platformTarget := "android-27",
javacOptions in Compile ++= "-source" :: "1.7" :: "-target" :: "1.7" :: Nil,
libraryDependencies ++=
aar("org.macroid" %% "macroid" % "2.0") ::
"com.android.support" % "appcompat-v7" % "24.0.0" ::
Nil,
proguardScala in Android := true,

proguardOptions in Android ++= Seq(
"-ignorewarnings",
"-keep class scala.Dynamic"
)
)

lazy val slackApp = project
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.dependsOn(sdkJVM, apiJVM, utilJVM)
.settings(
libraryDependencies ++=
Expand All @@ -283,7 +311,7 @@ lazy val slackApp = project
)

lazy val gitterApp = project
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.dependsOn(sdkJVM, apiJVM, utilJVM)
.settings(
libraryDependencies ++=
Expand All @@ -292,7 +320,7 @@ lazy val gitterApp = project
)

lazy val githubApp = project
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.dependsOn(sdkJVM, apiJVM, utilJVM)
.settings(
libraryDependencies ++=
Expand Down Expand Up @@ -333,7 +361,7 @@ lazy val assets = project
lazy val systemTest = project
.configs(IntegrationTest)
.settings(Defaults.itSettings)
.settings(commonSettings)
.settings(defaultScalaVersionSettings, commonSettings)
.settings(
libraryDependencies ++=
Deps.akka.http.value % IntegrationTest ::
Expand Down
5 changes: 5 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ in
nodejs-8_x yarn
phantomjs
gnumake gcc # required for some weird npm things
androidsdk
];

installPhase= ''
Expand All @@ -23,5 +24,9 @@ in
echo "Make sure you have the docker service running and added your user to the group 'docker'."
echo Now run ./start sbt dev
echo Then point your browser to http://localhost:12345

mkdir -p ~/.android/sbt/sdk/{platform-tools,build-tools/27.0.3}/
cp -a ${pkgs.androidsdk}/bin/* ~/.android/sbt/sdk/platform-tools/
cp -a ${pkgs.androidsdk}/bin/* ~/.android/sbt/sdk/build-tools/27.0.3/
'';
}
Loading