如何在sbt中为我的项目设置系统属性? [英] How do I set a system property for my project in sbt?

查看:109
本文介绍了如何在sbt中为我的项目设置系统属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定我确实缺少一些简单的东西...我想为我的sbt项目将系统属性java.awt.headless设置为true.阅读关于属性的页面,我认为我需要使用systemsystemOptional.在我的项目文件中,我尝试了以下操作:

I'm sure I'm missing something really simple... I want to set the system property java.awt.headless to true for my sbt project. Reading the page on properties I think that I need to use system or systemOptional. In my project file I've tried things like:

lazy val javaAwtHeadless = system[Boolean]("java.awt.headless")

将其设置为用户属性(例如lazy val javaAwtHeadless = property[Boolean])并在build.properties中设置伴随值,使该属性在sbt控制台中可见,但在sbt的Scala控制台中不可见(通过System.getProperty("java.awt.headless")).

Setting it as a user property (e.g. lazy val javaAwtHeadless = property[Boolean]) and setting the accompanying value in build.properties made the property visible in the sbt console but not within sbt's Scala console (via System.getProperty("java.awt.headless")).

set java.awt.headless true可以正常工作,包括在Scala控制台中进行设置,但这种情况不会持续到下次启动sbt时.

set java.awt.headless true from the sbt console works, including being set in the Scala console, but it doesn't persist to the next time I launch sbt.

推荐答案

一种简单的方法是编辑用于运行sbt的批处理文件或shell脚本并添加-Dprop=val

A straightforward method would be to edit the batch file or shell script that you use to run sbt and add -Dprop=val

这篇关于如何在sbt中为我的项目设置系统属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆