Simple Java project build example

Please provide an example to build a simple java project along with dependencies fully written in gradle and groovy .This will help a lots to me as well as our fellows who are new to gradle .

I can not find even a single complete script for that on net

the simpliest java build file with repository and dependency definition can look like this:

apply plugin:'java'
    compile 'org.slf4j:slf4j-api:1.6.6'

Suppose I have a simple pojo class and i want to compile it, build it , and create a jar for it .

Please provide a Gradle build script for that

putting that java file in src/main/java of your project folder and run build with the script above should do the trick

Thank you .It worked

Hi Rene

with your help I am now able to compile the codes for my project

how to run it on jetty server

please help

You can either use the war plugin to package your web application as web archive and deploy this manually to your server. for testing your app you can also use the jetty plugin to start and stop your web app in a jetty container from your build. Have a look at the according chapters in the userguide: and


Directory 'D:\sow\SowTrackerTool\src\main\webapp' specified for property 'webAppSourceDirectory' does not exist.

What should i do now

Perhaps check out the samples that are part of the ‘-all’ distribution. There are some examples of web projects in there.

I am not getting any proper sample

Till now i have been able to compile all my java files to the build folder

what should i do now to configure my jetty server

Hey vivek, the jetty plugin chapter of the userguide has the details:

cheers, René

I am still not getting .

Till now i have only added the jetty plugin to the build script . Can u please suggest me how to proceed in a step wise manner .

In what problems do you run when trying out the jetty plugin?

I am sending u the screenshot

The project structure is

I have till now only added the jetty plugin to my build script

My build Script Is

Sorry i am new to jetty and i want to do a hot deployment on the jetty server ,without creating any war file.

Hi Rene

Are you there , please find the screenshots above and suggest a solution

To keep things clean here in the forum, let’s close this thread and move on in the other jetty related thread you already opened:

cheers, René