I am trying to create HellowWorld using Gradle; can't compile it

I am trying to create a HelloWorld project using Gradle. I seem to be following the instructions:

This is my build.gradle:

apply plugin 'java'

      

This is my java file:

package my;

public class HelloWorld {

    public static void main(String args[]) {

        System.out.println("hello, world");

    }

}

      

My java file is at

grtest / src / main / my /

Folder

my build.gradle is in the hardest /

When i do

gradle build

It creates grtest / build / grtest.jar

but this jar just contains the manifest but does not contain the class file

I am doing this on windows command line, i have java, javac in path.

How do I compile it?

+3


source to share


1 answer


The reason is that by default the java plugin expects your java sources to be under src/main/java/...

, resources to be under src/main/resources

, etc. (all paths are in your project directory, grtest

that's the point). Since your source code is in src/main/my

, then Gradle could not find a file to compile under src/main/java/...

, so you got an empty jar.



+2


source







All Articles