在Android工作室中合并自定义模板的gradle

时间:2016-06-13 07:43:24

标签: templates android-studio

我尝试自定义模板,但我无法正确合并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'
}

1 个答案:

答案 0 :(得分:0)

尝试直接在recipe.xml.ftl中添加依赖项:

git merge MyBranch
git push origin --delete MyBranch