父级模块中的Android Gradle annotationProcessor不可用 [英] Android Gradle annotationProcessor not available in parent module

查看:2145
本文介绍了父级模块中的Android Gradle annotationProcessor不可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下设置:

ProjectA build.gralde:

  dependencies {
compile(project(':ProjectB'))
}

ProjectB build.gradle:

 依赖关系{
annotationProcessor'com.ryanharter.auto.value: auto-value-parcel:0.2.5'
compilecom.google.auto.value:auto-value:1.3
annotationProcessorcom.google.auto.value:auto-value:1.3

SomeClass in正在实现Parcelable的ProjectA

  @AutoValue 
公共抽象类SomeClass实现Parcelable {
... $ AutoValue不会在AutoValue_SomeClass中生成任何与Parcelable相关的方法。
$ b



然而,如果我将自动值包裹批注处理程序直接包含到ProjectA中,则问题已解决。



ProjectA build.gralde:

 依赖项{
compile(project(':projectB'))
annotationProcessor'com.ryanharter.auto.value:auto-value-parcel: 0.2.5'
}

任何人都可以解释 value-parcel annotationProcessor正在从ProjectA中排除?

解决方案

依赖关系不会导出到其他项目。此外,这些不会与库导出。



AutoValue本身有效,因为您使用 compile 依赖项定义它。这是你不应该做的。因此,更好的依赖设置将看起来像... ...

ProjectB



<$ p $
提供了com.jakewharton.auto.value:auto-value-annotations:$ autoValueVersion
annotationProcessorcom.google.auto.value:auto-value :$ autoValueVersion
annotationProcessorcom.ryanharter.auto.value:auto-value-parcel:$ autoValueParcelVersion
}

ProjectA

 依赖关系{
编译项目(':ProjectB')
提供了com.jakewharton.auto.value:auto-value-annotations:$ autoValueVersion
annotationProcessorcom.google.auto.value:auto-value:$ autoValueVersion
annotationProcessorcom.ryanharter.auto.value:auto-value-parcel:$ autoValueParcelVersion

但是没有 annotationProcessor 在所有项目上运行会更好。


I'm having the following setup:

ProjectA build.gralde:

dependencies {
    compile (project(':ProjectB'))
}

ProjectB build.gradle:

dependencies {
    annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
    compile "com.google.auto.value:auto-value:1.3"
    annotationProcessor "com.google.auto.value:auto-value:1.3"
}

And SomeClass in ProjectA that is implementing Parcelable

@AutoValue
public abstract class SomeClass implements Parcelable {
...
}

AutoValue won't generate any Parcelable related methods in AutoValue_SomeClass.

However, if I include auto-value-parcel annotationProcessor directly to ProjectA, the problem is resolved.

ProjectA build.gralde:

dependencies {
    compile (project(':projectB'))
    annotationProcessor 'com.ryanharter.auto.value:auto-value-parcel:0.2.5'
}

Can anyone explain how auto-value-parcel annotationProcessor is being excluded from ProjectA?

解决方案

annotationProcessor dependencies are not exported to other projects. Also these are not exported with libraries.

AutoValue itself works, because you defined it with a compile dependency. This is something you should not do either. So an better dependency setup would look like...

ProjectB

dependencies {
    provided "com.jakewharton.auto.value:auto-value-annotations:$autoValueVersion"
    annotationProcessor "com.google.auto.value:auto-value:$autoValueVersion"
    annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:$autoValueParcelVersion"
}

ProjectA

dependencies {
    compile project(':ProjectB')
    provided "com.jakewharton.auto.value:auto-value-annotations:$autoValueVersion"
    annotationProcessor "com.google.auto.value:auto-value:$autoValueVersion"
    annotationProcessor "com.ryanharter.auto.value:auto-value-parcel:$autoValueParcelVersion"
}

But not having annotationProcessor run on all projects would be even better.

这篇关于父级模块中的Android Gradle annotationProcessor不可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆