Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

javaOptions in Universal doesn't have effect in custom plugin #1208

Closed
prophe05 opened this issue Feb 28, 2019 · 5 comments
Closed

javaOptions in Universal doesn't have effect in custom plugin #1208

prophe05 opened this issue Feb 28, 2019 · 5 comments

Comments

@prophe05
Copy link

prophe05 commented Feb 28, 2019

I try to create custom plugin, that use Universal plugin,
I want to set javaOptions in Universal like:

override def requires = UniversalPlugin

override def projectSettings: Seq[Setting[_]] = Seq(
  javaOptions in Universal := {
      val log = sLog.value
      log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
      Seq(
        "-Dconfig.file=./conf/production.conf"
      , "-Dlogback.configurationFile=./conf/logback.xml"
      )
    }
)

but there is no effect.

Expected behaviour

.ini file should be generated
log message should appear

Actual behaviour

no result

Information

  • sbt-native-packager, 1.3.18
  • sbt version - 1.2.6
  • MacOS
  • package is docker
@kardapoltsev
Copy link
Member

I think an output of sbt inspect universal:javaOptions could be helpful

@prophe05
Copy link
Author

sure

[info] Task: scala.collection.Seq[java.lang.String]
[info] Description:
[info] Options passed to a new JVM when forking.
[info] Provided by:
[info] ProjectRef(uri("file:/Users/au/workspace/ivy/account/"), "root") / Universal / javaOptions
[info] Defined at:
[info] (com.typesafe.sbt.packager.archetypes.JavaAppPackaging.projectSettings) JavaAppPackaging.scala:45
[info] Reverse dependencies:

[info] Universal / mappings
[info] Delegates:
[info] Universal / javaOptions
[info] javaOptions
[info] ThisBuild / Universal / javaOptions
[info] ThisBuild / javaOptions
[info] Zero / Universal / javaOptions
[info] Global / javaOptions
[info] Related:
[info] Global / javaOptions

@kardapoltsev
Copy link
Member

Could you show please how do you enable plugins in your project? What command did you run?

@prophe05
Copy link
Author

This is simplified version of my plugin

import sbt._
import Keys._
import com.typesafe.sbt.SbtNativePackager._
import com.typesafe.sbt.packager.universal.UniversalPlugin

/** sets the build environment */
object BuildEnvPlugin extends AutoPlugin {

  // make sure it triggers automatically
  override def trigger = AllRequirements
  override def requires = UniversalPlugin

  override def projectSettings: Seq[Setting[_]] = Seq(
    javaOptions in Universal := {
      val log = sLog.value
      log.warn("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
      Seq(
        "-Dconfig.file=./conf/application.conf"
      , "-Dlogback.configurationFile=./conf/logback.xml"
      )
    }
  }
}

This is a project where I use it:

enablePlugins(JavaAppPackaging, DockerPlugin, BuildEnvPlugin)

lazy val root = project
	.in(file("."))
	.settings(
		name := appName
	,	version := appVersion
	,	libraryDependencies ++= appDependencies
	,	fork in run := true
	)

@prophe05
Copy link
Author

override def requires = JavaAppPackaging && UniversalPlugin

solved the problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants