英文:
How to call Gradle build task from Gulp build running in Node.js environment
问题
我已将Gradle添加到我的项目中以管理Java依赖关系,基本上它会从Maven中获取所有的jar包,然后运行一个复制任务将所有的jar包复制到一个目标文件夹。
我从项目根文件夹在命令行中运行Gradle:
gradle build //获取所有的jar包
gradle copyJarsToDest //一个自定义的Gradle任务,用于复制所有的运行环境依赖
现在有人要求我将我的Gradle任务集成到现有的Gulp构建任务中。Gulp构建在Node.js环境中运行,并使用Babel来使用最新的JavaScript功能。Gulp构建从Git存储库中拉取代码,编译JavaScript和Java代码,然后将它们放入可以部署到我们服务器的jar中。当我开始研究如何从Gulp调用我的Gradle任务时,我只看到了关于从Gradle调用Gulp的各种文章,没有关于如何从Gulp调用Gradle的内容。
对于如何在Gulp内部调用Gradle,有什么想法吗?我对Gulp还不熟悉,不知道是否有办法让Gulp执行“gradle build”和“gradle copyJarstoDest”这两个命令?非常感谢。
英文:
I have added Gradle to my project to manages Java dependencies, it basically fetches all the jars from maven and then runs a copy task to copy all the jars to a destination folder.
I run the Gradle from the command line at the project root folder:
gradle build //fetch all the jars
gradle copyJarsToDest //a custom Gradle task to copy all the runtime environment dependencies
Now I am asked to integrate my Gradle task into an existing Gulp Build task. The Gulp Build is running in Node.js environment and uses Babel for the latest JavaScript features. The Gulp Build pulls the code from Git repository, compiles the JavaScript and Java code, then put them into jars that can be deployed to our servers. When I start to look into how to call my Gradle task from Gulp, I only see the various posts about calling Gulp from Gradle, nothing on calling Gradle from Gulp.
Any ideas on how to call Gradle within Gulp? I am new to Gulp, I don't know if there is a way for me to ask Gulp to execute command lines "gradle build" and "gradle copyJarstoDest"? Many thanks.
专注分享java语言的经验与见解,让所有开发者获益!
评论