您的位置:首页 > 编程语言 > Java开发

Gradle 实现编译和运行Java程序

2016-07-01 12:33 531 查看
group 'com.mind'
version '1.0-SNAPSHOT'

apply plugin: 'java'
apply plugin: 'application'

// main函数所在路径
mainClassName = 'com.mind.God'

sourceCompatibility = 1.5

repositories {
mavenCentral()
}

dependencies {
testCompile group: 'junit', name: 'junit', version: '4.11'
}

God.java

package com.mind;

/**
* Created by Lovell on 16/7/1.
*/

public class God {
private String configPath = "../../";

private static God god;
public static God getInstance(){
if (god == null) {
god = new God();
}
return god;
}

public void setConfigPath(String configPath) {
this.configPath = configPath;
}

public String getConfigPath() {
return configPath;
}

public static void main(String[] args) {
System.out.println("message Hello World.");
System.out.println("God");
//        God.getInstance().setConfigPath(args[0]);
}
}

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