Download Gradle
Configure Environment
GRADLE_HOME=D:\gradle
PATH=%GRADLE_HOME%\bin
Verify Gradle Installation
gradle -version
Install Plug-in
Gradle IDE
Create Gradle Project
New --> Other --> Gradle Project
Configure build.gradle
Configure Repositories
Configure relevant repositories url
repositories { maven { url "http://repo.mycompany.com/maven2" } }
Configure Dependencies
e.g.
dependencies { compile group: 'commons-io', name: 'commons-io', version: '2.+' compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.+' testCompile group: 'junit', name: 'junit', version: '4.+' }
Gradle Build
D:\workspace\Gradle-Demo>gradle build cleanEclipse eclipse
HelloGradle Sample Class
package org.gradle; import org.apache.commons.lang3.StringUtils; public class HelloGradle { private final String name; public HelloGradle(String name) { super(); this.name = name; } public String getName() { return this.name; } public static void main(String[] args) { String ping = "Hello, Gradle"; String pong = "I am Zhou Shengshuai."; ping = StringUtils.wrap(ping, '"'); System.out.println(ping + "\n" + pong); } }
File Structure after Gradle Build
时间: 2024-10-31 12:06:42