Last active
January 14, 2016 20:12
-
-
Save vrunoa/1db6dfef2f4b87ae9e12 to your computer and use it in GitHub Desktop.
Create a task on gradle to get android project versionName from cli
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'com.android.library' | |
apply plugin: Version | |
android { | |
compileSdkVersion 23 | |
buildToolsVersion "23.0.2" | |
defaultConfig { | |
minSdkVersion 10 | |
targetSdkVersion 23 | |
versionCode 1 | |
versionName "1.0.2" | |
} | |
buildTypes { | |
release { | |
minifyEnabled false | |
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | |
} | |
} | |
} | |
dependencies { | |
compile fileTree(dir: 'libs', include: ['*.jar']) | |
testCompile 'junit:junit:4.12' | |
compile 'io.socket:socket.io-client:0.6.2' | |
} | |
// add the gradle task | |
class Version implements Plugin<Project>{ | |
public void apply(Project project) { | |
project.task("Version") { | |
project.gradle.projectsEvaluated { | |
println "$project.android.defaultConfig.versionName" | |
} | |
} | |
} | |
} | |
// run ./gradlew -q Version |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment