Transferred from: http://my.oschina.net/moziqi/blog/308842
Reference to the Http://blog.sina.com.cn/s/blog_4b20ae2e0102uz4t.html
1. On grandle website Download gradle, address: http://www.gradle.org/downloads
If just run can only download bin, in order to expand the development or download all.
2. After downloading, unzip the zip directly and put it in your computer's software installation directory, for example: D:\Program Files
3. In the computer/My Computer settings environment variables, if you download all, you need to add Gradle_home point to gradle the directory of the installation directory, for example: D:\Program files\gradle-2.0. You then need to add the bin directory of the Gradle to the PATH environment variable, for example: D:\Program files\gradle-2.0\bin
4. The above steps are set up, open cmd, run gradle-v can see Gradle version information, flag configuration is complete.
5. Open Eclipse,help-->install new software, enter Http://dist.springsource.com/release/TOOLS/gradle
If the prompt cannot find the address, it is estimated that the wall dropped, need to FQ. If you find the address, choose the reality to install the items, and then continue to press the next step, installed, restart Eclipse.
6. Create a Web project and create a Build.gradle file in the root directory
?
12345678910111213141516171819202122232425262728293031323334353637383940 |
import
org.gradle.plugins.ide.eclipse.model.Facet
apply plugin:
‘maven‘
apply plugin:
‘java‘
apply plugin:
‘war‘
apply plugin:
‘eclipse-wtp‘
sourceCompatibility =
1.8 // 设置 JDK 版本
webAppDirName =
‘WebContent‘
// 设置 WebApp 根目录
sourceSets.main.java.srcDir
‘src‘
// 设置 Java 源码所在目录
// 设置 maven 库地址
repositories {
mavenCentral()
// 中央库
maven { url
‘http://localhost:8081/nexus/content/groups/public‘
} // 自定义库地址
}
// 设置依赖
dependencies {
providedCompile
‘javax.servlet:servlet-api:2.5‘
// 编译期
providedRuntime
‘javax.servlet:jstl:1.2‘
// 运行时
}
// 设置 Project Facets
eclipse {
wtp {
facet {
facet name:
‘jst.web‘
, type: Facet.FacetType.fixed
facet name:
‘wst.jsdt.web‘
, type: Facet.FacetType.fixed
facet name:
‘jst.java‘
, type: Facet.FacetType.fixed
facet name:
‘jst.web‘
, version:
‘2.5‘
facet name:
‘jst.java‘
, version:
‘1.8‘
facet name:
‘wst.jsdt.web‘
, version:
‘1.0‘
}
}
}
|
Back up a picture for everyone to see, afraid of unfamiliar
See, my project has a G, under normal circumstances is not, how to have it? We need to right-click the project "Configure->convert to Gradle project.", and then just wait for the OK, just like I have this icon G, because we add the dependency package right? , we also need to right-click the project "Gradle->refresh all" and the jar will be loaded
Look, it feels weird, right? So we continue to right-click the project, "gradle-> enable Depe .... Mana .... (Rely on management, the word is too long, too lazy to play) "
That would be nice to see.
7. Set the next jar to download the saved address, or the default is saved in the C drive, "Window->preferences->gradle" (Can not be set, I personally do not like on the C-drive)
Fill in one more of my picture:
Eclipse under Gradle Configuration