Gradle exclude a specific subproject from full build

前端 未结 4 1992
别那么骄傲
别那么骄傲 2020-12-13 19:31


In our Gradle project, we want to add a new module for functional-tests that needs to be able to access dependencies from other subprojects but still not be run as

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-13 19:56

    I found a better solution to be to exclude the functional tests from running on the command line or via the build file.

    For example, to run all tests except the functional tests, run:

    $ gradle check -x :functional-tests:check
    

    Then when building the project, you can let the subproject build but exclude their tests from running.

    $ gradle clean assemble -x :functional-tests:check
    

    A better option is do disable the functional tests in your build file unless a property is set. For example, in your build.gradle you'd add:

    project('functional-tests') {
        test {
            onlyIf {
                project.hasProperty("functionalTests")
            }
        }
    }
    

    This way, functional tests are always skipped unless you specify a specific build property:

    $ gradle check
    $ gradle -PfunctionalTests check
    

    Hope that helps!

提交回复
热议问题