I do not know if this is suitable, you can create one common init gradle file that you run from the command line, so this is not a source code manipulation where you print all the necessary data. But the gradle conclusion is dirty.
This is the init.gradle snippet found in /Users/username
allprojects{ afterEvaluate({//listen for project evaluation println(project.name)//it is supposed to be 2 projects "ProjName" and "app" if(project.name.equalsIgnoreCase("app")){//or any other condtion to check if it is inner android project project.task("getVersion",{ println("versionCode = ${android.defaultConfig.versionCode}") }) } }); }
you run this script as ./gradlew --I /Users/username/init.gradle This is what I have as an output
music app versionCode = 1 :help Welcome to Gradle 2.4. To run a build, run gradlew <task> ... To see a list of available tasks, run gradlew tasks To see a list of command-line options, run gradlew
So, here's what you can do, another option available is to parse the build.gradle or manifest.xml file in bash or write your own console utility that will do this with a cleaner output. Hope I helped.
source share