本文介绍了Dagger 2.0 - AppEngine - gradle配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在AppEngine项目( NOT Android之一)中从Dagger 1.2.2移到Dagger 2.0.1。

I am trying to move from Dagger 1.2.2 to Dagger 2.0.1 in AppEngine project (NOT Android one).

Dagger 1.2.2简单:

With Dagger 1.2.2 simple:

compile 'com.squareup.dagger:dagger-compiler:1.2.2'
compile 'com.squareup.dagger:dagger:1.2.2'

完成了这个诀窍。

使用Dagger 2.0.1:

With Dagger 2.0.1:

compile 'com.google.dagger:dagger-compiler:2.0.1'
compile 'com.google.dagger:dagger:2.0.1'

不起作用(源代码生成,但与build / classes / main / .. package ../中的* .class文件混淆)。

does not work (source is generated but mixed up with *.class files in build/classes/main/..package../).

推荐答案

我找到了解决方案。

buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
    }
  }
  dependencies {
    classpath "net.ltgt.gradle:gradle-apt-plugin:0.3"
  }
}

apply plugin: "net.ltgt.apt"

dependecies {
  apt 'com.google.dagger:dagger-compiler:2.0.1'
  compile 'com.google.dagger:dagger:2.0.1'
}

另外,如果您使用Intellij,推荐:

Additionally if you are using Intellij a following configuration is recommended:

我也必须删除排除从整个构建目录和标记生成/源/ apt /主目录作为源。

I've also had to remove Exclude from whole build directory and mark generated/source/apt/main directory as source.

这篇关于Dagger 2.0 - AppEngine - gradle配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 23:08