Read a property from gradle.properties with a bash script

#!/usr/bin/env bash

GRADLE_PROPERTIES_FILE=gradle.properties

function getProperty {
    PROP_KEY=$1
    PROP_VALUE=`cat $GRADLE_PROPERTIES_FILE | grep "$PROP_KEY" | cut -d'=' -f2`
    echo $PROP_VALUE
}
GRAILS_VERSION=$(getProperty "grailsVersion")
echo $GRAILS_VERSION

Tags: #gradle #bash
May 2017, 16.

 

My next events:
🗓 Jul 20 09:00 Workshop Security in the Micronaut Framework
🗓 Sep 20 09:00 JCON Online 2022 - Getting Started with the Micronaut Framework
🗓 Sep 23 09:00 JCON Online 2022 - Micronaut® Framework and Microstream Java-native persistence engine