From 1a8219712acd17c225e050559aa9323c36ac8615 Mon Sep 17 00:00:00 2001 From: Walter Oggioni Date: Sat, 30 Sep 2017 11:00:04 +0200 Subject: [PATCH] fixed sbt build --- build.sbt | 59 ++++++++++++++++++++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 20 deletions(-) diff --git a/build.sbt b/build.sbt index 972a86a..48cf614 100644 --- a/build.sbt +++ b/build.sbt @@ -1,3 +1,5 @@ +import java.nio.file.{Files, StandardCopyOption} + import xsbti.compile.CompileAnalysis name := "jpacrepo" @@ -40,31 +42,47 @@ libraryDependencies += "org.jboss.resteasy" % "resteasy-jaxb-provider" % "3.0.11 enablePlugins(WarPlugin) -artifactName := { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) => - artifact.name + "-" + module.revision + "." + artifact.extension -} +artifactName := + { (sv: ScalaVersion, module: ModuleID, artifact: Artifact) => + artifact.name + "-" + module.revision + "." + artifact.extension + } //javacOptions += "-g" val compileNim = TaskKey[File]("compileNim", "Compile nim code of web interface", KeyRanks.ATask) -compileNim := { - val result = new File("src/main/webapp/jpacrepo.js") - val cmd = s"nim js -d:release -d:serverURL= -o:${result.getPath} nim/jpacrepo.nim" - println(cmd) - sys.process.stringToProcess(cmd).! match +compileNim := { - case 0 => - case _ => throw new RuntimeException("Error occurred during deploy") + val result = new File("nim/nimcache/jpacrepo.js") + val cmd = s"nim js -d:release -d:serverURL= nim/jpacrepo.nim" + println(cmd) + sys.process.stringToProcess(cmd).! match + { + case 0 => + case _ => throw new RuntimeException("Error occurred during deploy") + } +// val outfile = (baseDirectory.value / "nim" / "nimcache" / "jpacrepo.min.js").toString +// val closureCmd = s"closure-compiler --strict_mode_input=false -O ADVANCED --language_in ECMASCRIPT5 --language_out ECMASCRIPT5 --js_output_file=${outfile} ${result.getAbsolutePath}" +// println(closureCmd) +// sys.process.stringToProcess(closureCmd).! match +// { +// case 0 => +// case _ => throw new RuntimeException("Error occurred during deploy") +// } + result } - result -} -//compile in Compile <+= compileNim -packagedArtifact in(Compile, Keys.`package`) := { - val res = (packagedArtifact in(Compile, Keys.`package`)).value - val res2 = compileNim.value - res -} + +webappPostProcess := + { + val baseDir = baseDirectory.value / "nim" / "static" + val nimOutput = compileNim.value + webappDir: File => + { + IO.copyFile(baseDir / "index.html", webappDir / "index.html") + IO.copyFile(baseDir / "jpacrepo.css", webappDir / "jpacrepo.css") + IO.copyFile(nimOutput, webappDir / "jpacrepo.js") + } + } val wildflyUsername = SettingKey[String]("wildfly-username", "The account username to use to connect to wildfly with jboss-cli.sh") val wildflyPassword = SettingKey[String]("wildfly-password", "The account password to use to connect to wildfly with jboss-cli.sh") @@ -76,7 +94,8 @@ wildflyURL := "localhost:1234" val deploy2Wildfly = TaskKey[Unit]("deploy2Wildfly", "Deploy to a wildfly server instance", KeyRanks.ATask) -deploy2Wildfly := { +deploy2Wildfly := + { val cmd = s"/opt/wildfly/bin/jboss-cli.sh " + s"--controller='${wildflyURL.value}' " + s"--connect --user='${wildflyUsername.value}' " + @@ -88,4 +107,4 @@ deploy2Wildfly := { case 0 => case _ => throw new RuntimeException("Error occurred during deploy") } -} + }