在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):meituan/RoboAspectJ开源软件地址(OpenSource Url):https://github.com/meituan/RoboAspectJ开源编程语言(OpenSource Language):Groovy 100.0%开源软件介绍(OpenSource Introduction):RoboAspectJRoboAspectJ is a Gradle plugin to introduce AspectJ (Aspect-Orient Programming) to Android project. It compiles aspects(if needed) and weave them all together in FULL-PROJECT scope. This means project (or subproject) sources, external libraries and local dependencies will all be dealt with by default.
latest version: v0.9.1 PrerequisiteAndroid Plugin (application) 2.1.0 ApplyAdd plugin dependency in buildscript classpath: buildscript {
dependencies {
classpath 'com.meituan.gradle:roboaspectj:0.9.+'
}
} Apply plugin: apply plugin: 'com.meituan.roboaspectj' CodingThere are basically 2 ways to write your aspects and weave them into production code: As Sourcewrite aspects in @AspectJ syntax under your project's java source directory. e.g. As Librarycompile and bundle your aspects independently using ajc, then make it dependency in build script. For example: compile 'com.example.myaspects:library:1.0'
Variant-Specific ConcernWhile RoboAspectJ is registered globally, we still can do our crosscutting concern under specific variant. Actually, this is already done by Android plugin. As Sourceput variant-specific aspects under corresponding folder. For example, I want to do some performance monitoring in As Libraryadd variant-specific aspects dependency to corresponding configuration scope. myflavorCompile 'com.example.myaspects:library:1.0' ConfigurationThere is an extension ExcludeIf you want to leave some artifact untouched from AspectJ, using: aspectj {
exclude group: 'com.google.android', module: 'support-v4'
} Java runtimeWhen applying aspectj {
javartNeeded true
} DisableFor debug or performance use, you can disable weaving: aspectj {
enable false //by default, it's true and you don't have to add this statement.
} alternatively, set
Maybe you want it to be smarter to disable it when it's a debug flavor, then add this to your build script: aspectj {
disableWhenDebug true // default is false
} or, specify
Though weaving is disabled, Aspects and AspectJ compile dependencies are all still there. It's only the weaving step doesn't happen.
LicenseCode is under the Apache Licence v2. FeedbackThis plugin is currently a prototype, and it still has much to improve. Feel free to contact: [email protected] |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论