From 4265673587235977ea0ef146a8d21f58893acf32 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sun, 31 Mar 2019 14:09:50 -0400 Subject: [PATCH 1/9] Update dependencies and SNAPSHOT build number. --- build.sbt | 4 ++-- example/build.sbt | 4 ++-- example/project/build.properties | 2 +- example/project/plugin-install4j.sbt | 6 +++++- project/build.properties | 2 +- 5 files changed, 11 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index 08e16fd..879826e 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ sbtPlugin := true name := "sbt-install4j" organization := "com.github.jpsacha" -version := "1.2.0" +version := "1.2.1-SHAPSHOT" homepage := Some(url("http://github.com/jpsacha/sbt-install4j")) organizationHomepage := Some(url("http://ij-plugins.sf.net")) @@ -11,7 +11,7 @@ startYear := Some(2014) licenses := Seq("GPLv3" -> url("http://www.gnu.org/licenses/gpl.html")) description := "SBT plugin for building installers with Install4J." -scalaVersion := "2.12.3" +scalaVersion := "2.12.8" scalacOptions := Seq("-deprecation", "-unchecked") diff --git a/example/build.sbt b/example/build.sbt index 14db1e3..be05d8d 100644 --- a/example/build.sbt +++ b/example/build.sbt @@ -1,8 +1,8 @@ name := "sbt-install4j-example" organization := "ij-plugins.sf.net" -version := "1.2.01" +version := "1.3.0-SHAPSHOT" -scalaVersion := "2.12.3" +scalaVersion := "2.12.8" // Set the prompt (for this build) to include the project id. shellPrompt in ThisBuild := { state => "sbt:"+Project.extract(state).currentRef.project + "> " } diff --git a/example/project/build.properties b/example/project/build.properties index 266acc6..e2820dd 100644 --- a/example/project/build.properties +++ b/example/project/build.properties @@ -1,2 +1,2 @@ -sbt.version=1.1.0 +sbt.version=1.2.8 diff --git a/example/project/plugin-install4j.sbt b/example/project/plugin-install4j.sbt index 9330739..4ab48f2 100644 --- a/example/project/plugin-install4j.sbt +++ b/example/project/plugin-install4j.sbt @@ -1,2 +1,6 @@ // [[https://github.com/jpsacha/sbt-install4j]] -addSbtPlugin("com.github.jpsacha" % "sbt-install4j" % "1.2.0") + +// For test publishing with `publishM2` +resolvers += Resolver.mavenLocal + +addSbtPlugin("com.github.jpsacha" % "sbt-install4j" % "1.3.0-SHAPSHOT") diff --git a/project/build.properties b/project/build.properties index 8b697bb..c0bab04 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.1.0 +sbt.version=1.2.8 From 215fbd203165614f0399951d0f1a5baf3564580b Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sun, 31 Mar 2019 21:16:07 -0400 Subject: [PATCH 2/9] Add better support for determining location of install4jc (#7, #8, #9) --- README.md | 34 +++++++++++++-- build.sbt | 4 +- .../sf/sbt/install4j/Defaults.scala | 43 +++++++++++++++++++ .../sf/sbt/install4j/SBTInstall4J.scala | 26 ++++++++--- .../sf/sbt/install4j/DefaultsTest.scala | 30 +++++++++++++ 5 files changed, 128 insertions(+), 9 deletions(-) create mode 100644 src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala create mode 100644 src/test/scala/net/ij_plugins/sf/sbt/install4j/DefaultsTest.scala diff --git a/README.md b/README.md index 018dd76..aff8d76 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,12 @@ sbt-install4j ============= +[![Build Status](https://travis-ci.org/jpsacha/sbt-install4j.svg?branch=master)](https://travis-ci.org/jpsacha/sbt-install4j) [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.jpsacha/sbt-install4j/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.jpsacha/sbt-install4j) + + [SBT] plugin for building installers with [Install4J]. + Usage ----- @@ -24,7 +28,7 @@ enablePlugins(SBTInstall4J) install4jProjectFile := "installer/example.install4j" ``` -### Available Tasks and Settings +## Available Tasks and Settings SBT tasks provided by `sbt-install4j` plugin: @@ -43,8 +47,7 @@ SBT settings provided by `sbt-install4j` plugin: * `install4jCopyDependedJarsEnabled` : Boolean - if `true` dependent jars will be copies, if `false` they will be not. -* `install4jHomeDir` : File - - Install4J installation directory. It assumes that Install4J compiler is in subdirectory `bin/install4jc.exe` +* `install4jcFile` : File - Location of the install4j's command line compiler `install4jc[.exe]`. It can be found in the `bin` directory of the install4j installation. Default can be set with environment variable `INSTALL4JC_FILE`. * `install4jProjectFile` : String - The install4j project file that should be build. @@ -61,6 +64,31 @@ SBT settings provided by `sbt-install4j` plugin: * `install4jCompilerVariables` : Map[String, String] - Override a compiler variable with a different value. In the map, the `key` is variable's name, the `value` is variable's value. + +* `install4jHomeDir` : File - __Deprecated__. Install4J installation directory. It assumes that Install4J compiler is in subdirectory `bin`. Default can be set with environment variable `INSTALL4J_HOME`. This option is deprecated, use environment variable `INSTALL4JC_FILE` or setting `install4jcFile` instead. + +## Determining location of Install4J libraries and compiler + +The `sbt-install4j` executes Install4J compiler. It needs to know its location. It will attempts to determine location base on the OS used. On Windows it is assumed to be: +``` +C:\Program Files\Install4J7\bin\intall4jc.exe + +``` + +On Mac OS X: +``` +/Applications/install4j.app/Contents/Resources/app/bin/install4jc +``` + +On Linux: +``` +/opt/install4j/bin/install4jc +``` + +If the Install4J is installed in a different location you can specify location of the compiler using the environment variable `INSTALL4JC_FILE` or setting `install4jcFile`. For multi-platform builds it is preferred to use the environment variable `INSTALL4JC_FILE`. + + + [Install4J]: https://www.ej-technologies.com/products/install4j/overview.html diff --git a/build.sbt b/build.sbt index 879826e..d06bba5 100644 --- a/build.sbt +++ b/build.sbt @@ -3,7 +3,7 @@ sbtPlugin := true name := "sbt-install4j" organization := "com.github.jpsacha" -version := "1.2.1-SHAPSHOT" +version := "1.3.0-SHAPSHOT" homepage := Some(url("http://github.com/jpsacha/sbt-install4j")) organizationHomepage := Some(url("http://ij-plugins.sf.net")) @@ -15,6 +15,8 @@ scalaVersion := "2.12.8" scalacOptions := Seq("-deprecation", "-unchecked") +libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.7" % "test" + publishArtifact in(Test, packageBin) := false publishArtifact in(Test, packageDoc) := false publishArtifact in(Test, packageSrc) := false diff --git a/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala b/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala new file mode 100644 index 0000000..77d30f2 --- /dev/null +++ b/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala @@ -0,0 +1,43 @@ +package net.ij_plugins.sf.sbt.install4j + +import java.io.File + +object Defaults { + + val INSTALL4J_HOME_ENV = "INSTALL4J_HOME" + val INSTALL4JC_FILE_ENV = "INSTALL4JC_FILE" + + def install4jHomeDir(): String = { + // First check for INSTALL4J_HOME, and if available use that + Option(System.getProperty(INSTALL4J_HOME_ENV, null)) match { + case Some(s) => s + case _ => + val osName = System.getProperty("os.name") + + if (osName.startsWith("Windows")) + "C:/Program Files/install4j7" + else if (osName.equals("Linux")) + "/opt/install4j7" + else if (osName.equals("Mac OS X")) + "/Applications/install4j.app/Contents/Resources/app" + else + throw new UnsupportedOperationException( + "Cannot determine default 'Install4jHomeDir'. Unsupported OS: " + osName) + } + } + + def install4jCompilerFile(install4jHomeDir: String = Defaults.install4jHomeDir()): File = { + // First check for INSTALL4JC_PATH, and if available use that + Option(System.getProperty(INSTALL4JC_FILE_ENV, null)) match { + case Some(s) => new File(s) + case _ => new File(install4jHomeDir, "bin/" + compilerName()) + } + } + + def compilerName(): String = { + if (System.getProperty("os.name").startsWith("Windows")) + "install4jc.exe" + else + "install4jc" + } +} diff --git a/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala b/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala index 0cb5626..400b6a1 100644 --- a/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala +++ b/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala @@ -21,6 +21,7 @@ import java.io.{File, IOException} import sbt.Keys._ import sbt._ +import scala.collection.mutable import scala.sys.process.Process /** SBT plugin for building installers with Install4J. */ @@ -45,7 +46,18 @@ object SBTInstall4J extends sbt.AutoPlugin { lazy val install4jHomeDir: SettingKey[File] = SettingKey[File]( "install4jHomeDir", - "Install4J installation directory. It assumes that Install4J compiler is in subdirectory `bin/install4jc.exe`.") + "Deprecated. Install4J installation directory. " + + "It assumes that Install4J compiler is in subdirectory `bin`. " + + s"Default can be set with environment variable ${Defaults.INSTALL4J_HOME_ENV}. " + + s"This option is deprecated, use environment variable ${Defaults.INSTALL4JC_FILE_ENV} " + + "or setting `install4jcFile` instead.") + + lazy val install4jcFile: SettingKey[File] = SettingKey[File]( + "install4jcFile", + "Location of the install4j's command line compiler `install4jc[.exe]`. " + + "It can be found in the `bin` directory of the install4j installation. " + + s"Default can be set with environment variable ${Defaults.INSTALL4JC_FILE_ENV}." + + "") lazy val install4jProjectFile: SettingKey[String] = SettingKey[String]( "install4jProjectFile", @@ -80,7 +92,7 @@ object SBTInstall4J extends sbt.AutoPlugin { val _v2 = install4jCopyDependedJars.value assert(_v2 != null) - val install4jCompiler = new File(install4jHomeDir.value, "bin/install4jc.exe").getCanonicalFile + val install4jCompiler = Defaults.install4jCompilerFile().getCanonicalFile val install4jProject = new File(baseDirectory.value, install4jProjectFile.value).getCanonicalFile runInstall4J( install4jCompiler, @@ -113,7 +125,9 @@ object SBTInstall4J extends sbt.AutoPlugin { install4jCopyDependedJarsEnabled := true, - install4jHomeDir := file("C:/Program Files/install4j7"), + install4jHomeDir := file(Defaults.install4jHomeDir()), + + install4jcFile := file(Defaults.install4jCompilerFile().getCanonicalPath), install4jProjectFile := "installer/installer.install4j", @@ -159,11 +173,13 @@ object SBTInstall4J extends sbt.AutoPlugin { val logger = taskStreams.log logger.debug(prefix + "compiler: " + compiler.getAbsolutePath) - if (!compiler.exists) throw new IOException("Install4J Compiler not found: " + compiler.getAbsolutePath) + if (!compiler.exists) throw new IOException( + "Install4J Compiler not found at: " + compiler.getAbsolutePath) logger.debug(prefix + "project: " + project.getAbsolutePath) if (!project.exists) { - throw new IOException("install4j project file not found: " + project.getAbsolutePath) + throw new IOException("install4j project file not found: " + + "" + project.getAbsolutePath) } var commandLine = "\"" + compiler.getPath + "\"" diff --git a/src/test/scala/net/ij_plugins/sf/sbt/install4j/DefaultsTest.scala b/src/test/scala/net/ij_plugins/sf/sbt/install4j/DefaultsTest.scala new file mode 100644 index 0000000..c360d03 --- /dev/null +++ b/src/test/scala/net/ij_plugins/sf/sbt/install4j/DefaultsTest.scala @@ -0,0 +1,30 @@ +package net.ij_plugins.sf.sbt.install4j + +import java.io.File + +import org.scalatest.FlatSpec +import org.scalatest.Matchers._ + +class DefaultsTest extends FlatSpec { + + it should "determine install4jHomeDir from environment variable" in { + val f = File.createTempFile("_env_", "_env_") + val path_name = f.getCanonicalPath + System.setProperty(Defaults.INSTALL4J_HOME_ENV, path_name) + + val install4jHomeDir = Defaults.install4jHomeDir() + + install4jHomeDir should be(path_name) + } + + it should "determine install4jCompilerFile from environment variable" in { + val f = File.createTempFile("_env_", "_env_") + val path_name = f.getCanonicalPath + System.setProperty(Defaults.INSTALL4JC_FILE_ENV, path_name) + + val install4jCompilerFile = Defaults.install4jCompilerFile().getCanonicalPath + + install4jCompilerFile should be(path_name) + } + +} From 908e45d451bc3396aa6bdc57f37d1dbf3ccd3bbd Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sun, 31 Mar 2019 21:18:17 -0400 Subject: [PATCH 3/9] Improve reliability of command line process invocation. --- .../sf/sbt/install4j/SBTInstall4J.scala | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala b/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala index 400b6a1..fed1c72 100644 --- a/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala +++ b/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala @@ -182,27 +182,30 @@ object SBTInstall4J extends sbt.AutoPlugin { "" + project.getAbsolutePath) } - var commandLine = "\"" + compiler.getPath + "\"" + val commandLine = mutable.ListBuffer.empty[String] + + commandLine += compiler.getCanonicalPath // Verbose - if (verbose) commandLine += " --verbose" + if (verbose) commandLine += "--verbose" // Release - if (release.trim.nonEmpty) commandLine += " --release=" + release.trim + if (release.trim.nonEmpty) commandLine += "--release=" + release.trim // Compiler variables if (compilerVariables.nonEmpty) { - commandLine += " -D \"" + + commandLine += "-D" + commandLine += "\"" + compilerVariables.map { case (k, v) => k.trim + "=" + v.trim }.mkString(",") + "\"" } - commandLine += " \"" + project.getPath + "\"" + commandLine += project.getPath - logger.debug(prefix + "executing command: " + commandLine) - val output = Process(commandLine).lines + logger.debug(prefix + "executing command: " + commandLine.mkString(" ")) + val output = Process(commandLine).lineStream output.foreach(println) } } From 01e90d56e63a6582e312295999d8368bdb12d516 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sun, 31 Mar 2019 21:19:08 -0400 Subject: [PATCH 4/9] Upgrade example installer settings format to v.7. --- example/installer/example.install4j | 789 ++++++++++++++++++++++++++-- 1 file changed, 749 insertions(+), 40 deletions(-) diff --git a/example/installer/example.install4j b/example/installer/example.install4j index 18e0fa7..2cd660c 100644 --- a/example/installer/example.install4j +++ b/example/installer/example.install4j @@ -1,7 +1,7 @@ - + - + @@ -15,7 +15,10 @@ - + + + + @@ -26,33 +29,39 @@ + - + + + + + - + + - + @@ -65,18 +74,19 @@ - + + - + @@ -93,20 +103,82 @@ context.getBooleanVariable("sys.confirmedUpdateInstallation") - + + + + + + + ${form:welcomeMessage} + + + + + + !context.isConsole() + + + + + + + + + + String message = context.getMessage("ConsoleWelcomeLabel", context.getApplicationName()); +return console.askOkCancel(message, true); + + + + + + + + + + + + + + + + + + + + + updateCheck + + + + + + + + ${i18n:ClickNext} + + + + + + + + + - + + !context.getBooleanVariable("sys.confirmedUpdateInstallation") - + @@ -123,22 +195,95 @@ context.getVariable("sys.responseFile") == null - + + + + + + + ${i18n:SelectDirLabel(${compiler:sys.fullName})} + + + + + + + + + + + + + + true + + + + + + + + suggestAppDir + validateApplicationId + existingDirWarning + checkWritable + manualEntryAllowed + checkFreeSpace + showRequiredDiskSpace + showFreeDiskSpace + allowSpacesOnUnix + validationScript + standardValidation + + + - + + - + + + + + + + ${i18n:SelectComponentsLabel2} + + + + + + !context.isConsole() + + + + + + + + true + + + + + + + + selectionChangedScript + + + - + @@ -148,6 +293,7 @@ + !context.getBooleanVariable("sys.confirmedUpdateInstallation") @@ -155,18 +301,19 @@ - + + - + @@ -174,10 +321,13 @@ - + + + true + ${i18n:UninstallerMenuEntry(${compiler:sys.fullName})} @@ -186,7 +336,7 @@ !context.getBooleanVariable("sys.programGroupDisabled") - + @@ -199,44 +349,87 @@ - + + + + + + + ${i18n:WizardPreparing} + + + + + + + + + - + + - + + + + + + + ${form:finishedMessage} + + + + + + + + + - + - + + + ${i18n:UninstallerMenuEntry(${compiler:sys.fullName})} + + + true + + + + + + - + + - + @@ -244,7 +437,7 @@ - + @@ -257,31 +450,68 @@ - + + - + + + + + + + ${form:welcomeMessage} + + + + + + !context.isConsole() + + + + + + + + + + String message = context.getMessage("ConfirmUninstall", context.getApplicationName()); +return console.askYesNo(message, true); + + + + + + + + + + + + - + + - + @@ -290,14 +520,30 @@ - + + + + + + + ${i18n:UninstallerPreparing} + + + + + + + + + - + + @@ -305,25 +551,491 @@ - + + - + + + + + + + ${form:successMessage} + + + + + + + + + + + + + + + + + + + + + + + + - + + + @@ -333,11 +1045,8 @@ - - - + - From 99dbdcd7a6e5b1a4cb46ab437ce7435b6d4cbd2c Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sun, 31 Mar 2019 21:22:19 -0400 Subject: [PATCH 5/9] Add Travis CI setup. --- .travis.yml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..5b9360f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,20 @@ +sudo: false + +language: scala +scala: +- 2.12.8 + +jdk: + - oraclejdk8 + +install: true + +script: + - java -version + - sbt test + +branches: + only: + - master + - develop + From 55a2b01b7781c284ecc86cc92f77fa14ff7b44d4 Mon Sep 17 00:00:00 2001 From: jarek Date: Sun, 31 Mar 2019 21:25:54 -0400 Subject: [PATCH 6/9] Update README.md Correction: only compier location needed. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aff8d76..86d69a5 100644 --- a/README.md +++ b/README.md @@ -67,7 +67,7 @@ SBT settings provided by `sbt-install4j` plugin: * `install4jHomeDir` : File - __Deprecated__. Install4J installation directory. It assumes that Install4J compiler is in subdirectory `bin`. Default can be set with environment variable `INSTALL4J_HOME`. This option is deprecated, use environment variable `INSTALL4JC_FILE` or setting `install4jcFile` instead. -## Determining location of Install4J libraries and compiler +## Determining location of Install4J compiler The `sbt-install4j` executes Install4J compiler. It needs to know its location. It will attempts to determine location base on the OS used. On Windows it is assumed to be: ``` @@ -92,4 +92,4 @@ If the Install4J is installed in a different location you can specify location o [Install4J]: https://www.ej-technologies.com/products/install4j/overview.html -[SBT]: http://www.scala-sbt.org/ \ No newline at end of file +[SBT]: http://www.scala-sbt.org/ From af22f7d3b6db51c28e29c8e8278ef0698f0f327a Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Wed, 3 Apr 2019 19:53:40 -0400 Subject: [PATCH 7/9] Support extra command line options [#10, #11] --- README.md | 27 ++++++++++++++++-- .../sf/sbt/install4j/Defaults.scala | 16 +++++++++++ .../sf/sbt/install4j/SBTInstall4J.scala | 28 ++++++++++++++++--- 3 files changed, 65 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 86d69a5..b8c417a 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,21 @@ install4jProjectFile := "installer/example.install4j" SBT tasks provided by `sbt-install4j` plugin: * `install4j` : Task - - Builds Install4J project + Builds Install4J project. Simple usage from SBT REPL + ``` + sbt> install4j + ``` + It will build project defined in by setting `install4jProjectFile` + + It can take optional arguments that are passed by to the Install4J compiler. + Refer to `install4jc` documentation in [Install4J Help](https://www.ej-technologies.com/resources/install4j/help/doc/#install4j.cli) for list of supported command line options. You can print option summary from SBT REPL using + ``` + sbt> install4j --help + ``` + Example of only building `windows` media type + ``` + sbt> install4j -m windows + ``` * `install4jCopyDependedJars` : Task - Copies project dependencies to directory `install4jDependedJarsDir` @@ -49,10 +63,12 @@ SBT settings provided by `sbt-install4j` plugin: * `install4jcFile` : File - Location of the install4j's command line compiler `install4jc[.exe]`. It can be found in the `bin` directory of the install4j installation. Default can be set with environment variable `INSTALL4JC_FILE`. -* `install4jProjectFile` : String - The install4j project file that should be build. +* `install4jProjectFile` : String - Relative path to the install4j project file that should be build. * `install4jDependedJarsDir` : String - Location where dependent jars will be copied. + +* `install4jExtraOptions` : Seq[String] - "Additional command line options passed to the compiler." * `install4jVerbose` : Boolean - Enables verbose mode. @@ -87,6 +103,13 @@ On Linux: If the Install4J is installed in a different location you can specify location of the compiler using the environment variable `INSTALL4JC_FILE` or setting `install4jcFile`. For multi-platform builds it is preferred to use the environment variable `INSTALL4JC_FILE`. +## Tips & Tricks + +To see debugging information set SBT logging level to `debug`: +```cmd +sbt> debug +``` +Look in the log for lines prefixed with `[debug] [sbt-install4j]`. diff --git a/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala b/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala index 77d30f2..08d71f7 100644 --- a/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala +++ b/src/main/scala/net/ij_plugins/sf/sbt/install4j/Defaults.scala @@ -1,3 +1,19 @@ +/* + * Copyright 2014-2019 Jarek Sacha (jpsacha -at- gmail.com) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package net.ij_plugins.sf.sbt.install4j import java.io.File diff --git a/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala b/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala index fed1c72..54db6a1 100644 --- a/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala +++ b/src/main/scala/net/ij_plugins/sf/sbt/install4j/SBTInstall4J.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014 Jarek Sacha (jpsacha -at- gmail.com) + * Copyright 2014-2019 Jarek Sacha (jpsacha -at- gmail.com) * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +20,7 @@ import java.io.{File, IOException} import sbt.Keys._ import sbt._ +import sbt.complete.DefaultParsers._ import scala.collection.mutable import scala.sys.process.Process @@ -28,9 +29,11 @@ import scala.sys.process.Process object SBTInstall4J extends sbt.AutoPlugin { object autoImport { - lazy val install4j: TaskKey[Unit] = TaskKey[Unit]( + lazy val install4j: InputKey[Unit] = InputKey[Unit]( "install4j", - "Builds Install4J project.") + "Builds Install4J project. " + + "It can take optional argument that are passed by to the Install4J compiler. " + + "Refer to `install4jc` documentation in Install4J Help for list of supported command line options.") lazy val install4jCopyDependedJars: TaskKey[File] = TaskKey[File]( "install4jCopyDependedJars", @@ -61,12 +64,16 @@ object SBTInstall4J extends sbt.AutoPlugin { lazy val install4jProjectFile: SettingKey[String] = SettingKey[String]( "install4jProjectFile", - "The install4j project file that should be build.") + "Relative path to the install4j project file that should be build.") lazy val install4jDependedJarsDir: SettingKey[String] = SettingKey[String]( "install4jDependedJarsDir", "Location where dependent jars will be copied.") + lazy val install4jExtraOptions: SettingKey[Seq[String]] = SettingKey[Seq[String]]( + "install4jExtraOptions", + "Additional command line options passed to the compiler.") + lazy val install4jVerbose: SettingKey[Boolean] = SettingKey[Boolean]( "install4jVerbose", "Enables verbose mode.") @@ -86,6 +93,9 @@ object SBTInstall4J extends sbt.AutoPlugin { override def projectSettings: Seq[Def.Setting[_]] = Seq( install4j := { + // get the result of parsing + val extraArgs: Seq[String] = spaceDelimited("").parsed + // Run dependent tasks first val _v1 = (packageBin in Compile).value assert(_v1 != null) @@ -100,6 +110,8 @@ object SBTInstall4J extends sbt.AutoPlugin { verbose = install4jVerbose.value, release = install4jRelease.value, compilerVariables = install4jCompilerVariables.value, + extraOptions = install4jExtraOptions.value, + extraArgs = extraArgs, streams.value) }, @@ -125,6 +137,8 @@ object SBTInstall4J extends sbt.AutoPlugin { install4jCopyDependedJarsEnabled := true, + install4jExtraOptions := Seq.empty[String], + install4jHomeDir := file(Defaults.install4jHomeDir()), install4jcFile := file(Defaults.install4jCompilerFile().getCanonicalPath), @@ -169,6 +183,8 @@ object SBTInstall4J extends sbt.AutoPlugin { verbose: Boolean, release: String, compilerVariables: Map[String, String], + extraOptions: Seq[String], + extraArgs: Seq[String], taskStreams: TaskStreams) { val logger = taskStreams.log @@ -204,6 +220,10 @@ object SBTInstall4J extends sbt.AutoPlugin { commandLine += project.getPath + commandLine ++= extraOptions + + commandLine ++= extraArgs + logger.debug(prefix + "executing command: " + commandLine.mkString(" ")) val output = Process(commandLine).lineStream output.foreach(println) From 3dc169a2de0a7203e574fe4e603a6e326bb792bf Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sat, 6 Apr 2019 09:48:10 -0400 Subject: [PATCH 8/9] Clarify which license is used [#12]. --- README.md | 6 ++++++ build.sbt | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b8c417a..a337c18 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,13 @@ sbt> debug Look in the log for lines prefixed with `[debug] [sbt-install4j]`. +## License + +sbt-install4j is licensed under [Apache 2.0 license][Apache2]. + + [Install4J]: https://www.ej-technologies.com/products/install4j/overview.html [SBT]: http://www.scala-sbt.org/ +[Apache2]: https://www.apache.org/licenses/LICENSE-2.0.html diff --git a/build.sbt b/build.sbt index d06bba5..2a940ab 100644 --- a/build.sbt +++ b/build.sbt @@ -8,7 +8,7 @@ version := "1.3.0-SHAPSHOT" homepage := Some(url("http://github.com/jpsacha/sbt-install4j")) organizationHomepage := Some(url("http://ij-plugins.sf.net")) startYear := Some(2014) -licenses := Seq("GPLv3" -> url("http://www.gnu.org/licenses/gpl.html")) +licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")) description := "SBT plugin for building installers with Install4J." scalaVersion := "2.12.8" From c6f90ddc8449d8b1fabcf29ff20ca35170921f45 Mon Sep 17 00:00:00 2001 From: Jarek Sacha Date: Sat, 6 Apr 2019 09:49:11 -0400 Subject: [PATCH 9/9] Update dependencies for Sonatype publishing. --- project/sbt-sonatype.sbt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project/sbt-sonatype.sbt b/project/sbt-sonatype.sbt index 38cee59..8259c7a 100644 --- a/project/sbt-sonatype.sbt +++ b/project/sbt-sonatype.sbt @@ -1,4 +1,4 @@ // [https://github.com/xerial/sbt-sonatype] -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.0") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5") // [https://github.com/sbt/sbt-pgp] -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") \ No newline at end of file +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1") \ No newline at end of file