Skip to content

Latest commit

 

History

History
22 lines (16 loc) · 871 Bytes

README.md

File metadata and controls

22 lines (16 loc) · 871 Bytes

Checking properties

Checking if a property exist

Modify the propertyCheck task to print Yes, we have foo! when the project has a property called foo, and print Sorry, we're out of foo! when it doesnt.

  • Run ./gradlew propertyCheck
  • Assert the task prints Sorry, we're out of foo!
  • Run ./gradlew propertyCheck -Pfoo=bar
  • Assert the task prints Yes, we have foo!

Safely fetching property values

Modify the propertyCheck task to print the value of foo, or Still out of foo! if the property doesn't exist or is empty.

  • Run ./gradlew propertyCheck
  • Assert the task prints Still out of foo!
  • Run ./gradlew propertyCheck -Pfoo
  • Assert the task still prints Still out of foo!
  • Run ./gradlew propertyCheck -Pfoo=bar
  • Assert the task now prints bar
  • Q: Can you write a solution that doesn't rely on project.hasProperty()