build.gradle - If else in Gradle scripts -
i have strange behavior in gradle , cannot find way out of it. in gradle.properties file, using checking condition:
//gradle.properties if ( "${system.property['database_dir']}".compareto('swdb') == 0 ) { project_database_path=../database/swdb/include } else { project_database_path=../database/include/ } i created new task called printproperties , looks this.
//build.gradle task printproperties { println "${system.properties['database_dir']}".compareto('swdb') == 0 println project_database_path } i following output when run printproperties task.
$gradle printproperties -ddatabase_dir=swdb
true
../database/include/
:printproperties up-to-date
build successful
total time: 1.07 secs
it strange task prints true gradle.properties file not evaluate same condition correctly. me this?
your code shall take place in init.gradle script.
you can find documentation here : https://docs.gradle.org/current/userguide/init_scripts.html
gradle.properties file key=value pairs
Comments
Post a Comment