开发者

How do i can call more than one gradle scripts into other gradle script

I am converting ant script to gradle.I have change following

<ant antfile="build.xml"
             target="clean"/>

task buildclean(type: GradleBuild)<< {
    buildFile ='build.gradle'
    tasks['clean']
}

task buildelocket(type: GradleBuild)<< {
    buildFile ='bussniess/build.gradle'
    tasks['elocket']
}

this gradle script is calling three more other gardle scripts.When i called开发者_如何转开发 buildclean task from other task under same gradle script it is not working properly

task callingtasks <<{
    tasks.buildclean.excute()
    tasks.buildelocket.excute()
}

How do i can call more than one gradle scripts into other gradle script


I think there are two issues with your build scripts:

  1. remove the "<<" in the buildclean and buildelocket task. << is a shortcut for doLast{} but buidfile and task property of tasks of type GradleBuild should be set in configurationphase not during execution phase:

    task buildclean(type: GradleBuild) {
        buildFile ='build.gradle'
        tasks << 'clean'
    }
    
    task buildelocket(type: GradleBuild){
         buildFile ='bussniess/build.gradle'
         tasks << 'elocket'
    }
    
  2. For a number of reasons you should avoid executing tasks explicitly via execute(). Try

    task callingtasks(dependsOn: ['buildclean', 'buildelocket']){
    }
    
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜