强制依赖gradleApi()

时间:2015-10-12 10:49:27

标签: gradle build.gradle

我的gradle插件需要gradle API。因此,我使用Gradle 2.7的gradleApi()依赖。

dependencies {
    compile gradleApi()
    testCompile 'junit:junit:4.11'
    ...
}

Gradle 2.7附带junit 4.12给我带来了很多麻烦。这就是为什么我强制使用junit版本4.11。如果我显示依赖关系树,它就不会出现。但是在使用gradle测试的测试执行期间,它使用了junit 4.12。

configurations.all {
    resolutionStrategy {
        failOnVersionConflict()

        force 'junit:junit:4.11', 'commons-logging:commons-logging:1.1.3'
    }
}

我知道因为一个powermock错误消息而使用了错误的verson,这只发生在junit 4.12上。如果我使用gradle 2.0,那么构建工作正常。

org.powermock.reflect.exceptions.FieldNotFoundException: Field 'fTestClass' was not found in class org.junit.internal.runners.MethodValidator.

如何从gradleApi()中排除依赖项?

0 个答案:

没有答案