-
Notifications
You must be signed in to change notification settings - Fork 24
How to use Groovy
Okay, so you've seen this project and wondered WTF is Groovy. You've made some research, and seen how awesome it is.
So, do you want to use it on your Android application development? Here's how.
First of all, Android Studio has native Groovy support, so here you don't really have to add anything.
###IMPORTANT
Every Groovy class or Java class which references a Groovy one must be inside of src/main/groovy
instead of src/main/java
.
To add a Groovy class you'll only need to create your new Class files as a .groovy file, instead of a Java class (you could define your own template).
In order to make Android Studio compile your Android Groovy code, you will need a plugin which is under development. You will have to make a few changes at your module's build.gradle:
build.gradle
buildscript {
repositories {
mavenLocal()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.2.3'
classpath 'org.codehaus.groovy:gradle-groovy-android-plugin:0.3.6'
}
}
apply plugin: 'com.android.application'
apply plugin: 'groovyx.grooid.groovy-android'
android {
...
packagingOptions {
// workaround for http://stackoverflow.com/questions/20673625/android-gradle-plugin-0-7-0-duplicate-files-during-packaging-of-apk
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/groovy-release-info.properties'
}
}
dependencies{
compile 'org.codehaus.groovy:groovy:2.4.3:grooid'
}
After this little edits, you're ready to start using Groovy in your Android development.