我怎样才能运行的新任务的gradle? [英] How can I run new gradle task?
问题描述
我在的build.gradle创建新任务的gradle:
任务callCL(类型:执行){
的println你好
命令行'./rerun.sh
}
这假设运行rerun.sh:
#!/斌/庆典黄瓜-f重新运行--out rerun.txt文件=rerun.txt
如果[-f$文件],然后
黄瓜@ rerun.txt
RM $文件
科幻
我使用的IntelliJ作为IDE。我怎样才能运行这个任务?
我试图在zshell控制台中运行,并得到这个错误:
gradle这个callCL
zsh的:找不到命令:gradle这个
块引用>
块引用>但在IDE我用这样的gradle必须安装它所有的时间。
我该如何解决这个问题?而且是我写的好吗?
解决方案试试这个:
1.确保GRADLE_HOME,GRADLE_OPTS设置。
2.确保$ PATH有GRADLE_HOME /斌在里面。
3. 的gradle其中的应该返回你的有效输出。
4.然后,见下文
,如果这个工程在命令提示符下,那么你的IDE设置,只需要知道的是GRADLE_HOME又名其安装/可执行文件(无论是gradle这个或gradle.bat)的注:的我用我自己的虚拟rerun.sh文件,你可以使用的build.gradle(如下图所示)。
$猫rerun.sh
#!/斌/庆典回音林再运行一个命令回声
回声东西
回声......
回声$猫的build.gradle
任务callCL(类型:执行){
的println-----
的println你好
的println-----
可执行的庆典
ARGS-c,庆典./rerun.sh //下面将做以及在bash神奇数字已设置为#!/斌/庆典
// ARGS-c,./rerun.sh
}$ /cygdrive/c/gradle-2.0/bin/gradle callCL
-----
你好
-----
:callCL
林再运行一个命令回声
某物
...BUILD SUCCESSFUL总时间:2.006秒I have created a new gradle task in build.gradle:
task callCL(type: Exec) { println "hello" commandLine './rerun.sh' }
Which suppose to run rerun.sh:
#!/bin/bash cucumber -f rerun --out rerun.txt file="rerun.txt" if [ -f "$file" ] then cucumber @rerun.txt rm $file fi
I'm using IntelliJ as an IDE. How can I run this task?
I have tried to run in the zshell console and got this error:
gradle callCL zsh: command not found: gradle
But in the IDE I use gradle all the time so it must be installed.
How can I fix this? And is my writing ok?
解决方案Try this:
1. Make sure GRADLE_HOME, GRADLE_OPTS are set.
2. Make sure $PATH has GRADLE_HOME/bin in it.
3. which gradle should return you a valid output.
4. then, see below
, if this works on command prompt, then your IDE setting just need to know where's is GRADLE_HOME aka its installed / executable (either gradle or gradle.bat)NOTE: I have used my own dummy rerun.sh file, you can you use build.gradle (as shown below).
$ cat rerun.sh
#!/bin/bash echo Im re-running a command echo echo something echo ... echo
$ cat build.gradle
task callCL(type: Exec) { println "-----" println "hello" println "-----" executable "bash" args "-c", "bash ./rerun.sh" //The following will do as well as magic number in bash is already set to #!/bin/bash //args "-c", "./rerun.sh" }
$ /cygdrive/c/gradle-2.0/bin/gradle callCL
----- hello ----- :callCL Im re-running a command echo something ... BUILD SUCCESSFUL Total time: 2.006 secs
这篇关于我怎样才能运行的新任务的gradle?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!