2017-03-07 150 views
1

一切工作完全正常,直到我尝试使用apt或其他插件与我的注释处理器,我正在编写的gradle。我已经能够手动构建和运行所有的东西(有/无Gradle),但是一旦我引入插件就会出现问题。这里是我的脚本:为什么我的gradle构建失败? (找不到方法apt())

这里是我的buildscript:

buildscript { 

    evaluationDependsOn('compiler') 
    evaluationDependsOn('core') 

    repositories { 
     maven { url "https://plugins.gradle.org/m2/" } 
     flatDir { dirs './make' } 
    } 

    dependencies { 
     classpath "net.ltgt.gradle:gradle-apt-plugin:0.9" 
     classpath ':core:0.1' 
     apt ':compiler:0.1' 
    } 
} 

plugins { 
    id 'java' 
    id 'idea' 
    id "net.ltgt.apt" version "0.9" 
} 

group 'bundle' 
version '0.1-SNAPSHOT' 

我使用的gradle-apt-plugin。我也尝试过使用Palantir's annotation processing plugin,并且引发了确切的错误,导致我相信插件和我的配置和/或版本没有任何问题。

当地gradle这个版本:2.1 和 摇篮包装:3.4.1

注释处理的IntelliJ中启用。我还检查了我为远程插件存储库使用了正确的URL。我试着回滚gradlew版本。

Intellij警告我“发现未索引的远程maven仓库”,但根据想法论坛it's a bug but won't affect a build.除此之外,我不知道是什么让这失败。

下面是输出:

FAILURE: Build failed with an exception. 

* Where: 
Build file '/home/$USER/IdeaProjects/$PROJECT/build.gradle' line: 14 

* What went wrong: 
A problem occurred evaluating root project 'Dynamic-MVP'. 
> Could not find method apt() for arguments [:compiler:0.1] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler. 

回答

3

您正在试图将其添加到buildscript依赖关系,这是不正确的。 Buildscript的依赖关系只能是classpath。你最好把它作为添加到您的项目依赖:

dependencies { 
    apt ':compiler:0.1' 
} 

走出buildscript关闭。

+0

谢谢!我阅读了所有的Gradle用户指南,但我认为buildscript和项目之间的区别并不十分清楚。 –

相关问题