摇篮+ RoboBinding使用AspectJ +龙目岛是不兼容在一起 [英] Gradle + RoboBinding with AspectJ + Lombok are not compatible together
问题描述
我想在摇篮Android项目整合下列库:
- 龙目岛
- RoboBinding使用AspectJ
- 匕首
为了使用RoboBinding AspectJ和安卓1.1.0工具我编译AspectJ的插件,这个<一个href=\"https://github.com/kennyjoseph/RoboBinding-aspectj-plugin/commit/0f395808c6697513df4df8651a5c04ef5268dd9d\"相对=nofollow>修复。
所有图书馆使用的是一些编译时批注处理。我发现,龙目不使用AspectJ兼容。我注意到,龙目岛,而只适用于从提供的注释RoboBinding处理器使用apt(匕首可以使用两种)。
我也发现龙目岛和AspectJ workaurond Maven的,但我不知道这是否可以用摇篮中使用过(如果是的,我不知道该怎么做)。
如果没有龙目岛项目编制和工作。你可以用摇篮整合龙目岛和AspectJ帮助?
错误:
注:启动RoboBinding批注处理...
注意:开始RoboBinding批注处理...
注意:开始RoboBinding批注处理...
注意:开始RoboBinding批注处理...
:应用:compileDebugAspectJ
警告您未使用受Lombok支持的编译器,因此龙目岛将无法工作,并已被禁用。
您的处理器是:org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
龙目岛支持:太阳/苹果javac的1.6,ECJ
在错误model.setOutput(model.getInput());D:\\项目\\ BinderExample \\程序\\ SRC \\主\\ java的\\富\\ binderexample \\ MainActivity.java:32:0 :: 0的方法getInput()是未定义的类型BinderModel
错误:注意:开始RoboBinding批注处理...
注意:开始RoboBinding批注处理...
注意:开始RoboBinding批注处理...
注意:开始RoboBinding批注处理...
在错误model.setOutput(model.getInput());D:\\项目\\ BinderExample \\程序\\ SRC \\主\\富\\ binderexample \\ MainActivity.java:32:0 :: 0的方法getInput()是未定义的类型BinderModel
故障:建立失败,一个例外。* 什么地方出了错:
执行失败的任务:应用程序:compileDebugAspectJ。
&GT;该方法getInput()是未定义的类型BinderModel
模块:
@Module(内喷射= MainActivity.class)
公共类BinderModule { @Provides
@辛格尔顿
BinderModel provideBinderModel(){
返回新BinderModel();
}
}
型号:
@Data
@ presentationModel
公共类BinderModel器物有$ P $ {psentationModelChangeSupport 私人最终presentationModelChangeSupport changeSupport =新的presentationModelChangeSupport(本); 私人字符串输入;
私人字符串输出; @覆盖
公共presentationModelChangeSupport获得presentationModelChangeSupport(){
返回changeSupport;
}
}
活动:
公共类MainActivity延伸活动{ @注入
BinderModel模型; @覆盖
保护无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
。ObjectGraph.create(新BinderModule())注入(本);
查看查看= Binders.inflateAndBind(这一点,R.layout.activity_main,模型);
的setContentView(视图);
ButterKnife.inject(本);
} @OnClick(R.id.button)
无效onButtonClick(){
model.setOutput(model.getInput());
}
}
布局:
&LT; LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
的xmlns:绑定=http://robobinding.org/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent
机器人:方向=垂直&GT; &LT;的EditText
机器人:ID =@ + ID / EDITTEXT
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =CENTER_HORIZONTAL
安卓的inputType =TEXT
绑定:文本=$ {}输入/&GT; &LT;按钮
机器人:ID =@ + ID /按钮
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =CENTER_HORIZONTAL
机器人:文字=@字符串/按钮/&GT; &LT;的TextView
机器人:ID =@ + ID / TextView的
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_gravity =CENTER_HORIZONTAL
机器人:textAppearance =机器人:ATTR / textAppearanceLarge
绑定:文本={}输出/&GT;&LT; / LinearLayout中&GT;
摇篮脚本:
buildscript {
库{
jcenter()
mavenLocal()
} 依赖{
类路径'com.neenbedankt.gradle.plugins:Android的贴切:1.4
类路径'org.robobinding:AspectJ的插件:0.8.3修复
}
}应用插件:'com.android.application
应用插件:'org.robobinding.android-的AspectJ
应用插件:'com.neenbedankt.android-容易安卓{
compileSdkVersion 21
buildToolsVersion21.1.2 defaultConfig {
的applicationIDfoo.binderexample
15的minSdkVersion
targetSdkVersion 21
版本code 1
的versionName1.0
} buildTypes {
发布 {
minifyEnabled假
proguardFiles getDefaultProguardFile('proguard的-android.txt'),'proguard-rules.pro
}
}
}依赖{
编译文件树(包括:['的* .jar'],DIR:库)
编译com.android.support:appcompat-v7:22.0.0 编译com.jakewharton:奶油刀:6.1.0 //匕首
编译com.squareup.dagger:短剑:1.2.2
易'com.squareup.dagger:匕首编译:1.2.2 //龙目岛
提供'org.projectlombok:龙目:1.16.2
易'org.projectlombok:龙目:1.16.2 // robobinding
编译('org.robobinding:robobinding:0.8.9:用的AOP和依存关系'){
排除组:com.google.guava',模块:番石榴
}
aspectPath('org.robobinding:robobinding:0.8.9:用的AOP和依存关系'){
排除组:com.google.guava',模块:番石榴
}
易'org.robobinding:codeGEN:0.8.9
}
如果您想了解更多关于龙目岛的结合情况和AspectJ,请阅读的我的其他答案,然后也跟着链接那里。
I want to integrate in Android project on Gradle following libraries:
- Lombok
- RoboBinding with AspectJ
- Dagger
In order to use RoboBinding with AspectJ and android tools 1.1.0 I compiled aspectj-plugin with this fix.
All libraries are using some compile time annotation processing. I found that Lombok isn't compatible with AspectJ. I noticed that annotation processor from RoboBinding is using apt whereas lombok works only with provided (Dagger works with both).
I found also Lombok and AspectJ workaurond for Maven but I don't know if this can be used with Gradle too (if yes I don't know how to do it).
Without Lombok project is compiling and working. Can you help with integrating Lombok and AspectJ with Gradle?
Error:
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
:app:compileDebugAspectJ
warning You aren't using a compiler supported by lombok, so lombok will not work and has been disabled.
Your processor is: org.aspectj.org.eclipse.jdt.internal.compiler.apt.dispatch.BatchProcessingEnvImpl
Lombok supports: sun/apple javac 1.6, ECJ
error at model.setOutput(model.getInput());
D:\Projects\BinderExample\app\src\main\java\foo\binderexample\MainActivity.java:32:0::0 The method getInput() is undefined for the type BinderModel
Error:Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
Note: Start RoboBinding annotations processing...
error at model.setOutput(model.getInput());
D:\Projects\BinderExample\app\src\main\foo\binderexample\MainActivity.java:32:0::0 The method getInput() is undefined for the type BinderModel
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugAspectJ'.
> The method getInput() is undefined for the type BinderModel
Module:
@Module(injects = MainActivity.class)
public class BinderModule {
@Provides
@Singleton
BinderModel provideBinderModel() {
return new BinderModel();
}
}
Model:
@Data
@PresentationModel
public class BinderModel implements HasPresentationModelChangeSupport {
private final PresentationModelChangeSupport changeSupport = new PresentationModelChangeSupport(this);
private String input;
private String output;
@Override
public PresentationModelChangeSupport getPresentationModelChangeSupport() {
return changeSupport;
}
}
Activity:
public class MainActivity extends Activity {
@Inject
BinderModel model;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ObjectGraph.create(new BinderModule()).inject(this);
View view = Binders.inflateAndBind(this, R.layout.activity_main, model);
setContentView(view);
ButterKnife.inject(this);
}
@OnClick(R.id.button)
void onButtonClick() {
model.setOutput(model.getInput());
}
}
Layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:bind="http://robobinding.org/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:inputType="text"
bind:text="${input}"/>
<Button
android:id="@+id/button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:text="@string/button"/>
<TextView
android:id="@+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge"
bind:text="{output}"/>
</LinearLayout>
Gradle script:
buildscript {
repositories {
jcenter()
mavenLocal()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
classpath 'org.robobinding:aspectj-plugin:0.8.3-fix'
}
}
apply plugin: 'com.android.application'
apply plugin: 'org.robobinding.android-aspectj'
apply plugin: 'com.neenbedankt.android-apt'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "foo.binderexample"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.jakewharton:butterknife:6.1.0'
//dagger
compile 'com.squareup.dagger:dagger:1.2.2'
apt 'com.squareup.dagger:dagger-compiler:1.2.2'
//lombok
provided 'org.projectlombok:lombok:1.16.2'
apt 'org.projectlombok:lombok:1.16.2'
//robobinding
compile('org.robobinding:robobinding:0.8.9:with-aop-and-dependencies') {
exclude group: 'com.google.guava', module: 'guava'
}
aspectPath('org.robobinding:robobinding:0.8.9:with-aop-and-dependencies') {
exclude group: 'com.google.guava', module: 'guava'
}
apt 'org.robobinding:codegen:0.8.9'
}
If you want to know more about the situation of Lombok in combination with AspectJ, please read my other answer and also follow the links there.
这篇关于摇篮+ RoboBinding使用AspectJ +龙目岛是不兼容在一起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!