[2.1-RC2] sbt javaOptions not passed to forked process?

470 views
Skip to first unread message

Jeff Simpson

unread,
Jan 10, 2013, 2:48:07 PM1/10/13
to play-fr...@googlegroups.com
I just updated to 2.1-RC2 and notice we're now forking in tests (hurray).  I have some javaOptions set in my project that do not appear to be "sticking" in the forked process.  I have the following:


...javaOptions += """-Djava.security.manager -Djava.security.policy=security.policy -Dsun.net.inetaddr.ttl=5 -Dsun.net.inetaddr.negative.ttl=0 -Dfile.encoding=UTF-8'''",
...



Funny thing is in VisualVm I see the forked process and under "JVM arguments" I see:

-Djava.security.manager
-Djava.security.policy=security.policy
-Dsun.net.inetaddr.ttl=5
-Dsun.net.inetaddr.negative.ttl=0
-Dfile.encoding=UTF-8


The reason I suspect something is not "sticking" is I have some specs that fail when the java.security.policy is not present (in addition to other specs which fail due to the policy not being present):

    "contain security.policy param" in {
     
Option(sys.props("java.security.manager")).isDefined
     
Option(sys.props("java.security.policy")).isDefined
   
}


Anyone else seeing similar javaOption issues? 

Thanks,
-Jeff

Jeff Simpson

unread,
Jan 10, 2013, 2:54:32 PM1/10/13
to play-fr...@googlegroups.com
Looks like I jacked up my paste for the javaOptions line.  The trailing quotes are supposed to be """.

Jeff Simpson

unread,
Jan 15, 2013, 10:51:16 AM1/15/13
to play-fr...@googlegroups.com
Bump.  Anybody else seeing this?  2.1-RC1 was fine.  

Jeff Simpson

unread,
Jan 15, 2013, 12:02:13 PM1/15/13
to play-fr...@googlegroups.com
I temporarily turned of forking in tests:

fork in Test := false

Nilanjan Raychaudhuri

unread,
Jan 15, 2013, 12:15:47 PM1/15/13
to play-fr...@googlegroups.com
Jeff,

Are you doing this http://www.scala-sbt.org/0.13.0-SNAPSHOT/docs/Detailed-Topics/Forking#forked-jvm-options

Nilanjan, Developer & Consultant
Typesafe Inc.
Twitter: @nraychaudhuri

Jeff Simpson

unread,
Jan 15, 2013, 12:23:56 PM1/15/13
to play-fr...@googlegroups.com
I was setting: 

javaOptions += <params>

I tried the other combinations like:

javaOptions in test += <params>

Using "in test" I can see in VisualVM no options are passed whereas when I use use no task configuration (first example) I at least see the options in the forked process in VisualVM.  

Neither combination seems to pass the system param down to the specs process (or something along those lines).

Nilanjan Raychaudhuri

unread,
Jan 15, 2013, 2:55:01 PM1/15/13
to play-fr...@googlegroups.com
This seems to work for me:
import sbt._
import Keys._

object ApplicationBuild extends Build {

  val appName         = "test_forking"
  val appVersion      = "1.0-SNAPSHOT"

  val appDependencies = Seq(
  )


  val main = play.Project(appName, appVersion, appDependencies).settings(
    // Add your own project settings here     
    javaOptions in Test += "-Djava.security.policy=security.policy"
  )

}

I am assuming that sbt.version is set to sbt.version=0.12.2-RC2


Nilanjan, Developer & Consultant
Typesafe Inc.
Twitter: @nraychaudhuri


Jeff Simpson

unread,
Jan 15, 2013, 2:59:42 PM1/15/13
to play-fr...@googlegroups.com
Yeah, my build.properties has sbt.version=0.12.2-RC2.  Something strange is going on here.  Maybe it's one of my dependencies?  I do have an sbt wrapper script and updated the sbt-launch.jar in my project to 0.12.2-RC2, but maybe there's something else going on there...

Thanks trying to reproduce!

Nilanjan Raychaudhuri

unread,
Jan 15, 2013, 3:03:35 PM1/15/13
to play-fr...@googlegroups.com
Sure. Do you have multiple test configuration? if so this might be of some interest

https://groups.google.com/forum/#!topic/simple-build-tool/GhilCm7_j74/discussion


Nilanjan, Developer & Consultant
Typesafe Inc.
Twitter: @nraychaudhuri

Jeff Simpson

unread,
Jan 15, 2013, 3:11:14 PM1/15/13
to play-fr...@googlegroups.com
Curious how you know the option is getting passed in your example?  Does the code print the value of the java.security.policy?

I ran sbt and did:

[rearview] $ show sbt-dependency
[info] org.scala-sbt:sbt:0.12.2-RC2




Jeff Simpson

unread,
Jan 15, 2013, 5:00:28 PM1/15/13
to play-fr...@googlegroups.com
I added the following spec to a new project I created from the Play-2.1-RC2 bundle and it works fine, so I guess it's got to be something specific to my application.

package test

import org.specs2.mutable._
import org.junit.runner.RunWith
import org.specs2.runner.JUnitRunner

@RunWith(classOf[JUnitRunner])
class ForkOptionsSpec extends Specification {
 
"Forked Specs should" should {
   
"see system params" in {
     
Option(sys.props("foo")).isDefined
   
}
 
}
}


Jeff Simpson

unread,
Jan 15, 2013, 8:18:56 PM1/15/13
to play-fr...@googlegroups.com
Figured it out.  I didn't realize javaOptions is a List[String]!  I was passing multiple params like:

// BAD, WRONG!
javaOptions
+= """-Dfoo -Dbar"""


but it should be:

javaOptions ++= List("-Dfoo", "-Dbar")


:)

Jeff Simpson

unread,
Jan 15, 2013, 8:20:18 PM1/15/13
to play-fr...@googlegroups.com
Correction, javaOptions is a Seq[String]
Reply all
Reply to author
Forward
0 new messages