(1)Gradle是一个基于Apache Ant和Apache Maven概念的项目自动化构建工具。它使用一种基于Groovy的特定领域语言(DSL)来声明项目设置,抛弃了基于XML的各种繁琐配置。更多简介请百度,谢谢;
(2)Gradle(Groovy)>maven(依赖管理,发布)>ant(编译,测试,打包),主流的构建工具发展;
1:今天看到上海的而立之年的大佬感慨,定居问题,好像对我们这种刚踏入这行的小菜鸟来说貌似有点小远,不说太多废话了,之前找工作的经历写了一下,本来希望对同处于大三的有所帮助,或者对学弟学妹有所帮助,被定性为不符合要求的文章被踢出首页,所以没几个看到的,不啰嗦了。身为小菜鸟的我上班一已经周了,刚开始的一周熟悉基础知识,今天周一开始研究公司自己封装的框架,好吧,大学学的什么ssh,ssm框架貌似都没用上,不过构建工具之前研究的是maven,公司用的gradle,好好研究一下。所以从头开始学习。废话不多说了,结合之前大佬的研究,今天研究一下gradle;
2:gradle官网:https://gradle.org/
gradle官网下载地址:https://gradle.org/install/(好吧,都是英文,看着真费劲,下面简单实用截图介绍一下如何下载;它是分为unix,macOs,window,所以看清楚英文说的什么意思,安装的前提是已经安装jdk了哈,验证方式win+r,输入cmd,然后输入java -version,看看jdk是否已经安装成功;)
gradle慕课学习网址:http://www.imooc.com/learn/833
将下载之后的gradle文件解压缩:
解压缩之后配置配置一下环境变量,和验证一下是否配置成功:
3:配置如下所示:新建一个GRADLE_HOME,将解压缩的文件路径写进去,然后在path最后面加上;%GRADLE_HOME%in这句话;
4:验证一下效果,看配置是否正确,出现以下效果说明配置成功,至此gradle就搭建完成:
5:eclipse下面gradle的搭建(打开eclipse--->help--->eclipse marketplace--->搜索gradle);
6:搭建gradle项目,File--->New--->Other--->Gradle--->Gradle project--->Next然后出现以下界面:
点击next之后出现以下界面(输入项目名称,路径按照默认的;然后next):
点击next之后出现以下界面:
选择自己Windows系统的gradle路径( windows 下载、配置gradle),其他不填,然后next:
然后出现以下错误:
1 org.gradle.tooling.GradleConnectionException: Could not execute build using Gradle installation 'F:gradlegradle'. 2 at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55) 3 at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29) 4 at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41) 5 at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57) 6 at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 7 at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46) 8 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 9 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 10 at java.lang.Thread.run(Thread.java:745) 11 at org.gradle.tooling.internal.consumer.BlockingResultHandler.getResult(BlockingResultHandler.java:46) 12 at org.gradle.tooling.internal.consumer.DefaultBuildLauncher.run(DefaultBuildLauncher.java:77) 13 at com.gradleware.tooling.toolingclient.internal.DefaultToolingClient.executeAndWait(DefaultToolingClient.java:124) 14 at com.gradleware.tooling.toolingclient.internal.DefaultBuildLaunchRequest.executeAndWait(DefaultBuildLaunchRequest.java:49) 15 at org.eclipse.buildship.ui.wizard.project.ProjectCreationWizard$NewGradleProjectInitializer.run(ProjectCreationWizard.java:292) 16 at org.eclipse.buildship.core.projectimport.ProjectPreviewJob.runToolingApiJobInWorkspace(ProjectPreviewJob.java:73) 17 at org.eclipse.buildship.core.util.progress.ToolingApiWorkspaceJob$1.run(ToolingApiWorkspaceJob.java:79) 18 at org.eclipse.buildship.core.util.progress.ToolingApiInvoker.invoke(ToolingApiInvoker.java:62) 19 at org.eclipse.buildship.core.util.progress.ToolingApiWorkspaceJob.runInWorkspace(ToolingApiWorkspaceJob.java:76) 20 at org.eclipse.core.internal.resources.InternalWorkspaceJob.run(InternalWorkspaceJob.java:39) 21 at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) 22 Caused by: java.lang.IllegalArgumentException: The specified Gradle installation directory 'F:gradlegradle' does not appear to contain a Gradle distribution. 23 at org.gradle.tooling.internal.consumer.DistributionFactory$InstalledDistribution.getToolingImplementationClasspath(DistributionFactory.java:169) 24 at org.gradle.tooling.internal.consumer.loader.CachingToolingImplementationLoader.create(CachingToolingImplementationLoader.java:40) 25 at org.gradle.tooling.internal.consumer.loader.SynchronizedToolingImplementationLoader.create(SynchronizedToolingImplementationLoader.java:43) 26 at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.onStartAction(LazyConsumerActionExecutor.java:101) 27 at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:83) 28 at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45) 29 at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58) 30 at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38) 31 at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55) 32 at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 33 at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:46) 34 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) 35 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) 36 at java.lang.Thread.run(Thread.java:745)
出现上面的错误的原因是因为我这个local installion directory的这个路径是自己gradle的路径,不可以是其他的路径哦;
最后点击finally即可;
7:创建好的gradle项目如下所示:
8:打开build.gradle 添加你想要依赖的jar包
如以下两个包(查看各种包gradle依赖脚本教程 http://mvnrepository.com/ ):
compile group: 'org.springframework', name: 'spring-context', version: '4.3.2.RELEASE'
compile group: 'commons-dbcp', name: 'commons-dbcp', version: '1.3'
9、右键build.gradle 刷新整个gradle项目,下载所需的jar包:
下载jar包过程如下所示:
10:简单查看以下是否下载成功,至此使用eclipse创建gradle项目基本结束:
11:查看jar包对应的坐标:
mvnrepository官网:https://mvnrepository.com/
然后点击如下箭头所示:
然后点击下面箭头所示的:
然后点击如下箭头所示的:
学如逆水行舟,不进则退......