Getting started (no IDE)

John Ahlroos edited this page Dec 28, 2018 · 19 revisions

If you are new to Gradle and the Gradle Vaadin plugin then this is the right place to start. In this tutorial we will setup a project, add a runner and finally run the project only using the terminal.

Before we can start you need to ensure you have an up-2-date version of Gradle.

If you haven't installed Gradle yet, go to https://gradle.org/install/ and follow the instructions to get it installed. Remember, you will need to use the Gradle 5.

You can also use the Gradle Wrapper in your project so you do not have to install Gradle 5 globally. To do that, in the project folder run, gradle wrapper --gradle-version=5.0. That will install Gradle 5 in your project. Do this before creating the build.gradle files in the project. When importing the project into Intellij (or Eclipse) tell it to use the Gradle Wrapper in the project.

If you already have Gradle installed, then you need to verify that the version you use is Gradle 5 or above. You can do that by running gradle -v in the terminal. It should output the Gradle version in use.

Once that is done, we are ready to create our first project.

Start by creating a new folder for your project and move into it:

mkdir myapp
cd myapp

Next create a new file with the following contents (myapp/build.gradle):

plugins {
    id 'org.gretty' version '2.3.1'
    id 'com.devsoap.vaadin-flow' version '1.0.0.RC6'
}


// Automatically configure repositories and dependencies. For a more fine-grained example see
// https://github.com/devsoap/gradle-vaadin-flow/wiki/Dependency-management
vaadin.autoconfigure()

Now that we have the build file set, lets create a project! In the project folder run the vaadinCreateProject task:

gradle vaadinCreateProject

Once the task has run successfully you should see the following folder structure:

~/myapp $ tree
.
├── build.gradle  // The project build file
└── src
    └── main
        ├── java
        │   └── com
        │       └── example
        │           └── myapp
        │               ├── MyappServlet.java // The servlet of the Vaadin project
        │               └── MyappView.java // The main view of the Vaadin Project
        └── webapp
            └── frontend
                └── myapp-theme.css // The application theme

8 directories, 4 files

And that is all that is needed to start with the plugin.

We can now run the project by using the Gretty project runner and triggering the jettyRun target:

~/myapp $ gradle jettyRun

Your project should soon then be running on http://localhost:8080/myapp

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.