2
我有一個pom.xml
,它具有一些配置文件,用於檢查正在運行的操作系統並根據操作系統更改變量。 SBT中有這種行爲的等價物嗎?SBT中Maven配置文件的等效
The pom.xml I'm looking at (it's the LWJGL one)
我有一個pom.xml
,它具有一些配置文件,用於檢查正在運行的操作系統並根據操作系統更改變量。 SBT中有這種行爲的等價物嗎?SBT中Maven配置文件的等效
The pom.xml I'm looking at (it's the LWJGL one)
一般你應該改變你的想法。在SBT中,所有庫都使用普通的scala。
<profiles>
<profile>
<id>lwjgl-natives-linux></id>
<activation>
<os><family>unix</family></os>
</activation>
<properties>
<lwjgl.natives>natives-linux</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-macos></id>
<activation>
<os><family>mac</family></os>
</activation>
<properties>
<lwjgl.natives>natives-macos</lwjgl.natives>
</properties>
</profile>
<profile>
<id>lwjgl-natives-windows></id>
<activation>
<os><family>windows</family></os>
</activation>
<properties>
<lwjgl.natives>natives-windows</lwjgl.natives>
</properties>
</profile>
</profiles>
根據你的例子,定義變量。 (見How do I programmatically determine operating system in Java?):
val lwjglNatives = sys.props("os.name").toLowerCase match {
case os if os.contains("uni") =>
"natives-linux"
case os if os.contains("mac") | os.contains("darwin") =>
"natives-macos"
case os if os.contains("win") =>
"natives-windows"
}
然後你可以使用lwjglNatives
取決於操作系統。