Gradle缺少动态任务

时间:2017-02-16 16:50:18

标签: gradle android-gradle build.gradle finalizer gradle-task

我有一个宣布的任务:

tasks.getByName('connectedAndroidTest').finalizedBy 'archiveReports'

但是当我试图建立项目时,它告诉我:

Caused by: org.gradle.api.UnknownTaskException: Task with name 'connectedAndroidTest' not found in project ':TestProject'.
        at org.gradle.api.internal.tasks.DefaultTaskCollection.createNotFoundException(DefaultTaskCollection.java:80)
        at org.gradle.api.internal.DefaultNamedDomainObjectCollection.getByName(DefaultNamedDomainObjectCollection.java:229)
        at org.gradle.api.internal.tasks.DefaultTaskCollection.getByName(DefaultTaskCollection.java:31)
        at org.gradle.api.tasks.TaskCollection$getByName.call(Unknown Source)
        at build_6w8zk6ic8wtqwlvwwubix2jc3.run(/path/to/build.gradle:84)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
        ... 58 more

如果我改为其他方式:

tasks.connectedAndroidTest.finalizedBy 'archiveReports'

问题非常相似:

Caused by: groovy.lang.MissingPropertyException: Could not get unknown property 'connectedAndroidTest' for task set.
        at org.gradle.internal.metaobject.AbstractDynamicObject.getMissingProperty(AbstractDynamicObject.java:92)
        at org.gradle.internal.metaobject.AbstractDynamicObject.getProperty(AbstractDynamicObject.java:62)
        at org.gradle.api.internal.tasks.DefaultTaskContainer_Decorated.getProperty(Unknown Source)
        at build_6w8zk6ic8wtqwlvwwubix2jc3.run(/path/to/build.gradle:84)
        at org.gradle.groovy.scripts.internal.DefaultScriptRunnerFactory$ScriptRunnerImpl.run(DefaultScriptRunnerFactory.java:91)
        ... 58 more

我知道这个任务是由于风味而动态生成的,但是如何将终结器添加到动态任务中?

0 个答案:

没有答案