您的位置:首页 > 其它

Gradle Construction Project -- HelloGradle

2015-05-16 15:39 134 查看

Download Gradle

https://gradle.org/downloads/

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

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: