I've got a pom.xml
that has some profiles defined that check the operating system it's being run on and changes a variable based on the operating system. Is there an equivalent to this sort of behaviour in SBT?
Asked
Active
Viewed 802 times
2

TheReturningVoid
- 111
- 1
- 12
1 Answers
1
General you should change your mind. In SBT you use plain scala with all libraries.
<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>
According to your example, define the variable. (See 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"
}
Then you can use lwjglNatives
depending on OS.

bluenote10
- 23,414
- 14
- 122
- 178

Andrzej Jozwik
- 14,331
- 3
- 59
- 68