Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
482 views
in Technique[技术] by (71.8m points)

extjs - Gradle -- execute multiple commands from task

I have 2 separate apps (in one project) that require 2 separate builds (sencha cmd). I have been asked to create a gradle script that will do the builds for both apps.

I created a task that builds one app, but am having troubles using the same task to build the 2nd app.

This is what I have so far:

task senchaCmdBuild (type: Exec) {
  workingDir 'src/main/app/MYAPP'
  commandLine 'cmd', 'c', 'sencha app build'
}

and this works fine.

When I add the following 2 lines to above task:

 workingDir 'src/main/app/MYOTHERAPP'
 commandLine 'cmd', 'c', 'sencha app build'

the first command is ignored and only the second command executes.

So is there anyway I can execute both commands with one task?

question from:https://stackoverflow.com/questions/35561014/gradle-execute-multiple-commands-from-task

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You can use the second way to declare task types on gradle.

task senchaCmdBuild {
  doLast {
    exec {
      workingDir 'src/main/app/MYAPP'
      commandLine 'cmd', 'c', 'sencha app build'
    }
    exec {
      workingDir 'src/main/app/MYOTHERAPP'
      commandLine 'cmd', 'c', 'sencha app build'
    }
  }
}

You need put the exec method in doLast in order to be executed only on execution flow


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...