From d9298ac824b4edec2e9e774d7ab6ccfb08f27e7b Mon Sep 17 00:00:00 2001 From: Piston Date: Wed, 9 Mar 2016 20:56:19 +0300 Subject: [PATCH] installer with bundled jre --- README.MD | 2 +- build.sbt | 18 +++++- library/src/main/resources/reference.conf | 2 +- project/plugins.sbt | 4 +- setup/launch4j.xml | 32 +++++++++++ setup/setup.iss | 57 +++---------------- src/main/resources/application.conf | 10 ++++ src/main/resources/reference.conf | 11 ---- .../dispatcher/NanoboardDispatcher.scala | 3 +- .../dispatcher/NanoboardSlickDispatcher.scala | 2 +- .../model/NanoboardMessageData.scala | 3 + .../{server => }/model/package.scala | 4 +- .../com/karasiq/nanoboard/server/Main.scala | 2 +- .../nanoboard/server/NanoboardServer.scala | 3 +- src/test/scala/DatabaseTest.scala | 3 +- 15 files changed, 83 insertions(+), 73 deletions(-) create mode 100644 setup/launch4j.xml create mode 100644 src/main/resources/application.conf create mode 100644 src/main/scala/com/karasiq/nanoboard/model/NanoboardMessageData.scala rename src/main/scala/com/karasiq/nanoboard/{server => }/model/package.scala (97%) diff --git a/README.MD b/README.MD index d87b57d..69ef277 100644 --- a/README.MD +++ b/README.MD @@ -1,4 +1,4 @@ -# nanoboard [![Build Status](https://travis-ci.org/Karasiq/nanoboard.svg?branch=master)](https://travis-ci.org/Karasiq/nanoboard) [![Build status](https://ci.appveyor.com/api/projects/status/05l8dnixhn375kjm?svg=true)](https://ci.appveyor.com/project/Karasiq/nanoboard) [![Version](http://img.shields.io/badge/version-1.0.4-blue.svg?style=flat)](https://github.com/Karasiq/nanoboard/releases) +# nanoboard [![Build Status](https://travis-ci.org/Karasiq/nanoboard.svg?branch=master)](https://travis-ci.org/Karasiq/nanoboard) [![Build status](https://ci.appveyor.com/api/projects/status/05l8dnixhn375kjm?svg=true)](https://ci.appveyor.com/project/Karasiq/nanoboard) [![Version](http://img.shields.io/badge/version-1.0.5--M1-blue.svg?style=flat)](https://github.com/Karasiq/nanoboard/releases) Scala [nanoboard](https://github.com/nanoboard/nanoboard) implementation # Links diff --git a/build.sbt b/build.sbt index 9ab8f3c..9e75360 100644 --- a/build.sbt +++ b/build.sbt @@ -1,6 +1,8 @@ +import sbtassembly.Plugin.AssemblyKeys._ + lazy val commonSettings = Seq( organization := "com.github.karasiq", - version := "1.0.4", + version := "1.0.5-M1", isSnapshot := version.value.endsWith("SNAPSHOT"), scalaVersion := "2.11.7" ) @@ -59,6 +61,18 @@ lazy val backendSettings = Seq( "org.scalatest" %% "scalatest" % "2.2.4" % "test" ), mainClass in Compile := Some("com.karasiq.nanoboard.server.Main"), + mainClass in assembly := (mainClass in Compile).value, + jarName in assembly := "nanoboard-server.jar", + test in assembly := {}, + mappings in Universal := { + val universalMappings = (mappings in Universal).value + val fatJar = (assembly in Compile).value + val filtered = universalMappings filter { + case (file, name) ⇒ !name.endsWith(".jar") + } + filtered :+ (fatJar → ("lib/" + fatJar.getName)) + }, + scriptClasspath := Seq((jarName in assembly).value), scalaJsBundlerCompile in Compile <<= (scalaJsBundlerCompile in Compile).dependsOn(fullOptJS in Compile in frontend), scalaJsBundlerAssets in Compile += { import com.karasiq.scalajsbundler.dsl._ @@ -125,7 +139,7 @@ lazy val library = Project("nanoboard", file("library")) lazy val backend = Project("nanoboard-server", file(".")) .dependsOn(library) - .settings(commonSettings, backendSettings) + .settings(assemblySettings, commonSettings, backendSettings) .enablePlugins(ScalaJSBundlerPlugin, JavaAppPackaging) lazy val frontend = Project("nanoboard-frontend", file("frontend")) diff --git a/library/src/main/resources/reference.conf b/library/src/main/resources/reference.conf index 97cd016..de173d9 100644 --- a/library/src/main/resources/reference.conf +++ b/library/src/main/resources/reference.conf @@ -1,5 +1,5 @@ nanoboard { - version = 1.0.4 + version = 1.0.5-M1 client-version = karasiq-nanoboard v${nanoboard.version} encryption-key = "nano" bitmessage { diff --git a/project/plugins.sbt b/project/plugins.sbt index 35a781a..bee7ebf 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,11 @@ logLevel := Level.Warn -addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.0.6") +addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.1.0-RC2") addSbtPlugin("com.github.karasiq" % "sbt-scalajs-bundler" % "1.0.5") addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.7") +addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.11.2") + libraryDependencies += "com.lihaoyi" %% "scalatags" % "0.5.4" \ No newline at end of file diff --git a/setup/launch4j.xml b/setup/launch4j.xml new file mode 100644 index 0000000..bc367db --- /dev/null +++ b/setup/launch4j.xml @@ -0,0 +1,32 @@ + + + false + console + G:\Data\IdeaProjects\nanoboard\target\universal\stage\lib\nanoboard-server.jar + G:\Data\IdeaProjects\nanoboard\target\universal\nanoboard.exe + + + . + normal + http://java.com/download + + false + false + + G:\Data\IdeaProjects\nanoboard\frontend\files\favicon.ico + + nanoboard-server + + + + jre1.8.0_74 + false + true + 1.8.0 + + preferJre + 64/32 + 128 + 512 + + \ No newline at end of file diff --git a/setup/setup.iss b/setup/setup.iss index 4457bf0..a6f4d91 100644 --- a/setup/setup.iss +++ b/setup/setup.iss @@ -1,9 +1,9 @@ -#define OutputName "nanoboard" +#define OutputName "nanoboard-server" #define MyAppName "Nanoboard" -#define MyAppVersion "1.0.4" +#define MyAppVersion "1.0.5-M1" #define MyAppPublisher "Karasiq, Inc." #define MyAppURL "http://www.github.com/Karasiq/nanoboard" -#define MyAppExeName "bin\nanoboard-server.bat" +#define MyAppExeName "nanoboard.exe" #define ProjectFolder "..\" [Setup] @@ -32,54 +32,15 @@ Name: russian; MessagesFile: compiler:Languages\Russian.isl Name: desktopicon; Description: {cm:CreateDesktopIcon}; GroupDescription: {cm:AdditionalIcons}; Languages: [Files] -Source: {#ProjectFolder}\target\universal\stage\*; DestDir: {app}; Flags: ignoreversion recursesubdirs -Source: {#ProjectFolder}\setup\places.txt; DestDir: {app} -Source: {#ProjectFolder}\setup\categories.txt; DestDir: {app} -Source: {#ProjectFolder}\frontend\files\favicon.ico; DestDir: {app} +Source: {#ProjectFolder}\target\universal\nanoboard.exe; DestDir: {app}; Flags: ignoreversion +Source: G:\Temp\Java\jre1.8.0_74\*; DestDir: {app}\jre1.8.0_74; Flags: recursesubdirs ignoreversion +Source: {#ProjectFolder}\setup\places.txt; DestDir: {app}; Flags: ignoreversion +Source: {#ProjectFolder}\setup\categories.txt; DestDir: {app}; Flags: ignoreversion +Source: {#ProjectFolder}\frontend\files\favicon.ico; DestDir: {app}; Flags: ignoreversion [Icons] Name: {group}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; IconFilename: {app}\favicon.ico; WorkingDir: {app} Name: {commondesktop}\{#MyAppName}; Filename: {app}\{#MyAppExeName}; Tasks: desktopicon; IconFilename: {app}\favicon.ico; WorkingDir: {app} [Run] -Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}; Flags: shellexec postinstall skipifsilent; WorkingDir: {app}; Check: IsJREInstalled - -[Code] -#define MinJRE "1.8" -#define WebJRE "https://www.java.com/ru/download/manual.jsp" - -function IsJREInstalled: Boolean; -var - JREVersion: string; -begin - // read JRE version - Result := RegQueryStringValue(HKLM32, 'Software\JavaSoft\Java Runtime Environment', - 'CurrentVersion', JREVersion); - // if the previous reading failed and we're on 64-bit Windows, try to read - // the JRE version from WOW node - if not Result and IsWin64 then - Result := RegQueryStringValue(HKLM64, 'Software\JavaSoft\Java Runtime Environment', - 'CurrentVersion', JREVersion); - // if the JRE version was read, check if it's at least the minimum one - if Result then - Result := CompareStr(JREVersion, '{#MinJRE}') >= 0; -end; - -function InitializeSetup: Boolean; -var - ErrorCode: Integer; -begin - Result := True; - // check if JRE is installed; if not, then... - if not IsJREInstalled then - begin - // show a message box and let user to choose if they want to download JRE; - // if so, go to its download site and exit setup; continue otherwise - if MsgBox('Java is required. Do you want to download it now ?', - mbConfirmation, MB_YESNO) = IDYES then - begin - Result := False; - ShellExec('', '{#WebJRE}', '', '', SW_SHOWNORMAL, ewNoWait, ErrorCode); - end; - end; -end; \ No newline at end of file +Filename: {app}\{#MyAppExeName}; Description: {cm:LaunchProgram,{#StringChange(MyAppName, '&', '&&')}}; Flags: shellexec postinstall skipifsilent; WorkingDir: {app} \ No newline at end of file diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf new file mode 100644 index 0000000..9d6e55f --- /dev/null +++ b/src/main/resources/application.conf @@ -0,0 +1,10 @@ +akka.http { + server { + server-header = nanoboard/${nanoboard.version} + idle-timeout = 24h + } + + client { + user-agent-header = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.52 Safari/537.36 OPR/31.0.1889.50 (Edition beta)" + } +} \ No newline at end of file diff --git a/src/main/resources/reference.conf b/src/main/resources/reference.conf index 93f3db5..654b946 100644 --- a/src/main/resources/reference.conf +++ b/src/main/resources/reference.conf @@ -32,15 +32,4 @@ nanoboard { username = "nanoapi" password = "nano" } -} - -akka.http { - server { - server-header = nanoboard/${nanoboard.version} - idle-timeout = 24h - } - - client { - user-agent-header = "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.52 Safari/537.36 OPR/31.0.1889.50 (Edition beta)" - } } \ No newline at end of file diff --git a/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardDispatcher.scala b/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardDispatcher.scala index 7240b28..6729aed 100644 --- a/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardDispatcher.scala +++ b/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardDispatcher.scala @@ -2,10 +2,11 @@ package com.karasiq.nanoboard.dispatcher import akka.util.ByteString import com.karasiq.nanoboard.NanoboardCategory +import com.karasiq.nanoboard.model.NanoboardMessageData import scala.concurrent.Future -case class NanoboardMessageData(parent: Option[String], hash: String, text: String, answers: Int) + trait NanoboardDispatcher { def createContainer(pending: Int, random: Int, format: String, container: ByteString): Future[ByteString] diff --git a/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardSlickDispatcher.scala b/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardSlickDispatcher.scala index 7818bb9..38efa3c 100644 --- a/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardSlickDispatcher.scala +++ b/src/main/scala/com/karasiq/nanoboard/dispatcher/NanoboardSlickDispatcher.scala @@ -9,7 +9,7 @@ import akka.stream.{ActorMaterializer, OverflowStrategy} import akka.util.ByteString import com.karasiq.nanoboard.encoding.DataEncodingStage._ import com.karasiq.nanoboard.encoding.stages.{GzipCompression, PngEncoding, SalsaCipher} -import com.karasiq.nanoboard.server.model._ +import com.karasiq.nanoboard.model._ import com.karasiq.nanoboard.{NanoboardCategory, NanoboardMessage} import com.typesafe.config.{Config, ConfigFactory} import slick.driver.H2Driver.api._ diff --git a/src/main/scala/com/karasiq/nanoboard/model/NanoboardMessageData.scala b/src/main/scala/com/karasiq/nanoboard/model/NanoboardMessageData.scala new file mode 100644 index 0000000..9cee03b --- /dev/null +++ b/src/main/scala/com/karasiq/nanoboard/model/NanoboardMessageData.scala @@ -0,0 +1,3 @@ +package com.karasiq.nanoboard.model + +case class NanoboardMessageData(parent: Option[String], hash: String, text: String, answers: Int) diff --git a/src/main/scala/com/karasiq/nanoboard/server/model/package.scala b/src/main/scala/com/karasiq/nanoboard/model/package.scala similarity index 97% rename from src/main/scala/com/karasiq/nanoboard/server/model/package.scala rename to src/main/scala/com/karasiq/nanoboard/model/package.scala index fa08a55..dd7e65f 100644 --- a/src/main/scala/com/karasiq/nanoboard/server/model/package.scala +++ b/src/main/scala/com/karasiq/nanoboard/model/package.scala @@ -1,9 +1,7 @@ -package com.karasiq.nanoboard.server +package com.karasiq.nanoboard import java.time.Instant -import com.karasiq.nanoboard.dispatcher.NanoboardMessageData -import com.karasiq.nanoboard.{NanoboardCategory, NanoboardMessage} import slick.driver.H2Driver.api._ import scala.concurrent.ExecutionContext diff --git a/src/main/scala/com/karasiq/nanoboard/server/Main.scala b/src/main/scala/com/karasiq/nanoboard/server/Main.scala index 0b4e357..22c0673 100644 --- a/src/main/scala/com/karasiq/nanoboard/server/Main.scala +++ b/src/main/scala/com/karasiq/nanoboard/server/Main.scala @@ -9,8 +9,8 @@ import akka.http.scaladsl.Http.ServerBinding import akka.stream.scaladsl._ import akka.stream.{ActorMaterializer, ActorMaterializerSettings} import com.karasiq.nanoboard.dispatcher.NanoboardSlickDispatcher +import com.karasiq.nanoboard.model.{Place, Post, _} import com.karasiq.nanoboard.server.cache.MapDbNanoboardCache -import com.karasiq.nanoboard.server.model.{Place, Post, _} import com.karasiq.nanoboard.server.util.MessageValidator import com.karasiq.nanoboard.sources.bitmessage.BitMessageTransport import com.karasiq.nanoboard.sources.png.UrlPngSource diff --git a/src/main/scala/com/karasiq/nanoboard/server/NanoboardServer.scala b/src/main/scala/com/karasiq/nanoboard/server/NanoboardServer.scala index 7a50c9d..d0b7095 100644 --- a/src/main/scala/com/karasiq/nanoboard/server/NanoboardServer.scala +++ b/src/main/scala/com/karasiq/nanoboard/server/NanoboardServer.scala @@ -8,7 +8,8 @@ import akka.stream.scaladsl.{Flow, GraphDSL, Source} import akka.stream.{ActorMaterializer, FlowShape} import akka.util.ByteString import boopickle.Default._ -import com.karasiq.nanoboard.dispatcher.{NanoboardDispatcher, NanoboardMessageData} +import com.karasiq.nanoboard.dispatcher.NanoboardDispatcher +import com.karasiq.nanoboard.model.NanoboardMessageData import com.karasiq.nanoboard.server.util.AttachmentGenerator import com.karasiq.nanoboard.{NanoboardCategory, NanoboardMessage} diff --git a/src/test/scala/DatabaseTest.scala b/src/test/scala/DatabaseTest.scala index f6aaf74..4860f27 100644 --- a/src/test/scala/DatabaseTest.scala +++ b/src/test/scala/DatabaseTest.scala @@ -1,6 +1,5 @@ import com.karasiq.nanoboard.NanoboardMessage -import com.karasiq.nanoboard.dispatcher.NanoboardMessageData -import com.karasiq.nanoboard.server.model._ +import com.karasiq.nanoboard.model._ import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers} import slick.driver.H2Driver.api._