Skip to main content
added 15 characters in body
Source Link
Miquel
  • 4.8k
  • 3
  • 22
  • 19

Very old question, but I could not find any good solution and this question pointed me to a acceptable solution with the following features in sbt:

  • You can use ? on a key to return an option
  • The effect shown in this question about unset properties in sub-projects can be set in parent
  • assigning a key based on another key value

Define the property in both, the child and the parent:

lazy val testProperty = settingKey[String]("Test Prop") 

In the child project you set the property value conditionally like:

testProperty := testProperty.?.value.getOrElse("~ child default! ~") 

In the parent project you set the property value normally:

childProject / testProperty := "# parent override! " 

Very old question, but I could not find any good solution and this question pointed me to a acceptable solution with the following features in sbt:

  • You can use ? on a key to return an option
  • The effect shown in this question about unset properties in sub-projects can be set in parent
  • assigning a key based on another key value

Define the property in both, the child and the parent:

lazy val testProperty = settingKey[String]("Test Prop") 

In the child project you set the property value conditionally like:

testProperty := testProperty.?.value.getOrElse("~ child default! ~") 

In the parent project you set the property value normally:

testProperty := "# parent override! " 

Very old question, but I could not find any good solution and this question pointed me to a acceptable solution with the following features in sbt:

  • You can use ? on a key to return an option
  • The effect shown in this question about unset properties in sub-projects can be set in parent
  • assigning a key based on another key value

Define the property in both, the child and the parent:

lazy val testProperty = settingKey[String]("Test Prop") 

In the child project you set the property value conditionally like:

testProperty := testProperty.?.value.getOrElse("~ child default! ~") 

In the parent project you set the property value normally:

childProject / testProperty := "# parent override! " 
Source Link
Miquel
  • 4.8k
  • 3
  • 22
  • 19

Very old question, but I could not find any good solution and this question pointed me to a acceptable solution with the following features in sbt:

  • You can use ? on a key to return an option
  • The effect shown in this question about unset properties in sub-projects can be set in parent
  • assigning a key based on another key value

Define the property in both, the child and the parent:

lazy val testProperty = settingKey[String]("Test Prop") 

In the child project you set the property value conditionally like:

testProperty := testProperty.?.value.getOrElse("~ child default! ~") 

In the parent project you set the property value normally:

testProperty := "# parent override! "