Wednesday, November 4, 2015

Building Java Projects with Gradle Video and Notes

gradle tasks
gradle wrapper
gradlew build
gradlew run
jar tvf build/libs/gs-gradle-0.1.0.jar

HelloWorld.java
package hello;

import org.joda.time.LocalTime;

public class HelloWorld{
public static void main(String[] args){
LocalTime currentTime = new LocalTime();
System.out.println("The current local time is: " + currentTime);

Greeter greeter = new Greeter();
System.out.println(greeter.sayHello());
}
}

Greeter.java
package hello;

public class Greeter{
public String sayHello(){
return "Hello world!";
}
}

//build.gradle file starts
apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'application'

mainClassName = 'hello.HelloWorld'

repositories{
mavenCentral()
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

dependencies {
compile "joda-time:joda-time:2.2"
}

jar{
baseName = 'gs-gradle'
version = '0.1.0'
}

task wrapper(type: Wrapper){
gradleVersion = '2.3'
}
//build.gradle file ends

No comments: