我尝试自定义模板,但无法正确合并 gradle。
以下代码丢失,如何解决?提前致谢
apply plugin: 'com.neenbedankt.android-apt'
apt 'com.google.dagger:dagger-compiler:2.0.2'
provided 'javax.annotation:javax.annotation-api:1.2'
build.gradle.ftl
apply plugin: 'com.neenbedankt.android-apt'
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
dependencies {
compile 'com.google.dagger:dagger:2.0.2'
apt 'com.google.dagger:dagger-compiler:2.0.2'
provided 'javax.annotation:javax.annotation-api:1.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup:otto:1.3.8'
}
recipe.xml.ftl
<merge from="root/build.gradle.ftl"
to="${escapeXmlAttribute(projectOut)}/build.gradle" />
合并后的build.gradle
apply plugin: 'com.android.application' plugin: 'com.neenbedankt.android-apt'
...
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.google.dagger:dagger:2.0.2'
compile 'com.jakewharton:butterknife:7.0.1'
compile 'com.squareup:otto:1.3.8'
}
请您参考如下方法:
尝试直接在recipe.xml.ftl中添加依赖项:
<dependency mavenUrl="com.google.dagger:dagger-compiler:2.0.2" gradleConfiguration="apt"/>
<dependency mavenUrl="javax.annotation:javax.annotation-api:1.2" gradleConfiguration="provided" />