Fix GC logging configuration when running with Java 11

Also take the CI environment variable into consideration
This commit is contained in:
Marcos Pereira 2021-08-19 20:03:53 -04:00
parent 7cdca36ab8
commit b71efdea51
No known key found for this signature in database
GPG key ID: F7EBB0FF122A3D87

View file

@ -4,12 +4,8 @@
package akka
import java.io.FileReader
import java.io.{ FileInputStream, InputStreamReader }
import java.util.Properties
import java.time.format.DateTimeFormatter
import java.time.ZonedDateTime
import java.time.ZoneOffset
import com.lightbend.paradox.projectinfo.ParadoxProjectInfoPluginKeys._
import com.typesafe.sbt.MultiJvmPlugin.autoImport.MultiJvm
import sbtassembly.AssemblyPlugin.autoImport._
@ -21,6 +17,13 @@ import scala.collection.breakOut
object AkkaBuild {
object CliOptions {
// CI is the env var defined by Github Actions and Travis:
// - https://docs.github.com/en/actions/reference/environment-variables#default-environment-variables
// - https://docs.travis-ci.com/user/environment-variables/#default-environment-variables
val runningOnCi: CliOption[Boolean] = CliOption("akka.ci-server", sys.env.contains("CI"))
}
val enableMiMa = true
val parallelExecutionByDefault = false // TODO: enable this once we're sure it does not break things
@ -108,6 +111,15 @@ object AkkaBuild {
}
}
private def jvmGCLogOptions(isJdk11OrHigher: Boolean, isJdk8: Boolean): Seq[String] = {
if (isJdk11OrHigher)
// -Xlog:gc* is equivalent to -XX:+PrintGCDetails. See:
// https://docs.oracle.com/en/java/javase/11/tools/java.html#GUID-BE93ABDC-999C-4CB5-A88B-1994AAAC74D5
Seq("-Xlog:gc*")
else if (isJdk8) Seq("-XX:+PrintGCTimeStamps", "-XX:+PrintGCDetails")
else Nil
}
// -XDignore.symbol.file suppresses sun.misc.Unsafe warnings
final val DefaultJavacOptions = Seq("-encoding", "UTF-8", "-Xlint:unchecked", "-XDignore.symbol.file")
@ -191,10 +203,9 @@ object AkkaBuild {
// faster random source
"-Djava.security.egd=file:/dev/./urandom")
if (sys.props.contains("akka.ci-server"))
defaults ++ Seq("-XX:+PrintGCTimeStamps", "-XX:+PrintGCDetails")
else
defaults
defaults ++ CliOptions.runningOnCi
.ifTrue(jvmGCLogOptions(JdkOptions.isJdk11orHigher, JdkOptions.isJdk8))
.getOrElse(Nil)
},
// all system properties passed to sbt prefixed with "akka." will be passed on to the forked jvms as is
Test / javaOptions := {