Simple Java project build example

(vivek prasad) #1

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

(René Groeschke) #2

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'

(vivek prasad) #3

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

(René Groeschke) #4

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

(vivek prasad) #5

Thank you .It worked

(vivek prasad) #6

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

(René Groeschke) #7

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


(vivek prasad) #8
Directory 'D:\sow\SowTrackerTool\src\main\webapp' specified for property 'webAppSourceDirectory' does not exist.

What should i do now

(Luke Daley) #9

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

(vivek prasad) #10

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

(René Groeschke) #11

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

cheers, René

(vivek prasad) #12

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 .

(René Groeschke) #13

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

(vivek prasad) #14

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

(vivek prasad) #15

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

(vivek prasad) #16

Hi Rene

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

(René Groeschke) #17

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é