Gradle Helloworld - Main Class

Reference
Thanks 良葛格, his explanation is so simple and good to read and practice!!

Class
package examples;
public class HelloMain {
    public static void main(String[] params) {
        System.out.println("Hello world:" + params[0]);
    }
}

build.gradle
apply plugin:'java'
apply plugin:'application'

mainClassName='examples.HelloMain'

run {
    args username
}

run

$ gradle run -Pusername=Isaac

> Task :run
Hello world:Isaac

BUILD SUCCESSFUL in 721ms
3 actionable tasks: 1 executed, 2 up-to-date

沒有留言:

張貼留言

caffeinate – make your Mac awake

When running long tests on macOS, the machine may go to sleep if you don’t touch it. There’s a built-in command that keeps it awake. ...