Gradle工具安装及环境配置
Gradle工具下载:https://services.gradle.org/distributions/
一、下载
gradle-4.10.2-all.zip
https://downloads.gradle-dn.com/distributions/gradle-4.10.2-all.zip
二、环境配置
解压到这个目录:D:\6.CommonTools\gradle-4.10.2-all
将 D:\6.CommonTools\gradle-4.10.2-all\gradle-4.10.2\bin 添加到path
三、运行是否安装成功?
运行命令:gradle
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | D:\6.CommonTools\gradle-4.10.2-all\gradle-4.10.2\bin>gradle.bat Starting a Gradle Daemon (subsequent builds will be faster) FAILURE: Build failed with an exception. * What went wrong: Unable to start the daemon process. This problem might be caused by incorrect configuration of the daemon. For example, an unrecognized jvm option is used. Please refer to the user guide chapter on the daemon at https: //docs .gradle.org /4 .10.2 /userguide/gradle_daemon .html Please read the following process output to find out more : ----------------------- Error occurred during initialization of VM Could not reserve enough space for 1048576KB object heap * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights. * Get more help at https: //help .gradle.org |
提示访问链接: https://docs.gradle.org/4.10.2/userguide/gradle_daemon.html
解决方法:
进入 C:\Users\用户名\.gradle 目录,手动新建一个文件:gradle.properties,gradle.properties文件内容添加 org.gradle.daemon=false 一行
再次打开cmd终端,运行ok,如下:
四、demo练习
创建一个文件:build.gradle,内容为:
1 2 3 4 | // 定义hello1任务,传入的代码块负责配置该任务 task hello1 { println "配置第一个任务" } |
输入:gradle build.gradle
虽然输出了,但是报了一个异常,如何解决?
通过下面方式运行:
先执行:gradle tasks
再执行:gradle build
运行后不会提示错误信息。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
2019-03-04 WPS 2019 各组收集字串标注