Commit 4430372a authored by Jens Korinth's avatar Jens Korinth
Browse files

Closes #116 - Generate run scripts from sbt

* took longer than I care to admit, but now the executable scripts are
  generated by sbt assembly
* also has the welcome side effect that tapasco cannot be executed prior
  to running sbt assembly
* each sbt assembly should update the version string references
* cleaned up the build def a little
parent adde8193
#!/bin/bash
java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -splash:$TAPASCO_HOME/icon/tapasco_icon.png -jar $TAPASCO_HOME/target/scala-2.12/Tapasco-2017.2-SNAPSHOT.jar itapasco $*
#!/bin/bash
java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -jar $TAPASCO_HOME/target/scala-2.12/Tapasco-2017.2-SNAPSHOT.jar $*
#!/bin/bash
JAVA_OPT="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
cd $TAPASCO_HOME && sbt "logviewer $*"
#!/bin/bash
JAVA_OPT="-Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled"
cd $TAPASCO_HOME && sbt "reportviewer $*"
......@@ -6,7 +6,7 @@ version := tapascoVersion
name := "Tapasco"
scalaVersion := "2.12.1"
scalaVersion := "2.12.3"
libraryDependencies ++= Seq(
"org.scala-lang" % "scala-compiler" % scalaVersion.value,
......@@ -60,37 +60,93 @@ fork in run := true
val tapasco = inputKey[Unit]("Run Tapasco command.")
tapasco := (runMain in Compile).partialInput (" de.tu_darmstadt.cs.esa.tapasco.Tapasco ").evaluated
val itapasco = InputKey[Unit]("itapasco", "Run interactive Tapasco GUI.")
fullRunInputTask(itapasco, Compile, "de.tu_darmstadt.cs.esa.tapasco.Tapasco", "itapasco")
val logviewer = inputKey[Unit]("Run interactive DSE log viewer.")
fork in itapasco := true
val reportviewer = inputKey[Unit]("Run interactive report viewer.")
javaOptions in itapasco += "-splash:icon/tapasco_icon.png"
tapasco := (runMain in Compile).partialInput (" de.tu_darmstadt.cs.esa.tapasco.Tapasco ").evaluated
val logviewer = inputKey[Unit]("Run interactive DSE log viewer.")
fullRunInputTask(itapasco, Compile, "de.tu_darmstadt.cs.esa.tapasco.Tapasco", "itapasco")
fullRunInputTask(logviewer, Compile, "de.tu_darmstadt.cs.esa.tapasco.itapasco.executables.LogViewer")
javaOptions in logviewer += "-splash:icon/tapasco_icon.png"
val reportviewer = inputKey[Unit]("Run interactive report viewer.")
fullRunInputTask(reportviewer, Compile, "de.tu_darmstadt.cs.esa.tapasco.itapasco.executables.ReportViewer")
javaOptions in reportviewer += "-splash:icon/tapasco_icon.png"
fork := true
test in assembly := {}
fork in itapasco := true
assemblyJarName := "Tapasco-" + tapascoVersion + ".jar"
fork in Test := false
parallelExecution in Test := false
fork in Test := false
javaOptions in itapasco += "-splash:icon/tapasco_icon.png"
javaOptions in logviewer += "-splash:icon/tapasco_icon.png"
javaOptions in reportviewer += "-splash:icon/tapasco_icon.png"
test in assembly := {}
assemblyJarName := "Tapasco-" + tapascoVersion + ".jar"
mainClass in assembly := Some("de.tu_darmstadt.cs.esa.tapasco.Tapasco")
def writeScripts(jar: String, base: String) {
val N = scala.util.Properties.lineSeparator
val basePath = java.nio.file.Paths.get(base)
val binPath = basePath.resolve("bin")
val iconPath = basePath.resolve("icon").resolve("tapasco_icon.png")
val tapasco = binPath.resolve("tapasco")
val itapasco = binPath.resolve("itapasco")
val logviewer= binPath.resolve("tapasco-logviewer")
val rptviewer= binPath.resolve("tapasco-reportviewer")
var f = new java.io.FileWriter(tapasco.toString)
f.append("#!/bin/bash").append(N)
.append("java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled -jar %s $*".format(jar)).append(N)
f.close()
tapasco.toFile.setExecutable(true)
f = new java.io.FileWriter(itapasco.toString)
f.append("#!/bin/bash").append(N)
.append("java -Xms512M -Xmx1536M -Xss1M -XX:+CMSClassUnloadingEnabled ")
.append("-splash:%s ".format(iconPath.toString))
.append("-jar %s ".format(jar))
.append("itapasco $*").append(N)
f.close()
itapasco.toFile.setExecutable(true)
f = new java.io.FileWriter(logviewer.toString)
f.append("#!/bin/bash").append(N)
.append("cd $TAPASCO_HOME && sbt logviewer $*")
f.close()
logviewer.toFile.setExecutable(true)
f = new java.io.FileWriter(rptviewer.toString)
f.append("#!/bin/bash").append(N)
.append("cd $TAPASCO_HOME && sbt reportviewer $*")
f.close()
rptviewer.toFile.setExecutable(true)
}
cleanFiles ++= Seq(
baseDirectory.value / "bin" / "tapasco",
baseDirectory.value / "bin" / "itapasco",
baseDirectory.value / "bin" / "tapasco-logviewer",
baseDirectory.value / "bin" / "tapasco-reportviewer"
)
lazy val root = (project in file("."))
.settings(
assembly := (Def.taskDyn {
val a = assembly.value
val jar = target(_ / ("scala-" + scalaBinaryVersion.value) / assemblyJarName.value)
Def.task {
writeScripts(jar.value.toString, baseDirectory.value.toString)
a
}
}).value
)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment