2016-05-30 151 views
0

打包时使用SBT-本机打包插件SBT一个命令行应用程序,你有看起来像这种额外的命令行选项的包装脚本。命令行选项

-h | -help   print this message 
    -v | -verbose  this runner is chattier 
    -d | -debug  set sbt log level to debug 
    -no-version-check Don't run the java version check. 
    -mem <integer>  set memory options in MB (default: , which is -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:ReservedCodeCacheSize=128m) 
    -jvm-debug <port> Turn on JVM debugging, open at the given port. 

    # java version (default: java from PATH, currently java version "1.7.0_21") 
    -java-home <path>   alternate JAVA_HOME 

    # jvm options and output control 
    JAVA_OPTS   environment variable, if unset uses "" 
    -Dkey=val   pass -Dkey=val directly to the java runtime 
    -J-X    pass option -X directly to the java runtime 
        (-J is stripped) 

    # special option 
    --     To stop parsing built-in commands from the rest of the command-line. 
        e.g.) enabling debug and sending -d as app argument 
        $ ./start-script -d -- -d 

是否有可能有选择地禁用某些选项或将它们从打包的应用程序中全部删除?

+1

通过所有内容也许您正在寻找一种方法来自定义脚本模板:http://www.scala-sbt.org/sbt-native-packager/archetypes/java_app/customize。 html#start-script-customizations – Shyam

+0

谢谢@shyam我会看看这个选项。 –

回答

0

首先,有没有办法禁用单一的命令行选项。但是,你可以做一些其他的事情。

  1. 正如希亚姆正确提到的,你可以override the start script
  2. 第二个选项是使用-分离。之前的所有内容都将由脚本解析,后面的所有内容都作为应用程序命令行追加。

如果您有一个可能对全面可用性感兴趣的用例,可以打开一个功能请求。

欢呼声, 缪奇

+0

谢谢@muki我会尝试第一个选项。我知道第二个,但对于可分配的应用程序来说是非常不自然的,因为用户不必知道两个步骤命令行解析的存在 –

0

对于bash脚本,你可以添加到您的SBT配置:

bashScriptExtraDefines += """set -- -- "[email protected]""""

这有效地预先考虑一个--在命令行参数的传递,这将被包装物消耗掉。包装然后通过此前pregle --