如何使用gradle从GitHub克隆回购?

时间:2016-08-10 22:41:38

标签: gradle gradlew

我有一个依赖于其他回购的项目。我的目标是编写一个gradle任务,自动克隆所需的存储库。

我遇到的问题是,当我运行任务时,gradlew失败,因为它在运行我的任务之前尝试编译项目依赖项。这就是我所拥有的:

settings.gradle

include ':app'
include 'testRepo'
project(':testRepo').projectDir = new File('../testRepo')

的build.gradle

dependencies {
    classpath 'com.android.tools.build:gradle:2.1.2'
    classpath 'org.ajoberstar:gradle-git:1.5.1'
    classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
    classpath 'com.google.gms:google-services:3.0.0'

    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}

的build.gradle(APP)

task clone << {
    Grgit.clone(dir: file('../testRepo'), uri: "https://github.com/fakeAccount/testRepo.git")
}
dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    compile project(':testRepo')
    compile 'com.android.support:appcompat-v7:24.0.0'
    compile 'com.google.android.gms:play-services-maps:8.4.0'
    compile 'com.google.android.gms:play-services-location:8.4.0'
}

当我./gradlew clone时,我得到:

"Cannot evaluate module testRepo : Configuration with name 'default' not found"

这是因为它试图在从GitHub克隆之前编译testRepo项目。如果我拿出compile project(':testRepo')它就可以了。

关于如何使这项工作的任何想法?

0 个答案:

没有答案