From 15d685c41ccac09cb562692120b146745227ba67 Mon Sep 17 00:00:00 2001 From: Derek Wickern Date: Wed, 25 Oct 2017 14:20:52 -0700 Subject: [PATCH] fix duplicate application.ini mappings when both BASH and BAT are used --- .../scripts/ApplicationIniGenerator.scala | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/ApplicationIniGenerator.scala b/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/ApplicationIniGenerator.scala index ef280344b..086cfebf3 100644 --- a/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/ApplicationIniGenerator.scala +++ b/src/main/scala/com/typesafe/sbt/packager/archetypes/scripts/ApplicationIniGenerator.scala @@ -21,17 +21,24 @@ trait ApplicationIniGenerator { val pathMapping = cleanApplicationIniPath(location) //Do not use writeLines here because of issue #637 IO.write(configFile, ("# options from build" +: javaOptions).mkString("\n")) - val hasConflict = universalMappings.exists { - case (file, path) => file != configFile && path == pathMapping - } - // Warn the user if he tries to specify options - if (hasConflict) { - log.warn("--------!!! JVM Options are defined twice !!!-----------") - log.warn( - "application.ini is already present in output package. Will be overridden by 'javaOptions in Universal'" - ) + val filteredMappings = universalMappings.filter { + case (`configFile`, `pathMapping`) => + // ignore duplicate application.ini mappings with identical contents + // for example when using both the BASH and BAT plugin + true + + case (_, `pathMapping`) => + // specified a custom application.ini file *and* JVM options + // TODO: merge JVM options into the existing application.ini? + log.warn("--------!!! JVM Options are defined twice !!!-----------") + log.warn( + "application.ini is already present in output package. Will be overridden by 'javaOptions in Universal'" + ) + true + + case _ => false } - (configFile -> pathMapping) +: universalMappings + (configFile -> pathMapping) +: filteredMappings } .getOrElse(universalMappings)