如何在gradle中执行jar文件? [英] How to execute jar file in gradle?
问题描述
当我使用 ant 构建我的 android 项目时,我需要一些这样的任务:
When I use the ant to build my android project , I need some task like this:
<java jar="./build_tools/yuicompressor-2.4.8.jar" fork="true" failonerror="true">
<arg value="-o"/>
<arg value="${out.dir}/all-min-mobile.js"/>
<arg value="--charset"/>
<arg value="utf-8"/>
<arg value="${out.dir}/all-mobile.js"/>
</java>
我需要在我的 gradle 构建过程中完成这个过程.然后我将以下脚本放在我的 build.gradle 文件中:
I need to do the process in my gradle build process.Then I put following script in my build.gradle file:
task (runCompressTool , dependsOn: jar, type: JavaExec) {
classpath files('./build_tools/yuicompressor-2.4.8.jar')
main 'com.yahoo.platform.yui.compressor.Bootstrap'
args[0] = '-o'
args[1] = '${buildDir}/all-min-web.js'
args[2] = '--charset'
args[3] = 'utf-8'
args[4] = '--type'
args[5]='js'
args[6] = '${buildDir}/all-web.js'
}当我运行这个任务时,它失败了,只是告诉我退出代码是 1 而没有告诉我出了什么问题.有谁能帮帮我吗?
} When I run this task , it failed and just told me the exit code is 1 and didn't tell me what is wrong. So is there any body who can help me?
推荐答案
查看 Gradle 附带的 JavaExec 任务.您可以在以下 gradle dsl 参考中找到描述:http://gradle.org/docs/current/dsl/org.gradle.api.tasks.JavaExec.html
Have a look at the JavaExec task that is shipped with Gradle. You can find a description at the gradle dsl reference at: http://gradle.org/docs/current/dsl/org.gradle.api.tasks.JavaExec.html
这篇关于如何在gradle中执行jar文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!