quickstart-scala daml assistant template cleanup (#614) (#1007)

This commit is contained in:
Leonid Shlyapnikov 2019-05-08 11:18:22 -04:00 committed by GitHub
parent 67772baf61
commit 0ca414f09c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 8 deletions

View File

@ -263,10 +263,11 @@ filegroup(
name = "daml-assistant-iou-setup",
srcs = glob(
["source/getting-started/quickstart/template-root/*"],
# excluding quickstart-java stuff
# excluding quickstart-java stuff and da-skeleton.yaml (which should be removed once DA Assistant is gone)
exclude = [
"source/getting-started/quickstart/template-root/src",
"source/getting-started/quickstart/template-root/pom.xml",
"source/getting-started/quickstart/template-root/da-skeleton.yaml",
],
exclude_directories = 0,
),

View File

@ -11,7 +11,12 @@ This examples requires a running sandbox. To start a sandbox, run the following
$ daml start
```
To run the quickstart example:
To run the quickstart-scala example as part of a DAML Assistant project:
```
$ sbt "application/runMain com.digitalasset.quickstart.iou.IouMain localhost 6865"
```
To run the quickstart-scala as a standalone project, you have to specify `da.sdk.version` and `dar.file` JVM system properties:
```
$ sbt -Dda.sdk.version=<DA_SDK_VERSION> -Ddar.file=<DAR_FILE_PATH> "application/runMain com.digitalasset.quickstart.iou.IouMain localhost 6865"
```

View File

@ -5,7 +5,7 @@ object Versions {
private val daSdkVersionKey = "da.sdk.version"
val daSdkVersion: String = sys.props.get(daSdkVersionKey).getOrElse(getSdkVersionFromFile())
val daSdkVersion: String = sys.props.get(daSdkVersionKey).getOrElse(sdkVersionFromFile())
println(s"$daSdkVersionKey = ${daSdkVersion: String}")
private val darFileKey = "dar.file"
@ -14,7 +14,7 @@ object Versions {
.get(darFileKey)
.map(s => new sbt.File(s))
.filter(_.exists)
.getOrElse(new sbt.File(s"dist/${getProjectName(): String}.dar"))
.getOrElse(new sbt.File(s"./dist/${projectNameFromConfig(): String}.dar"))
println(s"$darFileKey = ${darFile.getAbsolutePath: String}")
lazy val detectedOs: String = sys.props("os.name") match {
@ -22,13 +22,13 @@ object Versions {
case _ => "linux"
}
private def getSdkVersionFromFile(): String =
private def sdkVersionFromFile(): String =
"10" + sbt.IO.read(new sbt.File("./SDK_VERSION").getAbsoluteFile).trim
private def getProjectName(): String =
private def projectNameFromConfig(): String =
sbt.IO
.readLines(new sbt.File("./daml.yaml").getAbsoluteFile)
.find(_.startsWith("name:"))
.map(_.replaceFirst("name:", "").trim)
.getOrElse("iou")
.getOrElse(throw new IllegalStateException(s"Cannot read project name from a config file"))
}

View File

@ -31,7 +31,6 @@ genrule(
# quickstart-scala template
mkdir -p $$OUT/quickstart-scala
cp -r $(location //language-support/scala/examples:quickstart-scala-dir)/* $$OUT/quickstart-scala/
rm $$OUT/quickstart-scala/da-skeleton.yaml
cp -rL $$SRC/quickstart-scala/* $$OUT/quickstart-scala/
tar zcf $(location :templates-tarball.tar.gz) templates-tarball