简体   繁体   English

在解决依赖项之前运行测试

[英]Run tests before dependency resolution

I have a root level project which contains ~100 sub-projects. 我有一个包含约100个子项目的根级项目。 The main goal of root project is to collect all produced jars into installer. 根项目的主要目标是将所有生产的jar收集到安装程序中。

In main project I am including subproject as a dependency and then do installer compilation like this: 在主项目中,我将子项目作为依赖项包含在内,然后像这样进行安装程序编译:

dependencies {
  blahblah project(":subproject1")
}

task blah(type: Copy) {
  from(configurations.blahblah)
  into 'qwe'
}

//and so on

I understand that jar artifact is produced by jar task and this task doesn't depend on test task. 我了解jar工件是由jar任务产生的,并且此任务不依赖于test任务。 And I see situation when Gradle produces installer first (which is time consuming) and only then runs tests. 我看到了Gradle首先生产安装程序(这很耗时)然后才运行测试的情况。 This is not very acceptable for me cause I need to get failure as soon as possible to not waste time. 这对我来说不是很可接受,因为我需要尽快失败以免浪费时间。

Can I solve this situation somehow? 我能以某种方式解决这种情况吗?

Thanks. 谢谢。

One solution would be to create a mustRunAfter constraint on the buildInstaller task, to ensure it will be run after all subprojects check tasks: 一种解决方案是在buildInstaller任务上创建mustRunAfter约束,以确保它将在所有子项目check任务之后运行:

In the installer sub-project build.gradle : 安装程序子项目build.gradle

gradle.projectsEvaluated {
    rootProject.subprojects.each { Project subproj ->
        if (subproj.name != project.name) {
            buildInstaller.mustRunAfter subproj.getTasks().getByName('check')
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM