Travis-ci没有找到“测试”任务

时间:2016-09-23 14:23:42

标签: android gradle android-gradle travis-ci

我有一个Android库项目,其中包含一些单元测试。测试运行并传递给开发机器和现场持续集成机器。我现在想将项目的主机存储库连接到travis-ci(https://travis-ci.org/)并在那里运行测试。

我已经设置了我的travis帐户,因此travis可以访问存储库并在每次推送时运行构建,但是,构建失败,因为travis无法找到我想要运行的gradle任务。

这是我的.travis.yml文件:

language: android

before_install:
 - chmod +x gradlew

script: ./gradlew :myproject:test

android:
  components:
     # Uncomment the lines below if you want to
     # use the latest revision of Android SDK Tools
    - platform-tools
    - tools

    # The BuildTools version used by your project
    - build-tools-24.0.2

    # The SDK version used to compile your project
    - android-24

这是我的app / build.gradle文件:

apply plugin: 'com.android.library'

android {
    compileSdkVersion 24
    buildToolsVersion '24.0.2'

defaultConfig {
    minSdkVersion 14
    targetSdkVersion 24
    versionCode 1
    versionName version
    testInstrumentationRunner 'android.support.test.runner.AndroidJUnitRunner'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}

testOptions {
    unitTests.returnDefaultValues = true
}
}



dependencies {
        testCompile 'junit:junit:4.12'
        testCompile 'org.mockito:mockito-core:1.10.19'
        compile 'com.android.support:appcompat-v7:24.2.1'
        androidTestCompile 'com.android.support.test:runner:0.5'
        androidTestCompile 'com.android.support.test:rules:0.5'
    }

这是我的root build.gradle文件:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

这是travis的输出(剥离了不必要的细节):

    travis_time:end:05a1fcb0:start=1474639730310016962,finish=1474639745836305811,duration=15526288849
[0Ktravis_fold:end:android.install
[0K$ java -Xmx32m -version
java version "1.7.0_76"
Java(TM) SE Runtime Environment (build 1.7.0_76-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.76-b04, mixed mode)
$ javac -J-Xmx32m -version
javac 1.7.0_76
travis_fold:start:before_install
[0Ktravis_time:start:01dad8c0
[0K$ chmod +x gradlew

travis_time:end:01dad8c0:start=1474639746648936514,finish=1474639746653023046,duration=4086532
[0Ktravis_fold:end:before_install
[0Ktravis_time:start:07b2b2a4
[0K$ ./gradlew :myproject:test
Downloading https://services.gradle.org/distributions/gradle-2.14.1-all.zip
...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
Unzipping /home/travis/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1-all.zip to /home/travis/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv
Set executable permissions for: /home/travis/.gradle/wrapper/dists/gradle-2.14.1-all/8bnwg5hd3w55iofp58khbp6yv/gradle-2.14.1/bin/gradle
To honour the JVM settings for this build a new JVM will be forked. Please consider using the daemon: https://docs.gradle.org/2.14.1/userguide/gradle_daemon.html.
Download https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.0/gradle-core-2.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder/2.2.0/builder-2.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.2.0/lint-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/transform-api/2.0.0-deprecated-use-gradle-api/transform-api-2.0.0-deprecated-use-gradle-api.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle-api/2.2.0/gradle-api-2.2.0.pom
Download https://jcenter.bintray.com/com/android/databinding/compilerCommon/2.2.0/compilerCommon-2.2.0.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm/5.0.4/asm-5.0.4.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/5.0.4/asm-parent-5.0.4.pom
Download https://jcenter.bintray.com/org/ow2/ow2/1.3/ow2-1.3.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-commons/5.0.4/asm-commons-5.0.4.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.2.1/proguard-gradle-5.2.1.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-parent/5.2.1/proguard-parent-5.2.1.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.core/0.7.5.201505241946/org.jacoco.core-0.7.5.201505241946.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.build/0.7.5.201505241946/org.jacoco.build-0.7.5.201505241946.pom
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.5.201505241946/org.jacoco.report-0.7.5.201505241946.pom
Download https://jcenter.bintray.com/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.pom
Download https://jcenter.bintray.com/org/sonatype/oss/oss-parent/7/oss-parent-7.pom
Download https://jcenter.bintray.com/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.pom
Download https://jcenter.bintray.com/com/google/google/1/google-1.pom
Download https://jcenter.bintray.com/org/antlr/antlr/3.5.2/antlr-3.5.2.pom
Download https://jcenter.bintray.com/org/antlr/antlr-master/3.5.2/antlr-master-3.5.2.pom
Download https://jcenter.bintray.com/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder-model/2.2.0/builder-model-2.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/builder-test-api/2.2.0/builder-test-api-2.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/sdklib/25.2.0/sdklib-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/sdk-common/25.2.0/sdk-common-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/common/25.2.0/common-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/manifest-merger/25.2.0/manifest-merger-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/25.2.0/ddmlib-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/jack/jack-api/0.11.0/jack-api-0.11.0.pom
Download https://jcenter.bintray.com/com/android/tools/jill/jill-api/0.10.0/jill-api-0.10.0.pom
Download https://jcenter.bintray.com/com/android/tools/analytics-library/protos/25.2.0/protos-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/analytics-library/shared/25.2.0/shared-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/analytics-library/tracker/25.2.0/tracker-25.2.0.pom
Download https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.pom
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint-checks/25.2.0/lint-checks-25.2.0.pom
Download https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.5.1/ecj-4.5.1.pom
Download https://jcenter.bintray.com/com/google/guava/guava/17.0/guava-17.0.pom
Download https://jcenter.bintray.com/com/google/guava/guava-parent/17.0/guava-parent-17.0.pom
Download https://jcenter.bintray.com/com/android/databinding/baseLibrary/2.2.0/baseLibrary-2.2.0.pom
Download https://jcenter.bintray.com/org/antlr/antlr4/4.5.3/antlr4-4.5.3.pom
Download https://jcenter.bintray.com/org/antlr/antlr4-master/4.5.3/antlr4-master-4.5.3.pom
Download https://jcenter.bintray.com/commons-io/commons-io/2.4/commons-io-2.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/25/commons-parent-25.pom
Download https://jcenter.bintray.com/org/apache/apache/9/apache-9.pom
Download https://jcenter.bintray.com/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3.pom
Download https://jcenter.bintray.com/com/android/tools/annotations/24.5.0/annotations-24.5.0.pom
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.2.1/proguard-base-5.2.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-parent/5.0.1/asm-parent-5.0.1.pom
Download https://jcenter.bintray.com/org/antlr/antlr-runtime/3.5.2/antlr-runtime-3.5.2.pom
Download https://jcenter.bintray.com/org/antlr/ST4/4.0.8/ST4-4.0.8.pom
Download https://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/25.2.0/layoutlib-api-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/dvlib/25.2.0/dvlib-25.2.0.pom
Download https://jcenter.bintray.com/com/android/tools/repository/25.2.0/repository-25.2.0.pom
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/33/commons-parent-33.pom
Download https://jcenter.bintray.com/org/apache/apache/13/apache-13.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.1.1/httpcomponents-client-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/project/4.1.1/project-4.1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-client/4.1/httpcomponents-client-4.1.pom
Download https://jcenter.bintray.com/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.pom
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/25.2.0/lint-api-25.2.0.pom
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.4/asm-analysis-5.0.4.pom
Download https://jcenter.bintray.com/com/intellij/annotations/12.0/annotations-12.0.pom
Download https://jcenter.bintray.com/com/google/jimfs/jimfs/1.1/jimfs-1.1.pom
Download https://jcenter.bintray.com/com/google/jimfs/jimfs-parent/1.1/jimfs-parent-1.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.pom
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcomponents-core/4.1/httpcomponents-core-4.1.pom
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/5/commons-parent-5.pom
Download https://jcenter.bintray.com/org/apache/apache/4/apache-4.pom
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.pom
Download https://jcenter.bintray.com/org/apache/commons/commons-parent/11/commons-parent-11.pom
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.pom
Download https://jcenter.bintray.com/com/android/tools/external/com-intellij/uast/145.597.3/uast-145.597.3.pom
Download https://jcenter.bintray.com/com/android/tools/annotations/25.2.0/annotations-25.2.0.pom
Download https://jcenter.bintray.com/com/google/guava/guava/18.0/guava-18.0.pom
Download https://jcenter.bintray.com/com/google/guava/guava-parent/18.0/guava-parent-18.0.pom
Download https://jcenter.bintray.com/com/android/tools/build/gradle/2.2.0/gradle-2.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/gradle-core/2.2.0/gradle-core-2.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder/2.2.0/builder-2.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.2.0/lint-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/transform-api/2.0.0-deprecated-use-gradle-api/transform-api-2.0.0-deprecated-use-gradle-api.jar
Download https://jcenter.bintray.com/com/android/tools/build/gradle-api/2.2.0/gradle-api-2.2.0.jar
Download https://jcenter.bintray.com/com/android/databinding/compilerCommon/2.2.0/compilerCommon-2.2.0.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm/5.0.4/asm-5.0.4.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-commons/5.0.4/asm-commons-5.0.4.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-gradle/5.2.1/proguard-gradle-5.2.1.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.core/0.7.5.201505241946/org.jacoco.core-0.7.5.201505241946.jar
Download https://jcenter.bintray.com/org/jacoco/org.jacoco.report/0.7.5.201505241946/org.jacoco.report-0.7.5.201505241946.jar
Download https://jcenter.bintray.com/net/sf/jopt-simple/jopt-simple/4.9/jopt-simple-4.9.jar
Download https://jcenter.bintray.com/com/google/protobuf/protobuf-java/2.5.0/protobuf-java-2.5.0.jar
Download https://jcenter.bintray.com/org/antlr/antlr/3.5.2/antlr-3.5.2.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder-model/2.2.0/builder-model-2.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/builder-test-api/2.2.0/builder-test-api-2.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/sdklib/25.2.0/sdklib-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/sdk-common/25.2.0/sdk-common-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/common/25.2.0/common-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/build/manifest-merger/25.2.0/manifest-merger-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/ddms/ddmlib/25.2.0/ddmlib-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/jack/jack-api/0.11.0/jack-api-0.11.0.jar
Download https://jcenter.bintray.com/com/android/tools/jill/jill-api/0.10.0/jill-api-0.10.0.jar
Download https://jcenter.bintray.com/com/android/tools/analytics-library/protos/25.2.0/protos-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/analytics-library/shared/25.2.0/shared-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/analytics-library/tracker/25.2.0/tracker-25.2.0.jar
Download https://jcenter.bintray.com/com/squareup/javawriter/2.5.0/javawriter-2.5.0.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcpkix-jdk15on/1.48/bcpkix-jdk15on-1.48.jar
Download https://jcenter.bintray.com/org/bouncycastle/bcprov-jdk15on/1.48/bcprov-jdk15on-1.48.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-tree/5.0.4/asm-tree-5.0.4.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-checks/25.2.0/lint-checks-25.2.0.jar
Download https://jcenter.bintray.com/org/eclipse/jdt/core/compiler/ecj/4.5.1/ecj-4.5.1.jar
Download https://jcenter.bintray.com/com/android/databinding/baseLibrary/2.2.0/baseLibrary-2.2.0.jar
Download https://jcenter.bintray.com/org/antlr/antlr4/4.5.3/antlr4-4.5.3.jar
Download https://jcenter.bintray.com/commons-io/commons-io/2.4/commons-io-2.4.jar
Download https://jcenter.bintray.com/com/googlecode/juniversalchardet/juniversalchardet/1.0.3/juniversalchardet-1.0.3.jar
Download https://jcenter.bintray.com/net/sf/proguard/proguard-base/5.2.1/proguard-base-5.2.1.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-debug-all/5.0.1/asm-debug-all-5.0.1.jar
Download https://jcenter.bintray.com/org/antlr/antlr-runtime/3.5.2/antlr-runtime-3.5.2.jar
Download https://jcenter.bintray.com/org/antlr/ST4/4.0.8/ST4-4.0.8.jar
Download https://jcenter.bintray.com/com/android/tools/layoutlib/layoutlib-api/25.2.0/layoutlib-api-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/dvlib/25.2.0/dvlib-25.2.0.jar
Download https://jcenter.bintray.com/com/android/tools/repository/25.2.0/repository-25.2.0.jar
Download https://jcenter.bintray.com/com/google/code/gson/gson/2.2.4/gson-2.2.4.jar
Download https://jcenter.bintray.com/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpclient/4.1.1/httpclient-4.1.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpmime/4.1/httpmime-4.1.jar
Download https://jcenter.bintray.com/net/sf/kxml/kxml2/2.3.0/kxml2-2.3.0.jar
Download https://jcenter.bintray.com/com/android/tools/lint/lint-api/25.2.0/lint-api-25.2.0.jar
Download https://jcenter.bintray.com/org/ow2/asm/asm-analysis/5.0.4/asm-analysis-5.0.4.jar
Download https://jcenter.bintray.com/com/intellij/annotations/12.0/annotations-12.0.jar
Download https://jcenter.bintray.com/com/google/jimfs/jimfs/1.1/jimfs-1.1.jar
Download https://jcenter.bintray.com/org/apache/httpcomponents/httpcore/4.1/httpcore-4.1.jar
Download https://jcenter.bintray.com/commons-logging/commons-logging/1.1.1/commons-logging-1.1.1.jar
Download https://jcenter.bintray.com/commons-codec/commons-codec/1.4/commons-codec-1.4.jar
Download https://jcenter.bintray.com/com/android/tools/external/lombok/lombok-ast/0.2.3/lombok-ast-0.2.3.jar
Download https://jcenter.bintray.com/com/android/tools/external/com-intellij/uast/145.597.3/uast-145.597.3.jar
Download https://jcenter.bintray.com/com/android/tools/annotations/25.2.0/annotations-25.2.0.jar
Download https://jcenter.bintray.com/com/google/guava/guava/18.0/guava-18.0.jar

FAILURE: Build failed with an exception.

* What went wrong:
Task 'test' not found in project ':myproject'.

* Try:
Run gradlew tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 32.707 secs

travis_time:end:07b2b2a4:start=1474639746657021455,finish=1474639780965732092,duration=34308710637
[0K
[31;1mThe command "./gradlew :myproject:test" exited with 1.[0m

Done. Your build exited with 1.

我尝试过不使用gradle包装器无济于事。

知道出了什么问题吗?

1 个答案:

答案 0 :(得分:1)

问题可能就在这一行:

script: ./gradlew :myproject:test

尝试

script: ./gradlew test

script: ./gradlew :app:test

更新:语法

正如here所说:

  

要执行特定子项目的任务,请指定其任务路径。   例如:

gradle :ABC:build
     

前导:代表根项目。 ABC是子项目,   和build该项目中的任务。

或者,为所有模块/子项目执行所需任务:

gradle build

如果您只需要执行根项目的任务,请使用下一个格式为注释here

gradle :build