首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Gradle插件混淆/与AutoValue和FreeBuilder的冲突

Gradle插件混淆/与AutoValue和FreeBuilder的冲突
EN

Stack Overflow用户
提问于 2018-01-04 16:09:13
回答 1查看 1K关注 0票数 1

我正在试验Gradle/IntelliJ和各种Java构建器/容器。但是,我无法在同一个项目中同时配置org.inferred.FreeBuilder和com.google.auto.value.AutoValue。

使用下面的build.gradle文件,我能够成功地编译一个用AutoValue命名的类(来自AutoValue 文档的动物示例)。

但是,一旦我取消注释"id 'org.inferred.processors“和"processor‘org.Inference.FreeBuilder:1.14.6’”,我就会得到

:processorPath \main\java\example\com\Animal.java:12: error:无法找到符号返回新的AutoValue_Animal (名称,numberOfLegs);^符号:类AutoValue_Animal位置: class AutoValue_Animal 1错误:编译AutoValue_Animal失败

代码语言:javascript
复制
plugins {
    id 'java'
    id 'idea'
    id 'net.ltgt.apt-idea'  version '0.13'
    // id 'org.inferred.processors' version '1.2.15'
}

version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    compile 'com.google.auto.value:auto-value:1.5.1'
    apt 'com.google.auto.value:auto-value:1.5.1'

    //processor 'org.inferred:freebuilder:1.14.6'
}

jar {
    from {
        (configurations.runtime).collect {
            it.isDirectory() ? it : zipTree(it)
        }
    }
    manifest {
        attributes 'Main-Class': 'example.com.Main'
    }
}

idea {
    project {
        // experimental: whether annotation processing will be configured in the IDE; only actually used with the 'idea' task.
        configureAnnotationProcessing = true
    }
    module {
        apt {
            // whether generated sources dirs are added as generated sources root
            addGeneratedSourcesDirs = true
            // whether the apt and testApt dependencies are added as module dependencies
            addAptDependencies = true

            // The following are mostly internal details; you shouldn't ever need to configure them.
            // whether the compileOnly and testCompileOnly dependencies are added as module dependencies
            addCompileOnlyDependencies = false // defaults to true in Gradle < 2.12
            // the dependency scope used for apt and/or compileOnly dependencies (when enabled above)
            mainDependenciesScope = "PROVIDED" // defaults to "COMPILE" in Gradle < 3.4, or when using the Gradle integration in IntelliJ IDEA
        }
    }
}

我正试图从这些消息来源中提取信息:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-01-05 00:26:08

您可以在项目中使用两个gradle依赖项,但不能同时使用它们的gradle插件。你也不需要。

您只需要一个gradle插件来支持注释处理器(它们中的任何一个),那么所有bean处理器依赖项都应该可以工作。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48099171

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档