Last active
February 5, 2016 01:23
-
-
Save kazurof/c094862977f59fa16ec8 to your computer and use it in GitHub Desktop.
GradleでJavaアプリを実行する最小構成サンプル ref: http://qiita.com/kazurof/items/d5b00f7baf2b1699257d
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'java' | |
repositories { | |
jcenter() | |
} | |
dependencies { | |
compile 'org.apache.commons:commons-lang3:3.4' | |
} | |
task nantoka(type: JavaExec) { | |
main = "org.example.Nantoka" | |
classpath = sourceSets.main.runtimeClasspath | |
args('apple', 'banana', 'cherry') | |
args 'durian' | |
} | |
// gradle -Ddousita.param=kousita kantoka | |
task kantoka(type: JavaExec) { | |
main = "org.example.Kantoka" | |
classpath = sourceSets.main.runtimeClasspath | |
args(System.properties['dousita.param'] ?: "default") | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
│ build.gradle | |
└─src | |
└─main | |
└─java | |
└─org | |
└─example | |
Kantoka.java | |
Nantoka.java |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import org.apache.commons.lang3.SystemUtils; | |
import java.util.Arrays; | |
public class Kantoka { | |
public static void main(String[] args) { | |
System.out.println("This is Kantoka"); | |
System.out.println(args.length); | |
Arrays.stream(args).forEach(System.out::println); | |
System.out.println(SystemUtils.JAVA_VERSION); | |
Nantoka.doNantoka(); | |
} | |
static void doKantoka() { | |
System.out.println("i am Kantoka"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.example; | |
import java.util.Arrays; | |
public class Nantoka { | |
public static void main(String[] args) { | |
System.out.println("This is Nantoka"); | |
System.out.println(args.length); | |
Arrays.stream(args).forEach(System.out::println); | |
Kantoka.doKantoka(); | |
} | |
static void doNantoka() { | |
System.out.println("i am Nantoka"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment