在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):groovy/groovy-android-gradle-plugin开源软件地址(OpenSource Url):https://github.com/groovy/groovy-android-gradle-plugin开源编程语言(OpenSource Language):Groovy 100.0%开源软件介绍(OpenSource Introduction):Groovy language support for AndroidDeprecated: This plugin has been deprecated in favor of Kotlin which has the full support of JetBrains and Google. The changes that go into each Android Plugin Version make it really hard for this plugin to keep up. As of Gradle 6.0 this plugin does not work. This plugin adds Groovy Language support for Android applications and libraries. UpdatesAs of 2.0.0 of this plugin only will work with the Android Gradle Plugin 3.0.0 and above. For support of lower version use 1.2.0. There is an issues when using build tool 26+ and the Groovy jar. The current work around is to use proguard or to use JarJar to create a jar file that does not have invoke dynamic classes. See ZarZaring the Groovy Jar for Android 26+ to create your own jar and avoid having to run proguard. See Github Issue for more details. Quick StartUse a lazybones template from grooid-template UsageEdit your buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:2.0.1'
}
}
apply plugin: 'com.android.application'
apply plugin: 'groovyx.android' The latest version of the Groovy Android Plugin can be found here You must choose which version of Groovy you use. Android support is available in
starting at the 2.4.x releases. You will need to add the following repository to your repositories {
jcenter()
} Then you can start using Groovy by adding the groovy dependency with the dependencies {
compile 'org.codehaus.groovy:groovy:2.4.12:grooid'
} Full list of releases can be found here here.
Then use the Should you want to test development versions of the plugin, you can add the snapshot repository and depend on a SNAPSHOT: buildscript {
repositories {
jcenter()
maven { url 'http://oss.jfrog.org/artifactory/oss-snapshot-local' }
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'org.codehaus.groovy:groovy-android-gradle-plugin:2.0.2-SNAPSHOT'
}
} Go here to see what the latest SNAPSHOT version is. Where to put sources?Groovy sources may be placed in Extra groovy sources may be added in a similar fashion as the android plugin
using the androidGroovy {
sourceSets {
main {
groovy {
srcDirs += 'src/main/java'
}
}
}
} would add all of the Java files in Writing Groovy CodeThis plugin has been successfully tested with Android Studio and will make no attempts to add support for other IDEs.
This plugin will let you write an application in Groovy but it is recommended, for performance, memory and battery life,
that you use Details can be found on Melix’s blog and here for more technical details Including Groovy LibrariesIn order to include libraries written in groovy that include the groovy or groovy-all jars, you will need to exclude the groovy dependency allowing the grooid jar to be the one to be compiled against. For example to use the groovy-xml library you would simply need to do exclude
the group compile ('org.codehaus.groovy:groovy-xml:2.4.3') {
exclude group: 'org.codehaus.groovy'
} Skipping Groovy CompileAs of version 1.2.0 only build types/build flavors with groovy sources included in them will have the groovy compile task added. If you would like to skip the groovy compilation tasks on older versions or on newer version wish to skip them in build types that have groovy sources you can use the following to disable the groovy compiler task.
Configuring the Groovy compilation optionsThe Groovy compilation tasks can be configured in the androidGroovy {
options {
configure(groovyOptions) {
encoding = 'UTF-8'
forkOptions.jvmArgs = ['-noverify'] // maybe necessary if you use Google Play Services
}
}
} See GroovyCompile for more options. See Example Application for an example of using these settings to enable custom compilation options. Only Use GroovyCFor integration with plain java projects or for working with generated files
(such as BuildConfig) it may be desirable to only have GroovyC run in order to
have Java files reference Groovy files. This is roughly the equivalent of placing
all java source files into the groovy source directory (including auto
generated files like BuildConfig). In order to only have GroovyC run simply set
the flag androidGroovy {
skipJavaC = true
} Annotation ProcessingAs of 1.2.0 Release annotation processing is configured by default. Previous versions would require androidGroovy {
options {
configure(groovyOptions) {
javaAnnotationProcessing = true
}
}
}
Android |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论