如何将命令传递给includeproject的build.gradle

时间:2019-02-21 12:36:28

标签: gradle

我需要将“ build -x test”之类的命令传递给包含的项目,该怎么做? 任何提示都将受到欢迎! ,目前没有像下面这样的-x测试

plugins {
  id "com.gradle.build-scan" version "1.6"
}

apply plugin: 'eclipse'

defaultTasks 'build'

//gradle build -Pfast=true 
task build{
    if(project.findProperty('fast')&&project.findProperty('fast').toLowerCase()=='true') {
        println "#### build fast###  " + project.findProperty('fast')
        gradle.includedBuild('another-project').task(':build')
    }else{
        println "#### build normally###" 
        dependsOn gradle.includedBuild('another-project').task(':test')
        dependsOn gradle.includedBuild('another-project').task(':build')
    }
}

task clean{
    dependsOn gradle.includedBuild('another-project').task(':clean')
}

task test{
    dependsOn gradle.includedBuild('another-project').task(':clean')
    dependsOn gradle.includedBuild('another-project').task(':test')
}

1 个答案:

答案 0 :(得分:0)

在单词周围使用以下文字可以解决我的问题

workingDir '../another-project'
commandLine 'gradle', 'build' ,'-x' ,'test'